2017-12-19 10:05:07 +00:00
|
|
|
import ngModule from '../module';
|
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 {
|
2019-04-05 13:20:12 +00:00
|
|
|
constructor($http, $state, $scope, aclService) {
|
|
|
|
this.aclService = aclService;
|
2018-02-22 12:40:23 +00:00
|
|
|
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
|
|
|
|
};
|
2019-04-05 13:20:12 +00:00
|
|
|
this.moreOptions = [
|
2019-05-02 08:04:02 +00:00
|
|
|
{callback: this.goToTicketRequest, name: 'Buy requests', acl: 'buyer'}
|
2019-04-05 13:20:12 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoreOpen() {
|
|
|
|
let options = this.moreOptions.filter(o => this.aclService.hasAny([o.acl]));
|
|
|
|
this.$.moreButton.data = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
goToTicketRequest() {
|
|
|
|
this.$state.go('item.request');
|
2019-02-28 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
2019-02-19 09:15:39 +00:00
|
|
|
stopEvent(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSearch(params) {
|
2019-03-08 12:12:13 +00:00
|
|
|
if (params && params.hasVisible === undefined && params.isActive === undefined)
|
|
|
|
Object.assign(params, {hasVisible: true, isActive: true});
|
|
|
|
|
2019-02-19 09:15:39 +00:00
|
|
|
if (params)
|
|
|
|
this.$.model.applyFilter(null, params);
|
|
|
|
else
|
|
|
|
this.$.model.clear();
|
2018-09-05 11:01:21 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 11:39:21 +00:00
|
|
|
showItemDescriptor(event, itemFk) {
|
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
this.$.itemDescriptor.itemFk = itemFk;
|
|
|
|
this.$.itemDescriptor.parent = event.target;
|
|
|
|
this.$.itemDescriptor.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-25 12:24:02 +00:00
|
|
|
showWorkerDescriptor(event, workerFk) {
|
2019-02-15 11:39:21 +00:00
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
2019-04-25 12:24:02 +00:00
|
|
|
this.selectedWorker = workerFk;
|
2019-02-15 11:39:21 +00:00
|
|
|
this.$.workerDescriptor.parent = event.target;
|
|
|
|
this.$.workerDescriptor.show();
|
2019-02-13 08:27:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cloneItem(event, item) {
|
2019-02-19 09:15:39 +00:00
|
|
|
this.stopEvent(event);
|
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) {
|
2019-02-19 09:15:39 +00:00
|
|
|
this.stopEvent(event);
|
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
|
|
|
}
|
2019-04-05 13:20:12 +00:00
|
|
|
Controller.$inject = ['$http', '$state', '$scope', 'aclService'];
|
2018-05-25 08:03:45 +00:00
|
|
|
|
|
|
|
ngModule.component('vnItemIndex', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
2017-12-19 10:05:07 +00:00
|
|
|
});
|