From c5683ab880f08578986d6a57645fd5c9a640cac5 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 09:17:18 +0200 Subject: [PATCH] feat: added itemShelving --- db/changes/10470-family/04-aclParking.sql | 2 + db/changes/10470-family/04-aclShelving.sql | 2 + db/dump/fixtures.sql | 31 +++++++---- modules/client/back/model-config.json | 6 ++ modules/client/back/models/parking.json | 33 +++++++++++ modules/client/back/models/shelving.json | 45 +++++++++++++++ modules/client/front/index.js | 1 + modules/client/front/routes.json | 43 ++++++++++++++- .../front/shelving/basic-data/index.html | 55 +++++++++++++++++++ .../client/front/shelving/basic-data/index.js | 12 ++++ modules/client/front/shelving/card/index.html | 5 ++ modules/client/front/shelving/card/index.js | 20 +++++++ .../client/front/shelving/card/index.spec.js | 25 +++++++++ .../client/front/shelving/create/index.html | 38 +++++++++++++ modules/client/front/shelving/create/index.js | 15 +++++ .../front/shelving/descriptor/index.html | 42 ++++++++++++++ .../client/front/shelving/descriptor/index.js | 26 +++++++++ .../front/shelving/descriptor/index.spec.js | 29 ++++++++++ .../front/shelving/descriptor/locale/es.yml | 2 + modules/client/front/shelving/index.js | 8 +++ .../client/front/shelving/index/index.html | 43 +++++++++++++++ modules/client/front/shelving/index/index.js | 14 +++++ .../client/front/shelving/index/locale/es.yml | 2 + modules/client/front/shelving/locale/es.yml | 1 + modules/client/front/shelving/main/index.html | 18 ++++++ modules/client/front/shelving/main/index.js | 29 ++++++++++ .../front/shelving/search-panel/index.html | 43 +++++++++++++++ .../front/shelving/search-panel/index.js | 7 +++ .../client/front/shelving/summary/index.html | 38 +++++++++++++ .../client/front/shelving/summary/index.js | 32 +++++++++++ 30 files changed, 656 insertions(+), 11 deletions(-) create mode 100644 db/changes/10470-family/04-aclParking.sql create mode 100644 db/changes/10470-family/04-aclShelving.sql create mode 100644 modules/client/back/models/parking.json create mode 100644 modules/client/back/models/shelving.json create mode 100644 modules/client/front/shelving/basic-data/index.html create mode 100644 modules/client/front/shelving/basic-data/index.js create mode 100644 modules/client/front/shelving/card/index.html create mode 100644 modules/client/front/shelving/card/index.js create mode 100644 modules/client/front/shelving/card/index.spec.js create mode 100644 modules/client/front/shelving/create/index.html create mode 100644 modules/client/front/shelving/create/index.js create mode 100644 modules/client/front/shelving/descriptor/index.html create mode 100644 modules/client/front/shelving/descriptor/index.js create mode 100644 modules/client/front/shelving/descriptor/index.spec.js create mode 100644 modules/client/front/shelving/descriptor/locale/es.yml create mode 100644 modules/client/front/shelving/index.js create mode 100644 modules/client/front/shelving/index/index.html create mode 100644 modules/client/front/shelving/index/index.js create mode 100644 modules/client/front/shelving/index/locale/es.yml create mode 100644 modules/client/front/shelving/locale/es.yml create mode 100644 modules/client/front/shelving/main/index.html create mode 100644 modules/client/front/shelving/main/index.js create mode 100644 modules/client/front/shelving/search-panel/index.html create mode 100644 modules/client/front/shelving/search-panel/index.js create mode 100644 modules/client/front/shelving/summary/index.html create mode 100644 modules/client/front/shelving/summary/index.js diff --git a/db/changes/10470-family/04-aclParking.sql b/db/changes/10470-family/04-aclParking.sql new file mode 100644 index 000000000..05acd68b1 --- /dev/null +++ b/db/changes/10470-family/04-aclParking.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Parking','*','*','ALLOW','ROLE','employee') \ No newline at end of file diff --git a/db/changes/10470-family/04-aclShelving.sql b/db/changes/10470-family/04-aclShelving.sql new file mode 100644 index 000000000..b237dfe0d --- /dev/null +++ b/db/changes/10470-family/04-aclShelving.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Shelving','*','*','ALLOW','ROLE','employee') \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index c329e4c6e..15d309d08 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -147,14 +147,29 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) VALUES - ('1', '700', '01', '1', '700-01', '70001'), - ('2', '700', '02', '2', '700-02', '70002'); + ('1', 700, '01', 1, '700-01', 70001), + ('2', 700, '02', 2, '700-02', 70002), + ('3', 100, '01', 1, '100-01', 1), + (32397, 100, '02', 1, 'A-47-1', 1165), + (34831, 200, '01', 1, 'K-26-2', 20220), + (34965, 200, '02', 2, 'L-08-4', 21800), + (39096, 200, '03', 2, 'LR-02-3', 99999); -INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`) VALUES - ('GVC', 1, 0, 1, 0, 1106), - ('HEJ', 2, 0, 1, 0, 1106), - ('UXN', 1, 0, 1, 0, 1106); + ('AA6', 34965, 1, 0, NULL, 0), + ('AA7', 34965, 1, 0, NULL, 0), + ('AA8', 34965, 1, 0, NULL, 0), + ('AA9', NULL, 1, 0, NULL, 0), + ('AAA', NULL, 0, 0, 1109, 1), + ('AAB', NULL, 0, 0, 1109, 1), + ('AAC', NULL, 1, 99, 1109, 1), + ('AAD', NULL, 0, 0, 1109, 1), + ('AAE', 39096, 1, 0, 1109, 1), + ('AAF', 34831, 1, 0, 1109, 1), + ('GVC', 1, 0, 1, 1106, 1), + ('HEJ', 2, 0, 1, 1106, 1), + ('UXN', 1, 0, 1, 1106, 1); INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`) VALUES @@ -1120,10 +1135,6 @@ INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`) (2, 2, 1), (3, 3, 2); -INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES - ('100', '01', 1, '100-01', 1); - INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `level`) VALUES (1, 1, 1); diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index 4feb3b168..3956f0c97 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -86,6 +86,9 @@ "ClientSample": { "dataSource": "vn" }, + "Parking": { + "dataSource": "vn" + }, "Sms": { "dataSource": "vn" }, @@ -98,6 +101,9 @@ "SageTransactionType": { "dataSource": "vn" }, + "Shelving": { + "dataSource": "vn" + }, "TpvError": { "dataSource": "vn" }, diff --git a/modules/client/back/models/parking.json b/modules/client/back/models/parking.json new file mode 100644 index 000000000..7efcf72d3 --- /dev/null +++ b/modules/client/back/models/parking.json @@ -0,0 +1,33 @@ +{ + "name": "Parking", + "base": "VnModel", + "options": { + "mysql": { + "table": "parking" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "column": { + "type": "string", + "required": true + }, + "row": { + "type": "string", + "required": true + }, + "sectorFk": { + "type": "number" + }, + "code": { + "type": "string" + }, + "pickingOrder": { + "type": "number" + } + } +} diff --git a/modules/client/back/models/shelving.json b/modules/client/back/models/shelving.json new file mode 100644 index 000000000..8e1ae3779 --- /dev/null +++ b/modules/client/back/models/shelving.json @@ -0,0 +1,45 @@ +{ + "name": "Shelving", + "base": "VnModel", + "options": { + "mysql": { + "table": "shelving" + } + }, + "properties": { + "code": { + "type": "string", + "id": true, + "description": "Identifier" + }, + "parkingFk": { + "type": "number", + "required": true + }, + "isPrinted": { + "type": "boolean", + "required": true + }, + "priority": { + "type": "number" + }, + "userFk": { + "type": "number" + }, + "isRecyclable": { + "type": "boolean" + } + }, + "relations": { + "parking": { + "type": "belongsTo", + "model": "Parking", + "foreignKey": "parkingFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "userFk" + } + } +} diff --git a/modules/client/front/index.js b/modules/client/front/index.js index ea732beea..a5e4324ca 100644 --- a/modules/client/front/index.js +++ b/modules/client/front/index.js @@ -47,3 +47,4 @@ import './consumption-search-panel'; import './defaulter'; import './notification'; import './unpaid'; +import './shelving'; diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 293243470..e55b45f3b 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -8,7 +8,8 @@ "main": [ {"state": "client.index", "icon": "person"}, {"state": "client.notification", "icon": "campaign"}, - {"state": "client.defaulter", "icon": "icon-defaulter"} + {"state": "client.defaulter", "icon": "icon-defaulter"}, + {"state": "client.shelving", "icon": "contact_support"} ], "card": [ {"state": "client.card.basicData", "icon": "settings"}, @@ -36,6 +37,9 @@ {"state": "client.card.unpaid", "icon": "icon-defaulter"} ] } + ], + "shelving": [ + {"state": "client.shelving.card.basicData", "icon": "settings"} ] }, "keybindings": [ @@ -381,6 +385,43 @@ "component": "vn-client-unpaid", "acl": ["administrative"], "description": "Unpaid" + }, + { + "url": "/shelving?q", + "state": "client.shelving", + "component": "vn-shelving", + "description": "Shelvings" + }, + { + "url": "/create", + "state": "client.shelving.create", + "component": "vn-shelving-create", + "description": "New shelving" + }, + { + "url": "/:id", + "state": "client.shelving.card", + "component": "vn-shelving-card", + "abstract": true, + "description": "Detail" + }, + { + "url": "/summary", + "state": "client.shelving.card.summary", + "component": "vn-shelving-summary", + "description": "Summary", + "params": { + "shelving": "$ctrl.shelving" + } + }, + { + "url": "/basic-data", + "state": "client.shelving.card.basicData", + "component": "vn-shelving-basic-data", + "description": "Basic data", + "params": { + "shelving": "$ctrl.shelving" + } } ] } diff --git a/modules/client/front/shelving/basic-data/index.html b/modules/client/front/shelving/basic-data/index.html new file mode 100644 index 000000000..20cf34d7c --- /dev/null +++ b/modules/client/front/shelving/basic-data/index.html @@ -0,0 +1,55 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/client/front/shelving/basic-data/index.js b/modules/client/front/shelving/basic-data/index.js new file mode 100644 index 000000000..b39707dd1 --- /dev/null +++ b/modules/client/front/shelving/basic-data/index.js @@ -0,0 +1,12 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section {} + +ngModule.component('vnShelvingBasicData', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +}); diff --git a/modules/client/front/shelving/card/index.html b/modules/client/front/shelving/card/index.html new file mode 100644 index 000000000..788a1ef00 --- /dev/null +++ b/modules/client/front/shelving/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/client/front/shelving/card/index.js b/modules/client/front/shelving/card/index.js new file mode 100644 index 000000000..82d3c6d87 --- /dev/null +++ b/modules/client/front/shelving/card/index.js @@ -0,0 +1,20 @@ +import ngModule from '../../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + const filter = { + include: [ + {relation: 'worker'}, + {relation: 'parking'} + ] + }; + this.$http.get(`Shelvings/${this.$params.id}`, {filter}) + .then(res => this.shelving = res.data); + } +} + +ngModule.vnComponent('vnShelvingCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/client/front/shelving/card/index.spec.js b/modules/client/front/shelving/card/index.spec.js new file mode 100644 index 000000000..f39840e5f --- /dev/null +++ b/modules/client/front/shelving/card/index.spec.js @@ -0,0 +1,25 @@ +import './index'; + +describe('component vnRoleCard', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('account')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRoleCard', {$element: null}); + })); + + describe('reload()', () => { + it('should reload the controller data', () => { + controller.$params.id = 1; + + $httpBackend.expectGET('Roles/1').respond('foo'); + controller.reload(); + $httpBackend.flush(); + + expect(controller.role).toBe('foo'); + }); + }); +}); diff --git a/modules/client/front/shelving/create/index.html b/modules/client/front/shelving/create/index.html new file mode 100644 index 000000000..1f8d09224 --- /dev/null +++ b/modules/client/front/shelving/create/index.html @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + +
diff --git a/modules/client/front/shelving/create/index.js b/modules/client/front/shelving/create/index.js new file mode 100644 index 000000000..336859b08 --- /dev/null +++ b/modules/client/front/shelving/create/index.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + onSubmit() { + return this.$.watcher.submit().then(res => + this.$state.go('client.shelving.card.basicData', {id: res.data.id}) + ); + } +} + +ngModule.component('vnShelvingCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/client/front/shelving/descriptor/index.html b/modules/client/front/shelving/descriptor/index.html new file mode 100644 index 000000000..05654e313 --- /dev/null +++ b/modules/client/front/shelving/descriptor/index.html @@ -0,0 +1,42 @@ + + + + Delete + + + +
+ + + + + + + {{::$ctrl.shelving.worker.firstName}} + + +
+
+
+ + + + \ No newline at end of file diff --git a/modules/client/front/shelving/descriptor/index.js b/modules/client/front/shelving/descriptor/index.js new file mode 100644 index 000000000..8bf2b3395 --- /dev/null +++ b/modules/client/front/shelving/descriptor/index.js @@ -0,0 +1,26 @@ +import ngModule from '../../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get shelving() { + return this.entity; + } + + set shelving(value) { + this.entity = value; + } + + onDelete() { + return this.$http.delete(`Shelvings/${this.shelving.code}`) + .then(() => this.$state.go('client.shelving')) + .then(() => this.vnApp.showSuccess(this.$t('Shelving removed'))); + } +} + +ngModule.component('vnShelvingDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +}); diff --git a/modules/client/front/shelving/descriptor/index.spec.js b/modules/client/front/shelving/descriptor/index.spec.js new file mode 100644 index 000000000..e2761c639 --- /dev/null +++ b/modules/client/front/shelving/descriptor/index.spec.js @@ -0,0 +1,29 @@ +import './index'; + +describe('component vnRoleDescriptor', () => { + let controller; + let $httpBackend; + + let role = {id: 1, name: 'foo'}; + + beforeEach(ngModule('account')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRoleDescriptor', {$element: null}, {role}); + })); + + describe('onDelete()', () => { + it('should delete entity and go to index', () => { + controller.$state.go = jest.fn(); + jest.spyOn(controller.vnApp, 'showSuccess'); + + $httpBackend.expectDELETE('Roles/1').respond(); + controller.onDelete(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('account.role'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + }); + }); +}); diff --git a/modules/client/front/shelving/descriptor/locale/es.yml b/modules/client/front/shelving/descriptor/locale/es.yml new file mode 100644 index 000000000..1ca512e4f --- /dev/null +++ b/modules/client/front/shelving/descriptor/locale/es.yml @@ -0,0 +1,2 @@ +Role will be removed: El rol va a ser eliminado +Role removed: Rol eliminado \ No newline at end of file diff --git a/modules/client/front/shelving/index.js b/modules/client/front/shelving/index.js new file mode 100644 index 000000000..c8282e196 --- /dev/null +++ b/modules/client/front/shelving/index.js @@ -0,0 +1,8 @@ +import './main'; +import './index/'; +import './summary'; +import './card'; +import './descriptor'; +import './search-panel'; +import './create'; +import './basic-data'; diff --git a/modules/client/front/shelving/index/index.html b/modules/client/front/shelving/index/index.html new file mode 100644 index 000000000..b69961796 --- /dev/null +++ b/modules/client/front/shelving/index/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/client/front/shelving/index/index.js b/modules/client/front/shelving/index/index.js new file mode 100644 index 000000000..da2a15efd --- /dev/null +++ b/modules/client/front/shelving/index/index.js @@ -0,0 +1,14 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + preview(shelving) { + this.selectedShelving = shelving; + this.$.summary.show(); + } +} + +ngModule.component('vnShelvingIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/client/front/shelving/index/locale/es.yml b/modules/client/front/shelving/index/locale/es.yml new file mode 100644 index 000000000..70932e983 --- /dev/null +++ b/modules/client/front/shelving/index/locale/es.yml @@ -0,0 +1,2 @@ +New role: Nuevo rol +View role: Ver rol \ No newline at end of file diff --git a/modules/client/front/shelving/locale/es.yml b/modules/client/front/shelving/locale/es.yml new file mode 100644 index 000000000..159fc7f16 --- /dev/null +++ b/modules/client/front/shelving/locale/es.yml @@ -0,0 +1 @@ +Subroles: Subroles diff --git a/modules/client/front/shelving/main/index.html b/modules/client/front/shelving/main/index.html new file mode 100644 index 000000000..324cc57cb --- /dev/null +++ b/modules/client/front/shelving/main/index.html @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/client/front/shelving/main/index.js b/modules/client/front/shelving/main/index.js new file mode 100644 index 000000000..580be0996 --- /dev/null +++ b/modules/client/front/shelving/main/index.js @@ -0,0 +1,29 @@ +import ngModule from '../../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class Shelving extends ModuleMain { + constructor($element, $) { + super($element, $); + this.filter = { + include: [ + {relation: 'parking'} + ], + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return {code: {like: `%${value}%`}}; + case 'parkingFk': + case 'userFk': + case 'isRecyclable': + return {[param]: value}; + } + } +} + +ngModule.vnComponent('vnShelving', { + controller: Shelving, + template: require('./index.html') +}); diff --git a/modules/client/front/shelving/search-panel/index.html b/modules/client/front/shelving/search-panel/index.html new file mode 100644 index 000000000..b7ca068a5 --- /dev/null +++ b/modules/client/front/shelving/search-panel/index.html @@ -0,0 +1,43 @@ +
+
+ + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/client/front/shelving/search-panel/index.js b/modules/client/front/shelving/search-panel/index.js new file mode 100644 index 000000000..4f9c3b599 --- /dev/null +++ b/modules/client/front/shelving/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnShelvingSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/client/front/shelving/summary/index.html b/modules/client/front/shelving/summary/index.html new file mode 100644 index 000000000..7d38c644c --- /dev/null +++ b/modules/client/front/shelving/summary/index.html @@ -0,0 +1,38 @@ + +
+ {{summary.code}} +
+ + +

Basic data

+ + + + + + + + + {{::summary.worker.firstName}} + + + + +
+
+
+ + \ No newline at end of file diff --git a/modules/client/front/shelving/summary/index.js b/modules/client/front/shelving/summary/index.js new file mode 100644 index 000000000..eba827956 --- /dev/null +++ b/modules/client/front/shelving/summary/index.js @@ -0,0 +1,32 @@ +import ngModule from '../../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + set shelving(value) { + console.log(value); + this._shelving = value; + this.$.summary = null; + if (!value) return; + + const filter = { + include: [ + {relation: 'worker'}, + {relation: 'parking'} + ] + }; + this.$http.get(`Shelvings/${value.code}`, {filter}) + .then(res => this.$.summary = res.data); + } + + get shelving() { + return this._shelving; + } +} + +ngModule.component('vnShelvingSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +});