salix/modules/item/front/create/index.js

41 lines
1.2 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.fetchDefaultPriorityTag();
}
fetchDefaultPriorityTag() {
this.validPriorities = [];
const filter = {fields: ['defaultPriority', 'defaultTag', 'validPriorities'], limit: 1};
this.$http.get(`ItemConfigs`, {filter})
.then(res => {
if (res.data) {
const dataRow = res.data[0];
dataRow.validPriorities.forEach(priority => {
this.validPriorities.push({priority});
});
this.item = {
priority: dataRow.defaultPriority,
tag: dataRow.defaultTag
};
}
});
}
onSubmit() {
this.$.watcher.submit().then(
json => this.$state.go('item.card.basicData', {id: json.data.id})
);
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnItemCreate', {
template: require('./index.html'),
controller: Controller
});