salix/client/item/src/index/index.js

74 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-12-19 10:05:07 +00:00
import ngModule from '../module';
2018-04-04 17:59:03 +00:00
import './product';
2018-02-22 07:18:57 +00:00
import './style.scss';
2017-12-19 10:05:07 +00:00
class Controller {
2018-02-22 12:40:23 +00:00
constructor($http, $state, $scope) {
this.$http = $http;
this.$state = $state;
this.$ = $scope;
2018-02-22 07:18:57 +00:00
this.itemSelected = null;
this.filter = {
include: [
{relation: 'itemType',
scope: {
fields: ['name', 'workerFk'],
include: {
relation: 'worker',
fields: ['firstName', 'name']
}
}
}
],
order: 'name ASC'
};
2017-12-19 10:05:07 +00:00
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return {
or: [
{id: value},
{name: {regexp: value}}
]
};
case 'name':
case 'description':
return {[param]: {regexp: value}};
case 'id':
case 'typeFk':
return {[param]: value};
}
2017-12-19 10:05:07 +00:00
}
2018-02-22 12:40:23 +00:00
cloneItem(item) {
this.itemSelected = item;
this.$.clone.show();
2018-02-22 12:40:23 +00:00
}
2018-02-22 12:40:23 +00:00
onCloneAccept(response) {
if (!(response == 'ACCEPT' && this.itemSelected))
return;
this.$http.post(`/item/api/Items/${this.itemSelected.id}/clone`).then(res => {
if (res && res.data && res.data.id)
this.$state.go('item.card.tags', {id: res.data.id});
});
2018-02-22 12:40:23 +00:00
this.itemSelected = null;
}
2018-02-22 07:18:57 +00:00
showItemPreview(item) {
this.itemSelected = item;
this.$.preview.show();
2018-02-22 07:18:57 +00:00
}
2017-12-19 10:05:07 +00:00
}
Controller.$inject = ['$http', '$state', '$scope'];
ngModule.component('vnItemIndex', {
template: require('./index.html'),
controller: Controller
2017-12-19 10:05:07 +00:00
});