salix/modules/client/front/credit/create/index.js

44 lines
943 B
JavaScript
Raw Normal View History

2018-05-23 12:26:51 +00:00
import ngModule from '../../module';
2020-03-17 10:17:50 +00:00
import Section from 'salix/components/section';
2017-12-04 07:17:29 +00:00
2020-03-17 10:17:50 +00:00
class Controller extends Section {
onSubmit() {
2020-03-17 10:17:50 +00:00
this.$http.get(`Recoveries/${this.$params.id}/hasActiveRecovery`).then(res => {
let activeRecovery = res.data;
if (activeRecovery)
2020-03-17 10:17:50 +00:00
this.$.confirmation.show();
else
this.addCredit();
});
}
cancel() {
2018-07-25 11:37:27 +00:00
this.goToIndex();
}
returnDialog(response) {
2019-10-30 15:57:14 +00:00
if (response === 'accept')
this.addCredit();
}
2018-07-25 11:37:27 +00:00
goToIndex() {
this.$state.go('client.card.credit.index');
}
addCredit() {
2020-03-17 10:17:50 +00:00
this.$.watcher.submit().then(
() => {
2018-07-25 11:37:27 +00:00
this.goToIndex();
}
);
}
}
2017-12-04 07:17:29 +00:00
ngModule.component('vnClientCreditCreate', {
2018-05-23 12:26:51 +00:00
template: require('./index.html'),
controller: Controller,
2017-12-04 07:17:29 +00:00
bindings: {
client: '<'
}
});