salix/modules/supplier/front/bankentity/index.js

41 lines
1.0 KiB
JavaScript

import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
open() {
this.$.bankEntityDialog.show();
}
resetLocation() {
this.location = {};
}
onCountryResponse(response) {
this.location.countryFk = response.id;
}
onAccept() {
try {
if (!this.location.countryFk)
throw new Error(`The country can't be empty`);
this.$http.post(`Bankentities`, this.location).then(() => {
this.vnApp.showMessage(this.$t('The bank entity has been created. You can save the data now'));
this.emit('response', {$response: this.location});
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
return false;
}
return true;
}
}
ngModule.vnComponent('vnNewBankEntity', {
template: require('./index.html'),
controller: Controller,
bindings: {
data: '<',
}
});