Skip to content

Commit 416260b

Browse files
kushthedudeiamareebjamal
authored andcommitted
chore: Migrate my-session, ticket and billing forms to ES6 (#3619)
1 parent fa27eac commit 416260b

File tree

5 files changed

+79
-74
lines changed

5 files changed

+79
-74
lines changed

app/components/forms/admin/settings/billing.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Component from '@ember/component';
22
import FormMixin from 'open-event-frontend/mixins/form';
33
import { validPhoneNumber } from 'open-event-frontend/utils/validators';
4+
import { action } from '@ember/object';
45

5-
export default Component.extend(FormMixin, {
6+
export default class extends Component.extend(FormMixin) {
67
getValidationRules() {
78
return {
89
inline : true,
@@ -99,13 +100,12 @@ export default Component.extend(FormMixin, {
99100
}
100101
}
101102
};
102-
},
103+
}
103104

104-
actions: {
105-
submit() {
106-
this.onValid(() => {
107-
this.save();
108-
});
109-
}
105+
@action
106+
submit() {
107+
this.onValid(() => {
108+
this.save();
109+
});
110110
}
111-
});
111+
}

app/components/forms/user-payment-info-form.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import Component from '@ember/component';
22
import FormMixin from 'open-event-frontend/mixins/form';
33
import { validPhoneNumber } from 'open-event-frontend/utils/validators';
44
import { pick, orderBy } from 'lodash-es';
5-
import { computed } from '@ember/object';
5+
import { action, computed } from '@ember/object';
66
import { countries } from 'open-event-frontend/utils/dictionary/demography';
77

8-
export default Component.extend(FormMixin, {
8+
export default class extends Component.extend(FormMixin) {
99
didInsertElement() {
10-
this._super(...arguments);
10+
super.didInsertElement(...arguments);
1111
this.set('userBillingInfo', pick(this.authManager.currentUser, ['billingContactName', 'billingCity', 'billingPhone', 'company', 'billingTaxInfo', 'billingCountry', 'billingState', 'billingAddress', 'billingZipCode', 'billingAdditionalInfo']));
12-
},
12+
}
1313

1414
getValidationRules() {
1515
return {
@@ -88,30 +88,30 @@ export default Component.extend(FormMixin, {
8888
}
8989
}
9090
};
91-
},
91+
}
9292

93-
countries: computed(function() {
93+
@computed()
94+
get countries() {
9495
return orderBy(countries, 'name');
95-
}),
96+
}
9697

97-
actions: {
98-
submit() {
99-
this.onValid(async() => {
100-
this.set('isLoading', true);
101-
try {
102-
this.authManager.currentUser.setProperties(this.userBillingInfo);
103-
await this.authManager.currentUser.save();
104-
this.notify.success(this.l10n.t('Your billing details has been updated'), {
105-
id: 'bill_det_updated'
106-
});
107-
} catch (error) {
108-
this.authManager.currentUser.rollbackAttributes();
109-
this.notify.error(this.l10n.t('An unexpected error occurred'), {
110-
id: 'bill_det_unexpect'
111-
});
112-
}
113-
this.set('isLoading', false);
114-
});
115-
}
98+
@action
99+
submit() {
100+
this.onValid(async() => {
101+
this.set('isLoading', true);
102+
try {
103+
this.authManager.currentUser.setProperties(this.userBillingInfo);
104+
await this.authManager.currentUser.save();
105+
this.notify.success(this.l10n.t('Your billing details has been updated'), {
106+
id: 'bill_det_updated'
107+
});
108+
} catch (error) {
109+
this.authManager.currentUser.rollbackAttributes();
110+
this.notify.error(this.l10n.t('An unexpected error occurred'), {
111+
id: 'bill_det_unexpect'
112+
});
113+
}
114+
this.set('isLoading', false);
115+
});
116116
}
117-
});
117+
}

app/controllers/my-sessions/view.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
import Controller from '@ember/controller';
2-
import { computed } from '@ember/object';
2+
import { computed, action } from '@ember/object';
33
import moment from 'moment';
44

5-
export default Controller.extend({
6-
isUpcoming: computed('model.endsAt', function() {
5+
export default class extends Controller {
6+
7+
@computed('model.endsAt')
8+
get isUpcoming() {
79
let endAt = this.get('model.endsAt');
810
if (endAt < moment()) {
911
return false;
1012
}
1113
return true;
12-
}),
14+
}
1315

14-
actions: {
15-
openProposalDeleteModal() {
16-
this.set('isProposalDeleteModalOpen', true);
17-
},
18-
deleteProposal() {
19-
this.set('isLoading', true);
20-
this.model.destroyRecord()
21-
.then(() => {
22-
this.transitionToRoute('my-sessions.index');
23-
this.notify.success(this.l10n.t('Proposal has been deleted successfully.'));
24-
})
25-
.catch(() => {
26-
this.notify.error(this.l10n.t('An unexpected error has occurred.'));
27-
})
28-
.finally(() => {
29-
this.set('isLoading', false);
30-
this.set('isProposalDeleteModalOpen', false);
31-
});
32-
}
16+
@action
17+
openProposalDeleteModal() {
18+
this.set('isProposalDeleteModalOpen', true);
19+
}
20+
21+
@action
22+
deleteProposal() {
23+
this.set('isLoading', true);
24+
this.model.destroyRecord()
25+
.then(() => {
26+
this.transitionToRoute('my-sessions.index');
27+
this.notify.success(this.l10n.t('Proposal has been deleted successfully.'));
28+
})
29+
.catch(() => {
30+
this.notify.error(this.l10n.t('An unexpected error has occurred.'));
31+
})
32+
.finally(() => {
33+
this.set('isLoading', false);
34+
this.set('isProposalDeleteModalOpen', false);
35+
});
3336
}
34-
});
37+
}

app/controllers/my-tickets/past.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Controller from '@ember/controller';
2-
export default Controller.extend({
3-
actions: {
4-
shareEvent(event) {
5-
this.set('eventToShare', event);
6-
this.set('isShareModalOpen', true);
7-
}
2+
import { action } from '@ember/object';
3+
4+
export default class extends Controller {
5+
@action
6+
shareEvent(event) {
7+
this.set('eventToShare', event);
8+
this.set('isShareModalOpen', true);
89
}
9-
});
10+
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Controller from '@ember/controller';
2-
export default Controller.extend({
3-
actions: {
4-
shareEvent(event) {
5-
this.set('eventToShare', event);
6-
this.set('isShareModalOpen', true);
7-
}
2+
import { action } from '@ember/object';
3+
4+
export default class extends Controller {
5+
@action
6+
shareEvent(event) {
7+
this.set('eventToShare', event);
8+
this.set('isShareModalOpen', true);
89
}
9-
});
10+
}

0 commit comments

Comments
 (0)