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

74 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-12-19 10:05:07 +00:00
import ngModule from '../module';
2020-03-17 13:43:46 +00:00
import Section from 'salix/components/section';
2018-02-22 07:18:57 +00:00
import './style.scss';
2017-12-19 10:05:07 +00:00
2020-03-17 13:43:46 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
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-02-19 09:15:39 +00:00
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) {
2020-03-17 13:43:46 +00:00
if (event.defaltPrevented) return;
event.preventDefault();
event.stopPropagation();
this.selectedWorker = workerFk;
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;
this.$.clone.show();
2018-02-22 12:40:23 +00:00
}
2018-02-22 12:40:23 +00:00
onCloneAccept(response) {
2019-10-30 15:57:14 +00:00
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});
});
2018-02-22 12:40:23 +00:00
this.itemSelected = null;
}
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;
this.$.preview.show();
2018-02-22 07:18:57 +00:00
}
2017-12-19 10:05:07 +00:00
}
2020-03-17 13:43:46 +00:00
Controller.$inject = ['$element', '$scope'];
ngModule.component('vnItemIndex', {
template: require('./index.html'),
controller: Controller
2017-12-19 10:05:07 +00:00
});