import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ resetPassword: service(), resetPasswordData: service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, formConfig : { newPassword : { isEditable : true }, confirmnewPassword : { isEditable : true } }, actions: { async resetPassword() { //var management = this.accountManagement.model; // if(management == null || management == undefined){ // alert("kosong"); // } this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { //this.set('accountManagement.model.isApprovalData', false); //var current = this.accountAddress.model; //current.accountManagement= management; this.resetPasswordData.save(this.resetPassword.model).then(response => { if (response != undefined) { //console.log(response.newPassword); alert("Success"); this.transitionToRoute('login'); this.set('rightActionInProgress',false); //this.transitionToRoute('account-management.detail', this.accountManagement.model.id); } }) .catch((e) => { console.log(e); //this.set("rightActionInProgress", false); this.set('rightActionInProgress',false); this.set('errorMessage', e.errors[0].title); }); } else { this.set("rightActionInProgress", false); } }); }, } });