salix/modules/item/front/index/index.js

74 lines
1.8 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.itemSelected = null;
this.imagesPath = '//verdnatura.es/vn-image-data/catalog';
this.showFields = {
id: false,
actions: false
};
}
stopEvent(event) {
event.preventDefault();
event.stopImmediatePropagation();
}
showItemDescriptor(event, itemFk) {
if (event.defaultPrevented) return;
event.preventDefault();
event.stopPropagation();
this.$.itemDescriptor.itemFk = itemFk;
this.$.itemDescriptor.parent = event.target;
this.$.itemDescriptor.show();
}
showWorkerDescriptor(event, workerFk) {
if (event.defaltPrevented) return;
event.preventDefault();
event.stopPropagation();
this.selectedWorker = workerFk;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
cloneItem(event, item) {
this.stopEvent(event);
this.itemSelected = item;
this.$.clone.show();
}
onCloneAccept(response) {
if (!(response == 'accept' && this.itemSelected))
return;
this.$http.post(`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) {
this.stopEvent(event);
this.itemSelected = item;
this.$.preview.show();
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.component('vnItemIndex', {
template: require('./index.html'),
controller: Controller
});