Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.

Commit 5d391d0

Browse files
authored
Merge pull request #371 from gitcoinco/hopsoft/349/sort-dropdowns
Improve UX around dropdowns
2 parents 18f8598 + 627bba2 commit 5d391d0

File tree

18 files changed

+198
-100
lines changed

18 files changed

+198
-100
lines changed

assets/.prettierrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
module.exports = {};
1+
module.exports = {
2+
trailingComma: 'es5',
3+
singleQuote: true,
4+
};

assets/src/css/_selectize.bootstrap4.scss

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* Selectize bootstrap 4
3-
*/
4-
51
.selectize-control {
62
position: relative;
73
}
@@ -39,6 +35,25 @@
3935
-webkit-border-radius: 0rem;
4036
-moz-border-radius: 0rem;
4137
border-radius: 0rem;
38+
39+
input {
40+
height: auto !important;
41+
}
42+
}
43+
44+
.selectize-control {
45+
&.single .item {
46+
max-width: 85% !important;
47+
white-space: nowrap;
48+
text-overflow: ellipsis;
49+
overflow: hidden;
50+
}
51+
&.multi .item {
52+
width: 180px !important;
53+
white-space: nowrap;
54+
text-overflow: ellipsis;
55+
overflow: hidden;
56+
}
4257
}
4358

4459
.selectize-control.multi .selectize-input.has-items {
@@ -136,6 +151,10 @@
136151
right: 0;
137152
}
138153

154+
.selectize-input, .selectize-dropdown {
155+
min-width: 250px;
156+
}
157+
139158
.selectize-dropdown {
140159
position: absolute;
141160
z-index: 10;
@@ -209,6 +228,11 @@
209228
overflow-x: hidden;
210229
max-height: 200px;
211230
-webkit-overflow-scrolling: touch;
231+
232+
.option {
233+
white-space: nowrap;
234+
text-overflow: ellipsis;
235+
}
212236
}
213237

214238
.selectize-control.single .selectize-input,
@@ -426,9 +450,9 @@
426450
}
427451

428452
.selectize-input.dropdown-active {
429-
-webkit-border-radius: 0.25rem;
430-
-moz-border-radius: 0.25rem;
431-
border-radius: 0.25rem;
453+
//-webkit-border-radius: 0.25rem;
454+
//-moz-border-radius: 0.25rem;
455+
//border-radius: 0.25rem;
432456
}
433457

434458
.selectize-input.dropdown-active::before {
@@ -475,4 +499,4 @@
475499
-webkit-border-radius: 0;
476500
-moz-border-radius: 0;
477501
border-radius: 0;
478-
}
502+
}

