2020-10-14 09:33:42 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import Component from 'core/lib/component';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
|
|
|
open($event) {
|
|
|
|
if ($event.defaultPrevented) return;
|
|
|
|
|
|
|
|
this.$.provinceDialog.show();
|
|
|
|
$event.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccept() {
|
|
|
|
try {
|
|
|
|
if (!this.province.name)
|
|
|
|
throw new Error(`The province name can't be empty`);
|
2021-09-02 09:56:59 +00:00
|
|
|
if (!this.province.autonomyFk)
|
|
|
|
throw new Error(`The autonomy can't be empty`);
|
2020-10-14 09:33:42 +00:00
|
|
|
|
|
|
|
this.$http.patch(`provinces`, this.province).then(res => {
|
|
|
|
this.vnApp.showMessage(this.$t('The province has been created'));
|
|
|
|
this.emit('response', {$response: res.data});
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
this.vnApp.showError(this.$t(e.message));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnGeoProvince', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
data: '<',
|
|
|
|
}
|
|
|
|
});
|