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; this.imagesPath = '//verdnatura.es/vn-image-data/catalog'; this.showFields = { id: false, actions: false }; } 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}; } } 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(); } paramBuilder(param, value) { switch (param) { case 'tags': return {[param]: value}; } } cloneItem(event, item) { event.preventDefault(); event.stopImmediatePropagation(); 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; } preview(event, item) { event.preventDefault(); event.stopImmediatePropagation(); this.itemSelected = item; this.$.preview.show(); } } Controller.$inject = ['$http', '$state', '$scope']; ngModule.component('vnItemIndex', { template: require('./index.html'), controller: Controller });