assets/src/css/codefund-framework/_custom.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ ul.list-group-kv li.list-group-item {
7676
.click-option:hover {
7777
text-decoration: underline;
7878
}
79+
80+
.page-item {
81+
.page-link.active {
82+
background-color: #ccecf8;
83+
}
84+
}

assets/src/onload.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import "selectize";
2-
import $ from "jquery";
1+
import 'selectize';
2+
import $ from 'jquery';
33

44
const initSelectize = () => {
5-
$("select.selectize").selectize({
6-
plugins: ["remove_button"],
7-
delimiter: ",",
8-
persist: false
5+
$('select.selectize').selectize({
6+
plugins: ['remove_button'],
7+
delimiter: ',',
8+
persist: false,
9+
onDropdownClose: _dropdown => {},
910
});
1011
};
1112

12-
const initFontAwesome = () => {
13-
return FontAwesome.dom.i2svg();
14-
};
15-
16-
document.addEventListener("turbolinks:load", () => {
13+
const initFontAwesome = () => FontAwesome.dom.i2svg();
14+
document.addEventListener('turbolinks:load', () => {
1715
initSelectize();
1816
initFontAwesome();
1917
});

lib/code_fund/assets/assets.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ defmodule CodeFund.Assets do
6060
end
6161

6262
def by_user_id(user_id) do
63-
from(o in Asset, where: o.user_id == ^user_id)
63+
from(o in Asset, where: o.user_id == ^user_id, order_by: fragment("lower(?)", o.name))
6464
|> CodeFund.Repo.all()
6565
end
6666

@@ -155,7 +155,8 @@ defmodule CodeFund.Assets do
155155
156156
"""
157157
def list_assets do
158-
Repo.all(Asset)
158+
from(a in Asset, order_by: fragment("lower(?)", a.name))
159+
|> Repo.all()
159160
end
160161

161162
defp filter_config(:assets) do

lib/code_fund/audiences/audiences.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ defmodule CodeFund.Audiences do
2525
2626
"""
2727
def list_audiences do
28-
Repo.all(Audience)
28+
from(a in Audience, order_by: fragment("lower(?)", a.name))
29+
|> Repo.all()
2930
|> Repo.preload(:campaigns)
3031
end
3132

lib/code_fund/creatives/creatives.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ defmodule CodeFund.Creatives do
6262
end
6363

6464
def by_user_id(user_id) do
65-
from(o in Creative, where: o.user_id == ^user_id)
65+
from(o in Creative, where: o.user_id == ^user_id, order_by: fragment("lower(?)", o.name))
6666
|> CodeFund.Repo.all()
6767
end
6868

@@ -160,7 +160,7 @@ defmodule CodeFund.Creatives do
160160
161161
"""
162162
def list_creatives do
163-
Repo.all(Creative)
163+
from(c in Creative, order_by: fragment("lower(?)", c.name)) |> Repo.all()
164164
end
165165

166166
defp filter_config(:creatives) do

lib/code_fund/templates/templates.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule CodeFund.Templates do
1919
2020
"""
2121
def list_templates do
22-
Template
22+
from(t in Template, order_by: fragment("lower(?)", t.name))
2323
|> Repo.all()
2424
|> Repo.preload([:themes])
2525
end

lib/code_fund/users/users.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ defmodule CodeFund.Users do
2424
end
2525

2626
def get_by_role(role) do
27-
from(u in User, where: ^role in u.roles, order_by: [asc: u.first_name]) |> Repo.all()
27+
from(u in User, where: ^role in u.roles, order_by: fragment("lower(?)", u.first_name))
28+
|> Repo.all()
2829
end
2930

3031
def get_by_api_key(api_key) do

lib/code_fund_web/controllers/campaign_controller.ex

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,17 @@ defmodule CodeFundWeb.CampaignController do
119119
status: [
120120
type: :select,
121121
label: "Status",
122-
opts: [choices: CodeFund.Campaigns.statuses()]
122+
opts: [
123+
choices: CodeFund.Campaigns.statuses()
124+
]
125+
],
126+
audience_id: [
127+
type: :select,
128+
label: "Audience",
129+
opts: [
130+
choices: audiences
131+
]
123132
],
124-
audience_id: [type: :select, label: "Audience", opts: [choices: audiences]],
125133
creative_id: [
126134
type: :select,
127135
label: "Creative",
@@ -157,31 +165,27 @@ defmodule CodeFundWeb.CampaignController do
157165
type: :multiple_select,
158166
label: "Included Topic Categories",
159167
opts: [
160-
class: "form-control campaign-form selectize",
161168
choices: Framework.GenericEnums.topic_categories()
162169
]
163170
],
164171
included_programming_languages: [
165172
type: :multiple_select,
166173
label: "Included Programming Languages",
167174
opts: [
168-
class: "form-control campaign-form selectize",
169175
choices: Framework.GenericEnums.programming_languages()
170176
]
171177
],
172178
excluded_topic_categories: [
173179
type: :multiple_select,
174180
label: "Excluded Topic Categories",
175181
opts: [
176-
class: "form-control campaign-form selectize",
177182
choices: Framework.GenericEnums.topic_categories()
178183
]
179184
],
180185
excluded_programming_languages: [
181186
type: :multiple_select,
182187
label: "Excluded Programming Languages",
183188
opts: [
184-
class: "form-control campaign-form selectize",
185189
choices: Framework.GenericEnums.programming_languages()
186190
]
187191
],
@@ -194,7 +198,6 @@ defmodule CodeFundWeb.CampaignController do
194198
action: "change->campaign-form#generateEstimates",
195199
key: "included_countries"
196200
],
197-
class: "form-control campaign-form selectize",
198201
choices: Framework.Geolocation.Countries.list(),
199202
hint: ~s"""
200203
<div>

0 commit comments

Comments
 (0)