salix/client/item/src/index/index.js

52 lines
1.2 KiB
JavaScript

import ngModule from '../module';
import './product';
import './style.scss';
class Controller {
constructor($http, $state, $scope) {
this.$http = $http;
this.$state = $state;
this.$scope = $scope;
this.model = {};
this.itemSelected = null;
this.items = [];
}
search(index) {
index.accept();
/* this.items = [];
index.accept().then(res => {
this.items = res.instances;
}); */
}
cloneItem(item) {
this.itemSelected = item;
this.$scope.clone.show();
}
onCloneAccept(response) {
if (response == 'ACCEPT' && this.itemSelected) {
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.$scope.preview.show();
}
}
Controller.$inject = ['$http', '$state', '$scope'];
ngModule.component('vnItemIndex', {
template: require('./index.html'),
controller: Controller
});