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
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
class Controller {
|
2018-02-22 12:40:23 +00:00
|
|
|
constructor($http, $state, $scope) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.$state = $state;
|
2018-06-07 21:47:19 +00:00
|
|
|
this.$ = $scope;
|
2018-02-22 07:18:57 +00:00
|
|
|
this.itemSelected = null;
|
2019-02-13 08:27:11 +00:00
|
|
|
this.imagesPath = '//verdnatura.es/vn-image-data/catalog';
|
|
|
|
|
|
|
|
this.showFields = {
|
|
|
|
id: false,
|
|
|
|
actions: false
|
|
|
|
};
|
2017-12-19 10:05:07 +00:00
|
|
|
}
|
2018-05-04 09:46:03 +00:00
|
|
|
|
2018-06-07 21:47:19 +00:00
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
|
|
|
case 'search':
|
2018-07-03 15:41:41 +00:00
|
|
|
return /^\d+$/.test(value)
|
|
|
|
? {id: value}
|
2018-07-09 16:06:25 +00:00
|
|
|
: {name: {like: `%${value}%`}};
|
2018-06-07 21:47:19 +00:00
|
|
|
case 'name':
|
|
|
|
case 'description':
|
2018-07-09 16:06:25 +00:00
|
|
|
return {[param]: {like: `%${value}%`}};
|
2018-06-07 21:47:19 +00:00
|
|
|
case 'id':
|
|
|
|
case 'typeFk':
|
|
|
|
return {[param]: value};
|
2018-09-05 11:01:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 08:27:11 +00:00
|
|
|
showDescriptor(event, itemFk) {
|
|
|
|
this.quicklinks = {
|
|
|
|
btnThree: {
|
|
|
|
icon: 'icon-transaction',
|
|
|
|
state: `item.card.diary({
|
|
|
|
id: ${itemFk},
|
|
|
|
warehouseFk: ${this.ticket.warehouseFk},
|
|
|
|
ticketFk: ${this.ticket.id}
|
|
|
|
})`,
|
|
|
|
tooltip: 'Item diary'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.$scope.descriptor.itemFk = itemFk;
|
|
|
|
this.$scope.descriptor.parent = event.target;
|
|
|
|
this.$scope.descriptor.show();
|
|
|
|
}
|
|
|
|
|
2018-09-05 11:01:21 +00:00
|
|
|
paramBuilder(param, value) {
|
|
|
|
switch (param) {
|
2018-07-06 14:32:23 +00:00
|
|
|
case 'tags':
|
2018-09-05 11:01:21 +00:00
|
|
|
return {[param]: value};
|
2018-06-07 21:47:19 +00:00
|
|
|
}
|
2017-12-19 10:05:07 +00:00
|
|
|
}
|
2018-05-04 09:46:03 +00:00
|
|
|
|
2019-02-13 08:27:11 +00:00
|
|
|
cloneItem(event, item) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
2018-02-22 12:40:23 +00:00
|
|
|
this.itemSelected = item;
|
2018-06-07 21:47:19 +00:00
|
|
|
this.$.clone.show();
|
2018-02-22 12:40:23 +00:00
|
|
|
}
|
2018-05-04 09:46:03 +00:00
|
|
|
|
2018-02-22 12:40:23 +00:00
|
|
|
onCloneAccept(response) {
|
2018-06-07 21:47:19 +00:00
|
|
|
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-06-07 21:47:19 +00:00
|
|
|
|
2019-02-13 08:27:11 +00:00
|
|
|
preview(event, item) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
2018-02-22 07:18:57 +00:00
|
|
|
this.itemSelected = item;
|
2018-06-07 21:47:19 +00:00
|
|
|
this.$.preview.show();
|
2018-02-22 07:18:57 +00:00
|
|
|
}
|
2017-12-19 10:05:07 +00:00
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
Controller.$inject = ['$http', '$state', '$scope'];
|
|
|
|
|
|
|
|
ngModule.component('vnItemIndex', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
2017-12-19 10:05:07 +00:00
|
|
|
});
|