Skip to content

Commit 9b136d7

Browse files
kushthedudeiamareebjamal
authored andcommitted
chore: Migrate admin,account to ES6 in app/controllers (#3716)
* Migration admin,account to ES6 in app/controllers * fixing travis test
1 parent dd4a997 commit 9b136d7

File tree

18 files changed

+526
-513
lines changed

18 files changed

+526
-513
lines changed

app/controllers/account/password.js

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
import Controller from '@ember/controller';
2+
import { action } from '@ember/object';
23

3-
export default Controller.extend({
4-
actions: {
5-
changePassword(passwordData) {
6-
this.set('isLoading', true);
7-
let payload = {
8-
'data': {
9-
'old-password' : passwordData.passwordCurrent,
10-
'new-password' : passwordData.passwordNew
11-
}
12-
};
13-
this.loader
14-
.post('/auth/change-password', payload)
15-
.then(() => {
16-
this.notify.success(this.l10n.t('Password updated successfully'),
4+
export default class extends Controller {
5+
6+
@action
7+
changePassword(passwordData) {
8+
this.set('isLoading', true);
9+
let payload = {
10+
'data': {
11+
'old-password' : passwordData.passwordCurrent,
12+
'new-password' : passwordData.passwordNew
13+
}
14+
};
15+
this.loader
16+
.post('/auth/change-password', payload)
17+
.then(() => {
18+
this.notify.success(this.l10n.t('Password updated successfully'),
19+
{
20+
id: 'pass_upd_succ'
21+
});
22+
})
23+
.catch(error => {
24+
if (error.errors) {
25+
this.notify.error(this.l10n.t(`${error.errors[0].detail}`),
26+
{
27+
id: 'err_pass_ser'
28+
});
29+
} else {
30+
this.notify.error(this.l10n.t('Unexpected error. Password did not change.'),
1731
{
18-
id: 'pass_upd_succ'
32+
id: 'err_unex_pass'
1933
});
20-
})
21-
.catch(error => {
22-
if (error.errors) {
23-
this.notify.error(this.l10n.t(`${error.errors[0].detail}`),
24-
{
25-
id: 'err_pass_ser'
26-
});
27-
} else {
28-
this.notify.error(this.l10n.t('Unexpected error. Password did not change.'),
29-
{
30-
id: 'err_unex_pass'
31-
});
32-
}
33-
})
34-
.finally(() => {
35-
this.set('isLoading', false);
36-
this.setProperties({ 'passwordCurrent': '', 'passwordNew': '', 'passwordRepeat': '' });
37-
});
38-
}
34+
}
35+
})
36+
.finally(() => {
37+
this.set('isLoading', false);
38+
this.setProperties({ 'passwordCurrent': '', 'passwordNew': '', 'passwordRepeat': '' });
39+
});
3940
}
40-
});
41+
}
42+

app/controllers/account/profile.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import Controller from '@ember/controller';
2+
import { action } from '@ember/object';
23

3-
export default Controller.extend({
4-
actions: {
5-
async updateContactInfo() {
6-
this.set('isLoading', true);
7-
try {
8-
await this.model.save();
9-
this.notify.success(this.l10n.t('Your Contact Info has been updated'),
10-
{
11-
id: 'cont_info_upd'
12-
});
13-
} catch (error) {
14-
this.notify.error(this.l10n.t(error.message),
15-
{
16-
id: 'cont_upd_error'
17-
});
18-
}
19-
this.set('isLoading', false);
4+
export default class extends Controller {
5+
@action
6+
async updateContactInfo() {
7+
this.set('isLoading', true);
8+
try {
9+
await this.model.save();
10+
this.notify.success(this.l10n.t('Your Contact Info has been updated'),
11+
{
12+
id: 'cont_info_upd'
13+
});
14+
} catch (error) {
15+
this.notify.error(this.l10n.t(error.message),
16+
{
17+
id: 'cont_upd_error'
18+
});
2019
}
20+
this.set('isLoading', false);
2121
}
22-
});
22+
}
Lines changed: 70 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,79 @@
11
import Controller from '@ember/controller';
22
import { camelCase, startCase } from 'lodash-es';
3+
import { action } from '@ember/object';
34

4-
export default Controller.extend({
5+
export default class extends Controller {
56

6-
disableEventSubtopic : true,
7-
currentTopicSelected : null,
7+
disableEventSubtopic = true;
8+
currentTopicSelected = null;
89

9-
actions: {
10-
async loadSubTopics(topic) {
11-
this.set('isLoading', true);
12-
try {
13-
this.set('model.eventSubTopics', await topic.get('subTopics').toArray());
14-
this.set('disableEventSubtopic', false);
15-
this.set('currentTopicSelected', topic);
16-
} catch (e) {
17-
this.notify.error(this.l10n.t('An unexpected error has occurred. SubTopics not loaded.'),
10+
@action
11+
async loadSubTopics(topic) {
12+
this.set('isLoading', true);
13+
try {
14+
this.set('model.eventSubTopics', await topic.subTopics.toArray());
15+
this.set('disableEventSubtopic', false);
16+
this.set('currentTopicSelected', topic);
17+
} catch (e) {
18+
this.notify.error(this.l10n.t('An unexpected error has occurred. SubTopics not loaded.'),
19+
{
20+
id: 'subtop_error'
21+
});
22+
} finally {
23+
this.set('isLoading', false);
24+
}
25+
}
26+
@action
27+
openModalFor(modelInstanceOrName) {
28+
const modelName = typeof modelInstanceOrName === 'string' ? modelInstanceOrName : modelInstanceOrName.constructor.modelName;
29+
const modelInstance = typeof modelInstanceOrName === 'string' ? this.store.createRecord(modelInstanceOrName) : modelInstanceOrName;
30+
const camelCasedValue = camelCase(modelName);
31+
this.set(camelCasedValue, modelInstance);
32+
modelInstance.openModal = true;
33+
}
34+
@action
35+
deleteEventProperty(eventProp) {
36+
this.set('isLoading', true);
37+
const modelName = camelCase(eventProp.constructor.modelName);
38+
eventProp.destroyRecord()
39+
.then(() => {
40+
this.get(`model.${modelName}s`).removeObject(eventProp);
41+
this.notify.success(this.l10n.t('This Event Property has been deleted successfully.'),
1842
{
19-
id: 'subtop_error'
43+
id: 'event_prop_del'
2044
});
21-
} finally {
45+
})
46+
.catch(() => {
47+
this.notify.error(this.l10n.t('An unexpected error has occurred. Event Type was not deleted.'),
48+
{
49+
id: 'event_type_error'
50+
});
51+
})
52+
.finally(() => {
2253
this.set('isLoading', false);
23-
}
24-
},
25-
openModalFor(modelInstanceOrName) {
26-
const modelName = typeof modelInstanceOrName === 'string' ? modelInstanceOrName : modelInstanceOrName.constructor.modelName;
27-
const modelInstance = typeof modelInstanceOrName === 'string' ? this.store.createRecord(modelInstanceOrName) : modelInstanceOrName;
28-
const camelCasedValue = camelCase(modelName);
29-
this.set(camelCasedValue, modelInstance);
30-
modelInstance.openModal = true;
31-
},
32-
deleteEventProperty(eventProp) {
33-
this.set('isLoading', true);
34-
const modelName = camelCase(eventProp.constructor.modelName);
35-
eventProp.destroyRecord()
36-
.then(() => {
37-
this.get(`model.${modelName}s`).removeObject(eventProp);
38-
this.notify.success(this.l10n.t('This Event Property has been deleted successfully.'),
39-
{
40-
id: 'event_prop_del'
41-
});
42-
})
43-
.catch(() => {
44-
this.notify.error(this.l10n.t('An unexpected error has occurred. Event Type was not deleted.'),
45-
{
46-
id: 'event_type_error'
47-
});
48-
})
49-
.finally(() => {
50-
this.set('isLoading', false);
51-
});
52-
},
53-
addEventProperty(modelInstance) {
54-
const camelCasedValue = camelCase(modelInstance.constructor.modelName);
55-
this.set('isLoading', true);
56-
modelInstance.save()
57-
.then(() => {
58-
this.get(`model.${camelCasedValue}s`).addObject(modelInstance);
59-
this.notify.success(this.l10n.t(`${startCase(camelCasedValue)} has been added successfully.`),
60-
{
61-
id: 'mode_add_succ'
62-
});
63-
})
64-
.catch(() => {
65-
this.notify.error(this.l10n.t(`An unexpected error has occurred. ${startCase(camelCasedValue)} not saved.`),
66-
{
67-
id: 'mode_err_succ'
68-
});
69-
})
70-
.finally(() => {
71-
this.set('isLoading', false);
72-
this.set(camelCasedValue, null);
73-
});
74-
}
54+
});
55+
}
56+
@action
57+
addEventProperty(modelInstance) {
58+
const camelCasedValue = camelCase(modelInstance.constructor.modelName);
59+
this.set('isLoading', true);
60+
modelInstance.save()
61+
.then(() => {
62+
this.get(`model.${camelCasedValue}s`).addObject(modelInstance);
63+
this.notify.success(this.l10n.t(`${startCase(camelCasedValue)} has been added successfully.`),
64+
{
65+
id: 'mode_add_succ'
66+
});
67+
})
68+
.catch(() => {
69+
this.notify.error(this.l10n.t(`An unexpected error has occurred. ${startCase(camelCasedValue)} not saved.`),
70+
{
71+
id: 'mode_err_succ'
72+
});
73+
})
74+
.finally(() => {
75+
this.set('isLoading', false);
76+
this.set(camelCasedValue, null);
77+
});
7578
}
76-
});
79+
}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import Controller from '@ember/controller';
2+
import { action } from '@ember/object';
23

3-
export default Controller.extend({
4-
actions: {
5-
saveSocials() {
6-
this.set('isLoading', true);
7-
let settings = this.model;
8-
settings.save()
9-
.then(() => {
10-
this.notify.success(this.l10n.t('Social links have been saved successfully.'),
11-
{
12-
id: 'social_link_upd'
13-
});
14-
})
15-
.catch(() => {
16-
this.notify.error(this.l10n.t('An unexpected error has occurred. Social links not saved.'),
17-
{
18-
id: 'unex_social_error'
19-
});
20-
})
21-
.finally(() => {
22-
this.set('isLoading', false);
23-
});
24-
}
4+
export default class extends Controller {
5+
@action
6+
saveSocials() {
7+
this.set('isLoading', true);
8+
let settings = this.model;
9+
settings.save()
10+
.then(() => {
11+
this.notify.success(this.l10n.t('Social links have been saved successfully.'),
12+
{
13+
id: 'social_link_upd'
14+
});
15+
})
16+
.catch(() => {
17+
this.notify.error(this.l10n.t('An unexpected error has occurred. Social links not saved.'),
18+
{
19+
id: 'unex_social_error'
20+
});
21+
})
22+
.finally(() => {
23+
this.set('isLoading', false);
24+
});
2525
}
26-
});
26+
}
Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
import { filterBy } from '@ember/object/computed';
22
import Controller from '@ember/controller';
3+
import { action } from '@ember/object';
34

4-
export default Controller.extend({
5-
footerPages: filterBy('model', 'place', 'footer'),
5+
export default class extends Controller {
66

7-
eventPages: filterBy('model', 'place', 'event'),
7+
footerPages = filterBy('model', 'place', 'footer');
88

9-
actions: {
10-
updateCurrentPage(page, type) {
11-
if (type === 'create') {
12-
this.set('isCreate', true);
13-
this.set('currentForm', this.store.createRecord('page'));
14-
} else {
15-
this.set('isCreate', false);
16-
this.set('currentForm', page);
17-
}
18-
this.set('isFormOpen', true);
19-
},
20-
savePage(page) {
21-
page.save()
22-
.then(() => {
23-
if (this.isCreate) {
24-
this.set('isFormOpen', false);
25-
}
26-
this.notify.success(this.l10n.t('Page details have been saved successfully.'),
27-
{
28-
id: 'page_detail_succ'
29-
});
30-
})
31-
.catch(() => {
32-
this.notify.error(this.l10n.t('An unexpected error has occurred. Page Details not saved.'),
33-
{
34-
id: 'page_detail_del'
35-
});
36-
});
9+
eventPages = filterBy('model', 'place', 'event');
10+
11+
@action
12+
updateCurrentPage(page, type) {
13+
if (type === 'create') {
14+
this.set('isCreate', true);
15+
this.set('currentForm', this.store.createRecord('page'));
16+
} else {
17+
this.set('isCreate', false);
18+
this.set('currentForm', page);
3719
}
20+
this.set('isFormOpen', true);
21+
}
22+
@action
23+
savePage(page) {
24+
page.save()
25+
.then(() => {
26+
if (this.isCreate) {
27+
this.set('isFormOpen', false);
28+
}
29+
this.notify.success(this.l10n.t('Page details have been saved successfully.'),
30+
{
31+
id: 'page_detail_succ'
32+
});
33+
})
34+
.catch(() => {
35+
this.notify.error(this.l10n.t('An unexpected error has occurred. Page Details not saved.'),
36+
{
37+
id: 'page_detail_del'
38+
});
39+
});
3840
}
39-
});
41+
}

0 commit comments

Comments
 (0)