diff --git a/client/item/src/niche/item-niche.html b/client/item/src/niche/item-niche.html
index 88206a4a4..f282644e9 100644
--- a/client/item/src/niche/item-niche.html
+++ b/client/item/src/niche/item-niche.html
@@ -1,49 +1,55 @@
+
+
+
\ No newline at end of file
diff --git a/client/item/src/niche/item-niche.js b/client/item/src/niche/item-niche.js
index a6d25be5e..e762bcf90 100644
--- a/client/item/src/niche/item-niche.js
+++ b/client/item/src/niche/item-niche.js
@@ -1,8 +1,8 @@
import ngModule from '../module';
export default class Controller {
- constructor($state, $scope, $http, $translate, vnApp) {
- this.$state = $state;
+ constructor($stateParams, $scope, $http, $translate, vnApp) {
+ this.params = $stateParams;
this.$scope = $scope;
this.$http = $http;
this.$translate = $translate;
@@ -38,7 +38,7 @@ export default class Controller {
}
addNiche() {
- this.niches.push({code: null, itemFk: this.$state.params.id, showAddIcon: true});
+ this.niches.push({code: null, itemFk: this.params.id, showAddIcon: true});
this._setIconAdd();
}
@@ -58,6 +58,34 @@ export default class Controller {
return oldNiche.id === newNiche.id && oldNiche.code === newNiche.code && oldNiche.warehouseFk === newNiche.warehouseFk;
}
+ setOldNiches(response) {
+ this._setIconAdd();
+ response.data.forEach(niche => {
+ this.oldNiches[niche.id] = Object.assign({}, niche);
+ });
+ }
+
+ getNiches() {
+ let filter = {
+ where: {itemFk: this.params.id},
+ include: {relation: 'warehouse'}
+ };
+ this.$http.get(`/item/api/ItemNiches?filter=${JSON.stringify(filter)}`).then(response => {
+ this.niches = response.data;
+ this.setOldNiches(response);
+ });
+ }
+
+ getWarehouse(id, warehouses) {
+ return warehouses.find(warehouse => warehouse.id === id);
+ }
+
+ getWarehouses() {
+ this.$http.get(`/item/api/Warehouses`).then(response => {
+ this.warehouses = response.data;
+ });
+ }
+
submit() {
let warehousesDefined = [];
let repeatedWarehouse = false;
@@ -92,6 +120,7 @@ export default class Controller {
if (repeatedWarehouse) {
return this.vnApp.showMessage(this.$translate.instant('The niche must be unique'));
}
+
canSubmit = nichesObj.update.length > 0 || nichesObj.create.length > 0 || nichesObj.delete.length > 0;
if (canSubmit) {
@@ -103,41 +132,13 @@ export default class Controller {
this.vnApp.showMessage(this.$translate.instant('No changes to save'));
}
- setOldNiches(response) {
- this._setIconAdd();
- response.data.forEach(niche => {
- this.oldNiches[niche.id] = Object.assign({}, niche);
- });
- }
-
- getWarehouse(id, warehouses) {
- return warehouses.find(warehouse => warehouse.id === id);
- }
-
- getNiches() {
- let filter = {
- where: {itemFk: this.$state.params.id},
- include: {relation: 'warehouse'}
- };
- this.$http.get(`/item/api/ItemNiches?filter=${JSON.stringify(filter)}`).then(response => {
- this.niches = response.data;
- this.setOldNiches(response);
- });
- }
-
- getWarehouses() {
- this.$http.get(`/item/api/Warehouses`).then(response => {
- this.warehouses = response.data;
- });
- }
-
$onInit() {
this.getNiches();
this.getWarehouses();
}
}
-Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
+Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];
ngModule.component('vnItemNiche', {
template: require('./item-niche.html'),
diff --git a/client/item/src/tags/item-tags.html b/client/item/src/tags/item-tags.html
index 17369ca48..80ee4cbd1 100644
--- a/client/item/src/tags/item-tags.html
+++ b/client/item/src/tags/item-tags.html
@@ -1,40 +1,50 @@