From ddbe1057ad9996e42100e156c188faafd40f1a3f Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 09:47:53 +0200 Subject: [PATCH] feat: add new section --- .../10490-august/00-aclItemShelving.sql | 3 + ...00-aclItemShelvingPlacementSupply copy.sql | 3 + .../item-shelving-placement-supply.json | 9 +- modules/item/front/item-shelving/index.html | 132 +++++------------- modules/item/front/item-shelving/index.js | 106 ++++++-------- .../item/front/item-shelving/locale/es.yml | 12 +- 6 files changed, 95 insertions(+), 170 deletions(-) create mode 100644 db/changes/10490-august/00-aclItemShelving.sql create mode 100644 db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql diff --git a/db/changes/10490-august/00-aclItemShelving.sql b/db/changes/10490-august/00-aclItemShelving.sql new file mode 100644 index 0000000000..3995bbe497 --- /dev/null +++ b/db/changes/10490-august/00-aclItemShelving.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ItemShelving', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql b/db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql new file mode 100644 index 0000000000..cc589a58f4 --- /dev/null +++ b/db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ItemShelvingPlacementSupplyStock', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/item/back/models/item-shelving-placement-supply.json b/modules/item/back/models/item-shelving-placement-supply.json index 11497b4fc9..a54013e05b 100644 --- a/modules/item/back/models/item-shelving-placement-supply.json +++ b/modules/item/back/models/item-shelving-placement-supply.json @@ -7,13 +7,17 @@ } }, "properties": { + "itemShelvingFk": { + "type": "number", + "id": true + }, "created": { "type": "date" }, "itemFk": { "type": "number" }, - "concept": { + "longName": { "type": "string" }, "parking": { @@ -24,6 +28,9 @@ }, "packing": { "type": "number" + }, + "stock": { + "type": "number" } } } \ No newline at end of file diff --git a/modules/item/front/item-shelving/index.html b/modules/item/front/item-shelving/index.html index 7949e73a3c..115829c8d4 100644 --- a/modules/item/front/item-shelving/index.html +++ b/modules/item/front/item-shelving/index.html @@ -1,21 +1,10 @@ - - - - + ng-click="removeConfirm.show()" + vn-tooltip="Remove selected lines" + vn-acl="replenisherBos" + icon="delete"> @@ -50,123 +39,78 @@ model="model"> - + Created - + Item + field="longName"> Concept + field="parking"> Parking - + Shelving + field="label"> Etiqueta Packing - + - + {{::itemShelvingPlacementSupplyStock.created | date: 'dd/MM/yyyy'}} + + {{::itemShelvingPlacementSupplyStock.itemFk}} + + - {{::defaulter.clientName}} + {{itemShelvingPlacementSupplyStock.longName}} - - {{::defaulter.salesPersonName | dashIfEmpty}} - + {{::itemShelvingPlacementSupplyStock.parking}} - {{::defaulter.amount | currency: 'EUR': 2}} - - {{::defaulter.workerName | dashIfEmpty}} - + {{::itemShelvingPlacementSupplyStock.shelving}} - - - + + {{::itemShelvingPlacementSupplyStock.label}} - - - {{::defaulter.created | date: 'dd/MM/yyyy'}} - + + {{::itemShelvingPlacementSupplyStock.packing}} - {{::defaulter.creditInsurance | currency: 'EUR': 2}} - {{::defaulter.defaulterSinced | date: 'dd/MM/yyyy'}} - - - - - - - - + + - - - -
-
{{$ctrl.$t('Add observation to all selected clients', {total: $ctrl.checked.length})}}
- - - - -
-
- - - - -
+ + \ No newline at end of file diff --git a/modules/item/front/item-shelving/index.js b/modules/item/front/item-shelving/index.js index f51a1a65b5..6fd8825aaf 100644 --- a/modules/item/front/item-shelving/index.js +++ b/modules/item/front/item-shelving/index.js @@ -1,11 +1,9 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; export default class Controller extends Section { constructor($element, $) { super($element, $); - this.defaulter = {}; this.smartTableOptions = { activeButtons: { @@ -13,42 +11,31 @@ export default class Controller extends Section { }, columns: [ { - field: 'clientFk', + field: 'parking', autocomplete: { - url: 'Clients', - showField: 'name', - valueField: 'id' + url: 'Parkings', + showField: 'code', + valueField: 'code' } }, { - field: 'salesPersonFk', + field: 'shelving', autocomplete: { - url: 'Workers/activeWithInheritedRole', - where: `{role: 'salesPerson'}`, - searchFunction: '{firstName: $search}', - showField: 'name', - valueField: 'id', + url: 'Shelvings', + showField: 'code', + valueField: 'code' } }, - { - field: 'workerFk', - autocomplete: { - url: 'Workers/activeWithInheritedRole', - searchFunction: '{firstName: $search}', - showField: 'name', - valueField: 'id', - } - }, - { - field: 'observation', - searchable: false - }, { field: 'created', searchable: false }, { - field: 'defaulterSinced', + field: 'itemFk', + searchable: false + }, + { + field: 'longName', searchable: false } ] @@ -58,16 +45,24 @@ export default class Controller extends Section { } get checked() { - const clients = this.$.model.data || []; + const itemShelvings = this.$.model.data || []; const checkedLines = []; - for (let defaulter of clients) { - if (defaulter.checked) - checkedLines.push(defaulter); + for (let itemShelving of itemShelvings) { + if (itemShelving.checked) + checkedLines.push(itemShelving); } return checkedLines; } + get label() { + const itemShelvings = this.$.model.data || []; + for (let itemShelving of itemShelvings) + itemShelving.label = itemShelving.stock / itemShelving.packing; + + return true; + } + getBalanceDueTotal() { this.$http.get('Defaulters/filter') .then(res => { @@ -80,48 +75,27 @@ export default class Controller extends Section { }); } - chipColor(date) { - const day = 24 * 60 * 60 * 1000; - const today = new Date(); - today.setHours(0, 0, 0, 0); - - const observationShipped = new Date(date); - observationShipped.setHours(0, 0, 0, 0); - - const difference = today - observationShipped; - - if (difference > (day * 20)) - return 'alert'; - if (difference > (day * 10)) - return 'warning'; - } - - onResponse() { - if (!this.defaulter.observation) - throw new UserError(`The message can't be empty`); - + async onRemove() { const params = []; - for (let defaulter of this.checked) { - params.push({ - text: this.defaulter.observation, - clientFk: defaulter.clientFk - }); - } + for (let itemShelving of this.checked) + params.push(itemShelving.itemShelvingFk); - this.$http.post(`ClientObservations`, params) .then(() => { - this.vnApp.showMessage(this.$t('Observation saved!')); - this.$state.reload(); - }); + for (let id of params) { + await this.$http.delete(`ItemShelvings/${id}`) + .then(() => { + this.vnApp.showSuccess(this.$t('ItemShelving removed')); + this.$state.reload(); + }); + } } exprBuilder(param, value) { switch (param) { - case 'creditInsurance': - case 'amount': - case 'clientFk': - case 'workerFk': - case 'salesPersonFk': - return {[`d.${param}`]: value}; + case 'parking': + case 'shelving': + case 'label': + case 'packing': + return {[param]: value}; } } } diff --git a/modules/item/front/item-shelving/locale/es.yml b/modules/item/front/item-shelving/locale/es.yml index c3e1d4e19c..00b6ffe58d 100644 --- a/modules/item/front/item-shelving/locale/es.yml +++ b/modules/item/front/item-shelving/locale/es.yml @@ -1,9 +1,3 @@ -Add observation: Añadir observación -Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s) -Balance D.: Saldo V. -Credit I.: Crédito A. -Last observation: Última observación -L. O. Date: Fecha Ú. O. -Last observation date: Fecha última observación -Search client: Buscar clientes -Worker who made the last observation: Trabajador que ha realizado la última observación \ No newline at end of file +Shelving: Matrícula +Remove selected lines: Eliminar líneas seleccionadas +Selected lines will be deleted: Las líneas seleccionadas serán eliminadas \ No newline at end of file