2017-12-20 11:40:29 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
2017-12-20 11:40:29 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2023-01-18 12:14:49 +00:00
|
|
|
this.fetchDefaultPriorityTag();
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchDefaultPriorityTag() {
|
2023-01-20 11:01:13 +00:00
|
|
|
this.validPriorities = [];
|
|
|
|
const filter = {fields: ['defaultPriority', 'defaultTag', 'validPriorities'], limit: 1};
|
2023-01-18 12:14:49 +00:00
|
|
|
this.$http.get(`ItemConfigs`, {filter})
|
|
|
|
.then(res => {
|
|
|
|
if (res.data) {
|
2023-01-20 11:01:13 +00:00
|
|
|
const dataRow = res.data[0];
|
|
|
|
dataRow.validPriorities.forEach(priority => {
|
|
|
|
this.validPriorities.push({priority});
|
|
|
|
});
|
2023-01-18 12:14:49 +00:00
|
|
|
this.item = {
|
2023-01-20 11:01:13 +00:00
|
|
|
priority: dataRow.defaultPriority,
|
|
|
|
tag: dataRow.defaultTag
|
2023-01-18 12:14:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2017-12-20 11:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit() {
|
|
|
|
this.$.watcher.submit().then(
|
2019-04-16 12:30:01 +00:00
|
|
|
json => this.$state.go('item.card.basicData', {id: json.data.id})
|
2017-12-20 11:40:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
Controller.$inject = ['$element', '$scope'];
|
2017-12-20 11:40:29 +00:00
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnItemCreate', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
2017-12-20 11:40:29 +00:00
|
|
|
});
|