63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
import ngModule from '../module';
|
|
import './product';
|
|
import './style.scss';
|
|
|
|
class Controller {
|
|
constructor($http, $state, $scope) {
|
|
this.$http = $http;
|
|
this.$state = $state;
|
|
this.$ = $scope;
|
|
this.itemSelected = null;
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'search':
|
|
return /^\d+$/.test(value)
|
|
? {id: value}
|
|
: {name: {like: `%${value}%`}};
|
|
case 'name':
|
|
case 'description':
|
|
return {[param]: {like: `%${value}%`}};
|
|
case 'id':
|
|
case 'typeFk':
|
|
return {[param]: value};
|
|
}
|
|
}
|
|
|
|
paramBuilder(param, value) {
|
|
switch (param) {
|
|
case 'tags':
|
|
return {[param]: value};
|
|
}
|
|
}
|
|
|
|
cloneItem(item) {
|
|
this.itemSelected = item;
|
|
this.$.clone.show();
|
|
}
|
|
|
|
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});
|
|
});
|
|
|
|
this.itemSelected = null;
|
|
}
|
|
|
|
showItemPreview(item) {
|
|
this.itemSelected = item;
|
|
this.$.preview.show();
|
|
}
|
|
}
|
|
Controller.$inject = ['$http', '$state', '$scope'];
|
|
|
|
ngModule.component('vnItemIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|