import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ topicSubscribed : service(), topicSubscribedData : service(), userInfoData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, users: Array(), formConfig : { user : { isEditable : true }, topicName : { isEditable : true }, isSubscribed : { isEditable : true }, }, init() { this._super(...arguments); var users = this.userInfoData.getList(); this.set("users", users); }, actions: { onChangeCombo(propertyName, item) { this.set(propertyName, item); }, async saveTopicSubscribed() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('topicSubscribed.model.isApprovalData', false); this.topicSubscribedData.save(this.topicSubscribed.model).then(response => { if (response != undefined) { this.transitionToRoute('topic-subscribed.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, }, });