Tarea #37 ItemBotanical
This commit is contained in:
parent
feabfc05d6
commit
a3985e70ed
|
@ -1,5 +1,41 @@
|
|||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Botanical</vn-title>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<mg-ajax
|
||||
path="/item/api/ItemBotanicals/{{patch.params.id}}"
|
||||
options="vnPatch">
|
||||
</mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.botanical"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" ng-cloak>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Botanical</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Botanical" model="$ctrl.botanical.botanical"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
initial-data="$ctrl.botanical.genus"
|
||||
field="$ctrl.botanical.genusFk"
|
||||
url="/item/api/genera"
|
||||
show-field="latin_genus_name"
|
||||
value-field="genus_id"
|
||||
label="Genus">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
initial-data="$ctrl.botanical.specie"
|
||||
field="$ctrl.botanical.specieFk"
|
||||
url="/item/api/species"
|
||||
show-field="latin_species_name"
|
||||
value-field="specie_id"
|
||||
label="Specie">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,5 +1,30 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class ItemBotanical {
|
||||
constructor($http, $state) {
|
||||
this.$http = $http;
|
||||
this.botanical = {
|
||||
itemFk: $state.params.id
|
||||
};
|
||||
}
|
||||
$onInit() {
|
||||
let filter = {
|
||||
where: {
|
||||
itemFk: this.botanical.itemFk
|
||||
},
|
||||
include: [{relation: 'genus'}, {relation: 'specie'}]
|
||||
};
|
||||
this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`)
|
||||
.then(res => {
|
||||
if (res.data) {
|
||||
Object.assign(this.botanical, res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
ItemBotanical.$inject = ['$http', '$state'];
|
||||
|
||||
ngModule.component('vnItemBotanical', {
|
||||
template: require('./item-botanical.html')
|
||||
template: require('./item-botanical.html'),
|
||||
controller: ItemBotanical
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue