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

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-05-23 12:26:51 +00:00
import ngModule from '../../module';
2017-12-04 07:17:29 +00:00
class Controller {
constructor($http, $scope, $state) {
this.$http = $http;
this.$scope = $scope;
this.$state = $state;
}
onSubmit() {
this.$http.get(`/client/api/Recoveries/${this.$state.params.id}/hasActiveRecovery`).then(res => {
let activeRecovery = res.data;
if (activeRecovery)
this.$scope.confirmation.show();
else
this.addCredit();
});
}
cancel() {
2018-07-25 11:37:27 +00:00
this.goToIndex();
}
returnDialog(response) {
if (response === 'ACCEPT')
this.addCredit();
}
2018-07-25 11:37:27 +00:00
goToIndex() {
this.$state.go('client.card.credit.index');
}
addCredit() {
this.$scope.watcher.submit().then(
() => {
2018-07-25 11:37:27 +00:00
this.goToIndex();
}
);
}
}
Controller.$inject = ['$http', '$scope', '$state'];
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: '<'
}
});