Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 37 additions & 35 deletions app/controllers/account/password.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';

export default Controller.extend({
actions: {
changePassword(passwordData) {
this.set('isLoading', true);
let payload = {
'data': {
'old-password' : passwordData.passwordCurrent,
'new-password' : passwordData.passwordNew
}
};
this.loader
.post('/auth/change-password', payload)
.then(() => {
this.notify.success(this.l10n.t('Password updated successfully'),
export default class extends Controller {

@action
changePassword(passwordData) {
this.set('isLoading', true);
let payload = {
'data': {
'old-password' : passwordData.passwordCurrent,
'new-password' : passwordData.passwordNew
}
};
this.loader
.post('/auth/change-password', payload)
.then(() => {
this.notify.success(this.l10n.t('Password updated successfully'),
{
id: 'pass_upd_succ'
});
})
.catch(error => {
if (error.errors) {
this.notify.error(this.l10n.t(`${error.errors[0].detail}`),
{
id: 'err_pass_ser'
});
} else {
this.notify.error(this.l10n.t('Unexpected error. Password did not change.'),
{
id: 'pass_upd_succ'
id: 'err_unex_pass'
});
})
.catch(error => {
if (error.errors) {
this.notify.error(this.l10n.t(`${error.errors[0].detail}`),
{
id: 'err_pass_ser'
});
} else {
this.notify.error(this.l10n.t('Unexpected error. Password did not change.'),
{
id: 'err_unex_pass'
});
}
})
.finally(() => {
this.set('isLoading', false);
this.setProperties({ 'passwordCurrent': '', 'passwordNew': '', 'passwordRepeat': '' });
});
}
}
})
.finally(() => {
this.set('isLoading', false);
this.setProperties({ 'passwordCurrent': '', 'passwordNew': '', 'passwordRepeat': '' });
});
}
});
}

36 changes: 18 additions & 18 deletions app/controllers/account/profile.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';

export default Controller.extend({
actions: {
async updateContactInfo() {
this.set('isLoading', true);
try {
await this.model.save();
this.notify.success(this.l10n.t('Your Contact Info has been updated'),
{
id: 'cont_info_upd'
});
} catch (error) {
this.notify.error(this.l10n.t(error.message),
{
id: 'cont_upd_error'
});
}
this.set('isLoading', false);
export default class extends Controller {
@action
async updateContactInfo() {
this.set('isLoading', true);
try {
await this.model.save();
this.notify.success(this.l10n.t('Your Contact Info has been updated'),
{
id: 'cont_info_upd'
});
} catch (error) {
this.notify.error(this.l10n.t(error.message),
{
id: 'cont_upd_error'
});
}
this.set('isLoading', false);
}
});
}
137 changes: 70 additions & 67 deletions app/controllers/admin/content/events.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,79 @@
import Controller from '@ember/controller';
import { camelCase, startCase } from 'lodash-es';
import { action } from '@ember/object';

export default Controller.extend({
export default class extends Controller {

disableEventSubtopic : true,
currentTopicSelected : null,
disableEventSubtopic = true;
currentTopicSelected = null;

actions: {
async loadSubTopics(topic) {
this.set('isLoading', true);
try {
this.set('model.eventSubTopics', await topic.get('subTopics').toArray());
this.set('disableEventSubtopic', false);
this.set('currentTopicSelected', topic);
} catch (e) {
this.notify.error(this.l10n.t('An unexpected error has occurred. SubTopics not loaded.'),
@action
async loadSubTopics(topic) {
this.set('isLoading', true);
try {
this.set('model.eventSubTopics', await topic.subTopics.toArray());
this.set('disableEventSubtopic', false);
this.set('currentTopicSelected', topic);
} catch (e) {
this.notify.error(this.l10n.t('An unexpected error has occurred. SubTopics not loaded.'),
{
id: 'subtop_error'
});
} finally {
this.set('isLoading', false);
}
}
@action
openModalFor(modelInstanceOrName) {
const modelName = typeof modelInstanceOrName === 'string' ? modelInstanceOrName : modelInstanceOrName.constructor.modelName;
const modelInstance = typeof modelInstanceOrName === 'string' ? this.store.createRecord(modelInstanceOrName) : modelInstanceOrName;
const camelCasedValue = camelCase(modelName);
this.set(camelCasedValue, modelInstance);
modelInstance.openModal = true;
}
@action
deleteEventProperty(eventProp) {
this.set('isLoading', true);
const modelName = camelCase(eventProp.constructor.modelName);
eventProp.destroyRecord()
.then(() => {
this.get(`model.${modelName}s`).removeObject(eventProp);
this.notify.success(this.l10n.t('This Event Property has been deleted successfully.'),
{
id: 'subtop_error'
id: 'event_prop_del'
});
} finally {
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Event Type was not deleted.'),
{
id: 'event_type_error'
});
})
.finally(() => {
this.set('isLoading', false);
}
},
openModalFor(modelInstanceOrName) {
const modelName = typeof modelInstanceOrName === 'string' ? modelInstanceOrName : modelInstanceOrName.constructor.modelName;
const modelInstance = typeof modelInstanceOrName === 'string' ? this.store.createRecord(modelInstanceOrName) : modelInstanceOrName;
const camelCasedValue = camelCase(modelName);
this.set(camelCasedValue, modelInstance);
modelInstance.openModal = true;
},
deleteEventProperty(eventProp) {
this.set('isLoading', true);
const modelName = camelCase(eventProp.constructor.modelName);
eventProp.destroyRecord()
.then(() => {
this.get(`model.${modelName}s`).removeObject(eventProp);
this.notify.success(this.l10n.t('This Event Property has been deleted successfully.'),
{
id: 'event_prop_del'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Event Type was not deleted.'),
{
id: 'event_type_error'
});
})
.finally(() => {
this.set('isLoading', false);
});
},
addEventProperty(modelInstance) {
const camelCasedValue = camelCase(modelInstance.constructor.modelName);
this.set('isLoading', true);
modelInstance.save()
.then(() => {
this.get(`model.${camelCasedValue}s`).addObject(modelInstance);
this.notify.success(this.l10n.t(`${startCase(camelCasedValue)} has been added successfully.`),
{
id: 'mode_add_succ'
});
})
.catch(() => {
this.notify.error(this.l10n.t(`An unexpected error has occurred. ${startCase(camelCasedValue)} not saved.`),
{
id: 'mode_err_succ'
});
})
.finally(() => {
this.set('isLoading', false);
this.set(camelCasedValue, null);
});
}
});
}
@action
addEventProperty(modelInstance) {
const camelCasedValue = camelCase(modelInstance.constructor.modelName);
this.set('isLoading', true);
modelInstance.save()
.then(() => {
this.get(`model.${camelCasedValue}s`).addObject(modelInstance);
this.notify.success(this.l10n.t(`${startCase(camelCasedValue)} has been added successfully.`),
{
id: 'mode_add_succ'
});
})
.catch(() => {
this.notify.error(this.l10n.t(`An unexpected error has occurred. ${startCase(camelCasedValue)} not saved.`),
{
id: 'mode_err_succ'
});
})
.finally(() => {
this.set('isLoading', false);
this.set(camelCasedValue, null);
});
}
});
}
46 changes: 23 additions & 23 deletions app/controllers/admin/content/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';

export default Controller.extend({
actions: {
saveSocials() {
this.set('isLoading', true);
let settings = this.model;
settings.save()
.then(() => {
this.notify.success(this.l10n.t('Social links have been saved successfully.'),
{
id: 'social_link_upd'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Social links not saved.'),
{
id: 'unex_social_error'
});
})
.finally(() => {
this.set('isLoading', false);
});
}
export default class extends Controller {
@action
saveSocials() {
this.set('isLoading', true);
let settings = this.model;
settings.save()
.then(() => {
this.notify.success(this.l10n.t('Social links have been saved successfully.'),
{
id: 'social_link_upd'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Social links not saved.'),
{
id: 'unex_social_error'
});
})
.finally(() => {
this.set('isLoading', false);
});
}
});
}
66 changes: 34 additions & 32 deletions app/controllers/admin/content/pages.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
import { filterBy } from '@ember/object/computed';
import Controller from '@ember/controller';
import { action } from '@ember/object';

export default Controller.extend({
footerPages: filterBy('model', 'place', 'footer'),
export default class extends Controller {

eventPages: filterBy('model', 'place', 'event'),
footerPages = filterBy('model', 'place', 'footer');

actions: {
updateCurrentPage(page, type) {
if (type === 'create') {
this.set('isCreate', true);
this.set('currentForm', this.store.createRecord('page'));
} else {
this.set('isCreate', false);
this.set('currentForm', page);
}
this.set('isFormOpen', true);
},
savePage(page) {
page.save()
.then(() => {
if (this.isCreate) {
this.set('isFormOpen', false);
}
this.notify.success(this.l10n.t('Page details have been saved successfully.'),
{
id: 'page_detail_succ'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Page Details not saved.'),
{
id: 'page_detail_del'
});
});
eventPages = filterBy('model', 'place', 'event');

@action
updateCurrentPage(page, type) {
if (type === 'create') {
this.set('isCreate', true);
this.set('currentForm', this.store.createRecord('page'));
} else {
this.set('isCreate', false);
this.set('currentForm', page);
}
this.set('isFormOpen', true);
}
@action
savePage(page) {
page.save()
.then(() => {
if (this.isCreate) {
this.set('isFormOpen', false);
}
this.notify.success(this.l10n.t('Page details have been saved successfully.'),
{
id: 'page_detail_succ'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Page Details not saved.'),
{
id: 'page_detail_del'
});
});
}
});
}
Loading