Skip to content

Commit b2bdb9f

Browse files
khangoncweitat
andauthored
feature-8784:Add type year drop down custom from field (#8796)
* feature-8784:Add type year drop down custom from field * feature-8784: Update code Add type year drop down custom from field * feature-8784: Add type year drop down custom from field * feature-8784:Add type year drop down custom from field * feature-8784:Add type year drop down custom from field * feature-8784: Change start year in dropdown list --------- Co-authored-by: cweitat <[email protected]>
1 parent f085f33 commit b2bdb9f

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

app/components/forms/orders/order-form.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { genders } from 'open-event-frontend/utils/dictionary/genders';
1414
import { ageGroups } from 'open-event-frontend/utils/dictionary/age-groups';
1515
import { countries } from 'open-event-frontend/utils/dictionary/demography';
16-
16+
import { years } from 'open-event-frontend/utils/dictionary/year-list';
1717

1818
export default Component.extend(FormMixin, {
1919
router : service(),
@@ -593,6 +593,7 @@ export default Component.extend(FormMixin, {
593593
genders : orderBy(genders, 'name'),
594594
ageGroups : orderBy(ageGroups, 'age'),
595595
countries : orderBy(countries, 'name'),
596+
years : orderBy(years, 'year'),
596597

597598
actions: {
598599
submit(data) {

app/components/forms/wizard/custom-form-input.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<div class="item" data-value="text">{{t "Short Answer"}}</div>
3333
<div class="item" data-value="paragraph">{{t "Paragraph"}}</div>
3434
<div class="item" data-value="number">{{t "Number"}}</div>
35+
<div class="item" data-value="year">{{t "Year"}}</div>
3536
<div class="item" data-value="boolean">{{t "Yes/No"}}</div>
3637
<div class="item" data-value="richtextlink">{{t "Rich Text Links"}}</div>
3738
</div>

app/templates/components/forms/orders/order-form.hbs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,26 @@
198198
@name={{if field.isRequired (concat field.fieldIdentifier "_required_" index) (concat field.fieldIdentifier "_" index)}}
199199
@onChange={{action (mut holder.acceptVideoRecording)}}/>
200200
{{/if}}
201+
{{#if (eq field.type 'year')}}
202+
<UiDropdown
203+
@class="search selection"
204+
@selected={{mut (get holder field.identifier)}}
205+
@onChange={{action (mut holder.year)}}>
206+
<Input
207+
@type="hidden"
208+
@value={{get holder field.identifierPath}}
209+
@name={{if field.isRequired (concat field.fieldIdentifier "_required_" index) (concat field.fieldIdentifier "_" index)}} />
210+
<i class="dropdown icon"></i>
211+
<div class="default text">{{t 'Select your year'}}</div>
212+
<div class="menu">
213+
{{#each this.years as |years|}}
214+
<div class="item" data-value="{{@years.year}}">
215+
{{years.year}}
216+
</div>
217+
{{/each}}
218+
</div>
219+
</UiDropdown>
220+
{{/if}}
201221
</div>
202222
{{/if}}
203223
{{/if}}

app/utils/dictionary/year-list.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let year: number = new Date().getFullYear();
2+
const earliestYear = 1930;
3+
const dateDropdown = [];
4+
while (year >= earliestYear) {
5+
const data = {
6+
year
7+
}
8+
dateDropdown.push(data)
9+
year -= 1;
10+
}
11+
export const years = dateDropdown;

0 commit comments

Comments
 (0)