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.filter = { include: [ {relation: 'itemType', scope: { fields: ['name', 'workerFk'], include: { relation: 'worker', fields: ['firstName', 'name'] } } } ], order: 'name ASC' }; } 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}; } } 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 });