2018-01-18 07:38:04 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
2021-03-04 06:56:31 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
showGenus(event) {
|
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
event.preventDefault();
|
2018-01-18 07:38:04 +00:00
|
|
|
|
2021-03-04 06:56:31 +00:00
|
|
|
this.$.genus.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
showSpecies(event) {
|
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
this.$.species.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
onGenusAccept() {
|
|
|
|
try {
|
|
|
|
if (!this.data.name)
|
|
|
|
throw new Error(`The name of the genus can't be empty`);
|
|
|
|
console.log(this.data);
|
|
|
|
this.$http.post(`genera`, this.data).then(res => {
|
|
|
|
this.vnApp.showMessage(this.$t('The genus has been created. You can save the data now'));
|
|
|
|
this.emit('response', {$response: res.data});
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
this.vnApp.showError(this.$t(e.message));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSpeciesAccept() {
|
|
|
|
try {
|
|
|
|
if (!this.data.name)
|
|
|
|
throw new Error(`The name of the specie can't be empty`);
|
|
|
|
console.log(this.data);
|
|
|
|
this.$http.post(`species`, this.data).then(res => {
|
|
|
|
this.vnApp.showMessage(this.$t('The specie has been created.'));
|
|
|
|
this.emit('response', {$response: res.data});
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
this.vnApp.showError(this.$t(e.message));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnItemBotanical', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
2018-01-18 07:38:04 +00:00
|
|
|
});
|