Skip to content

Commit e94feee

Browse files
committed
properly enabled selects in the new subscription view
1 parent 1f65fc0 commit e94feee

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

app/assets/javascripts/subscriptions.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
$(() => {
1+
document.addEventListener('DOMContentLoaded', () => {
2+
document.querySelectorAll('.js-subscription-type-select, .js-subscription-frequency-select').forEach((el) => {
3+
$(el).select2();
4+
});
5+
26
$('.js-enable-subscription').on('change', async (evt) => {
37
const $tgt = $(evt.target);
48
const $sub = $tgt.parents('details');
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1-
// Place all the styles related to the Subscriptions controller here.
2-
// They will automatically be included in application.css.
3-
// You can use Sass (SCSS) here: http://sass-lang.com/
1+
@import 'variables';
2+
3+
.new_subscription {
4+
.select2-container {
5+
height: 37px;
6+
margin: 4px 0px;
7+
}
8+
9+
.select2-container {
10+
.selection {
11+
.select2-selection {
12+
border-color: $muted-graphic;
13+
height: 100%;
14+
padding: 4px 0;
15+
}
16+
17+
.select2-selection__arrow {
18+
top: 50%;
19+
translate: 0 -50%;
20+
}
21+
}
22+
}
23+
}

app/views/subscriptions/new.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<%= f.select :type,
1515
options_for_select(type_choice_for(current_user), selected: @subscription.type),
1616
{ include_blank: true },
17-
class: 'form-element' %>
17+
class: 'form-element js-subscription-type-select' %>
1818
</div>
1919

2020
<div class="form-group">
@@ -35,7 +35,8 @@
3535
<div class="form-caption">How often do you want to be sent these emails?</div>
3636
<%= f.select :frequency,
3737
options_for_select(frequency_choice, selected: @subscription.frequency),
38-
{ include_blank: true }, class: 'form-element' %>
38+
{ include_blank: true },
39+
class: 'form-element js-subscription-frequency-select' %>
3940
</div>
4041

4142
<div class="actions">

0 commit comments

Comments
 (0)