From c5683ab880f08578986d6a57645fd5c9a640cac5 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 09:17:18 +0200 Subject: [PATCH 01/15] 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: '<' + } +}); From 99c7ad1c1be13b4fc9031af287d9ef023c4ea75d Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 24 May 2022 12:50:06 +0200 Subject: [PATCH 02/15] refactor: delete section shelving from client --- 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 | 45 +-------------- .../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 ----------- 27 files changed, 2 insertions(+), 632 deletions(-) delete mode 100644 modules/client/back/models/parking.json delete mode 100644 modules/client/back/models/shelving.json delete mode 100644 modules/client/front/shelving/basic-data/index.html delete mode 100644 modules/client/front/shelving/basic-data/index.js delete mode 100644 modules/client/front/shelving/card/index.html delete mode 100644 modules/client/front/shelving/card/index.js delete mode 100644 modules/client/front/shelving/card/index.spec.js delete mode 100644 modules/client/front/shelving/create/index.html delete mode 100644 modules/client/front/shelving/create/index.js delete mode 100644 modules/client/front/shelving/descriptor/index.html delete mode 100644 modules/client/front/shelving/descriptor/index.js delete mode 100644 modules/client/front/shelving/descriptor/index.spec.js delete mode 100644 modules/client/front/shelving/descriptor/locale/es.yml delete mode 100644 modules/client/front/shelving/index.js delete mode 100644 modules/client/front/shelving/index/index.html delete mode 100644 modules/client/front/shelving/index/index.js delete mode 100644 modules/client/front/shelving/index/locale/es.yml delete mode 100644 modules/client/front/shelving/locale/es.yml delete mode 100644 modules/client/front/shelving/main/index.html delete mode 100644 modules/client/front/shelving/main/index.js delete mode 100644 modules/client/front/shelving/search-panel/index.html delete mode 100644 modules/client/front/shelving/search-panel/index.js delete mode 100644 modules/client/front/shelving/summary/index.html delete mode 100644 modules/client/front/shelving/summary/index.js diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index 3956f0c97..4feb3b168 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -86,9 +86,6 @@ "ClientSample": { "dataSource": "vn" }, - "Parking": { - "dataSource": "vn" - }, "Sms": { "dataSource": "vn" }, @@ -101,9 +98,6 @@ "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 deleted file mode 100644 index 7efcf72d3..000000000 --- a/modules/client/back/models/parking.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "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 deleted file mode 100644 index 8e1ae3779..000000000 --- a/modules/client/back/models/shelving.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "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 a5e4324ca..ea732beea 100644 --- a/modules/client/front/index.js +++ b/modules/client/front/index.js @@ -47,4 +47,3 @@ 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 e55b45f3b..82052c95b 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -8,8 +8,7 @@ "main": [ {"state": "client.index", "icon": "person"}, {"state": "client.notification", "icon": "campaign"}, - {"state": "client.defaulter", "icon": "icon-defaulter"}, - {"state": "client.shelving", "icon": "contact_support"} + {"state": "client.defaulter", "icon": "icon-defaulter"} ], "card": [ {"state": "client.card.basicData", "icon": "settings"}, @@ -37,10 +36,7 @@ {"state": "client.card.unpaid", "icon": "icon-defaulter"} ] } - ], - "shelving": [ - {"state": "client.shelving.card.basicData", "icon": "settings"} - ] + ] }, "keybindings": [ {"key": "c", "state": "client.index"} @@ -385,43 +381,6 @@ "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 deleted file mode 100644 index 20cf34d7c..000000000 --- a/modules/client/front/shelving/basic-data/index.html +++ /dev/null @@ -1,55 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - -
\ 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 deleted file mode 100644 index b39707dd1..000000000 --- a/modules/client/front/shelving/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 788a1ef00..000000000 --- a/modules/client/front/shelving/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/client/front/shelving/card/index.js b/modules/client/front/shelving/card/index.js deleted file mode 100644 index 82d3c6d87..000000000 --- a/modules/client/front/shelving/card/index.js +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index f39840e5f..000000000 --- a/modules/client/front/shelving/card/index.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index 1f8d09224..000000000 --- a/modules/client/front/shelving/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/client/front/shelving/create/index.js b/modules/client/front/shelving/create/index.js deleted file mode 100644 index 336859b08..000000000 --- a/modules/client/front/shelving/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 05654e313..000000000 --- a/modules/client/front/shelving/descriptor/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - 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 deleted file mode 100644 index 8bf2b3395..000000000 --- a/modules/client/front/shelving/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index e2761c639..000000000 --- a/modules/client/front/shelving/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 1ca512e4f..000000000 --- a/modules/client/front/shelving/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index c8282e196..000000000 --- a/modules/client/front/shelving/index.js +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index b69961796..000000000 --- a/modules/client/front/shelving/index/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/client/front/shelving/index/index.js b/modules/client/front/shelving/index/index.js deleted file mode 100644 index da2a15efd..000000000 --- a/modules/client/front/shelving/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 70932e983..000000000 --- a/modules/client/front/shelving/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 159fc7f16..000000000 --- a/modules/client/front/shelving/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Subroles: Subroles diff --git a/modules/client/front/shelving/main/index.html b/modules/client/front/shelving/main/index.html deleted file mode 100644 index 324cc57cb..000000000 --- a/modules/client/front/shelving/main/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/client/front/shelving/main/index.js b/modules/client/front/shelving/main/index.js deleted file mode 100644 index 580be0996..000000000 --- a/modules/client/front/shelving/main/index.js +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index b7ca068a5..000000000 --- a/modules/client/front/shelving/search-panel/index.html +++ /dev/null @@ -1,43 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - -
-
\ 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 deleted file mode 100644 index 4f9c3b599..000000000 --- a/modules/client/front/shelving/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 7d38c644c..000000000 --- a/modules/client/front/shelving/summary/index.html +++ /dev/null @@ -1,38 +0,0 @@ - -
- {{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 deleted file mode 100644 index eba827956..000000000 --- a/modules/client/front/shelving/summary/index.js +++ /dev/null @@ -1,32 +0,0 @@ -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: '<' - } -}); From f00fb0dc3f4eb83a2166a1912c3f90278f2f09cc Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 24 May 2022 12:50:22 +0200 Subject: [PATCH 03/15] feat: add new module shelving --- back/nodemonConfig.json | 1 + front/module-import.js | 1 + jest-front.js | 1 + .../back/methods/shelving/getSummary.js | 52 ++++++++ modules/shelving/back/model-config.json | 8 ++ modules/shelving/back/models/parking.json | 33 +++++ modules/shelving/back/models/shelving.js | 3 + modules/shelving/back/models/shelving.json | 48 +++++++ modules/shelving/front/basic-data/index.html | 52 ++++++++ modules/shelving/front/basic-data/index.js | 10 ++ .../shelving/front/basic-data/locale/es.yml | 5 + modules/shelving/front/card/index.html | 8 ++ modules/shelving/front/card/index.js | 29 +++++ modules/shelving/front/create/index.html | 30 +++++ modules/shelving/front/create/index.js | 15 +++ modules/shelving/front/create/index.spec.js | 122 ++++++++++++++++++ modules/shelving/front/create/locale/es.yml | 11 ++ modules/shelving/front/descriptor/index.html | 45 +++++++ modules/shelving/front/descriptor/index.js | 66 ++++++++++ .../shelving/front/descriptor/index.spec.js | 64 +++++++++ .../shelving/front/descriptor/locale/es.yml | 7 + modules/shelving/front/index.js | 10 ++ modules/shelving/front/index/index.html | 43 ++++++ modules/shelving/front/index/index.js | 14 ++ modules/shelving/front/index/locale/es.yml | 5 + modules/shelving/front/locale/es.yml | 1 + modules/shelving/front/main/index.html | 18 +++ modules/shelving/front/main/index.js | 33 +++++ modules/shelving/front/module.js | 3 + modules/shelving/front/routes.json | 71 ++++++++++ .../shelving/front/search-panel/index.html | 43 ++++++ modules/shelving/front/search-panel/index.js | 7 + .../shelving/front/search-panel/locale/es.yml | 4 + modules/shelving/front/summary/index.html | 51 ++++++++ modules/shelving/front/summary/index.js | 41 ++++++ modules/shelving/front/summary/index.spec.js | 32 +++++ modules/shelving/front/summary/locale/es.yml | 12 ++ modules/shelving/front/summary/style.scss | 7 + 38 files changed, 1006 insertions(+) create mode 100644 modules/shelving/back/methods/shelving/getSummary.js create mode 100644 modules/shelving/back/model-config.json create mode 100644 modules/shelving/back/models/parking.json create mode 100644 modules/shelving/back/models/shelving.js create mode 100644 modules/shelving/back/models/shelving.json create mode 100644 modules/shelving/front/basic-data/index.html create mode 100644 modules/shelving/front/basic-data/index.js create mode 100644 modules/shelving/front/basic-data/locale/es.yml create mode 100644 modules/shelving/front/card/index.html create mode 100644 modules/shelving/front/card/index.js create mode 100644 modules/shelving/front/create/index.html create mode 100644 modules/shelving/front/create/index.js create mode 100644 modules/shelving/front/create/index.spec.js create mode 100644 modules/shelving/front/create/locale/es.yml create mode 100644 modules/shelving/front/descriptor/index.html create mode 100644 modules/shelving/front/descriptor/index.js create mode 100644 modules/shelving/front/descriptor/index.spec.js create mode 100644 modules/shelving/front/descriptor/locale/es.yml create mode 100644 modules/shelving/front/index.js create mode 100644 modules/shelving/front/index/index.html create mode 100644 modules/shelving/front/index/index.js create mode 100644 modules/shelving/front/index/locale/es.yml create mode 100644 modules/shelving/front/locale/es.yml create mode 100644 modules/shelving/front/main/index.html create mode 100644 modules/shelving/front/main/index.js create mode 100644 modules/shelving/front/module.js create mode 100644 modules/shelving/front/routes.json create mode 100644 modules/shelving/front/search-panel/index.html create mode 100644 modules/shelving/front/search-panel/index.js create mode 100644 modules/shelving/front/search-panel/locale/es.yml create mode 100644 modules/shelving/front/summary/index.html create mode 100644 modules/shelving/front/summary/index.js create mode 100644 modules/shelving/front/summary/index.spec.js create mode 100644 modules/shelving/front/summary/locale/es.yml create mode 100644 modules/shelving/front/summary/style.scss diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json index a1c9ca84f..5138bc30e 100644 --- a/back/nodemonConfig.json +++ b/back/nodemonConfig.json @@ -18,6 +18,7 @@ "modules/supplier/front/**/*", "modules/ticket/front/**/*", "modules/travel/front/**/*", + "modules/shelving/front/**/*", "modules/worker/front/**/*", "modules/zone/front/**/*" ] diff --git a/front/module-import.js b/front/module-import.js index ab1eb73d6..bc547deeb 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -21,6 +21,7 @@ export default function moduleImport(moduleName) { case 'entry' : return import('entry/front'); case 'account' : return import('account/front'); case 'supplier' : return import('supplier/front'); + case 'shelving' : return import('shelving/front'); case 'monitor' : return import('monitor/front'); } } diff --git a/jest-front.js b/jest-front.js index 7a692f57c..6d7532260 100644 --- a/jest-front.js +++ b/jest-front.js @@ -13,6 +13,7 @@ import './modules/route/front/module.js'; import './modules/ticket/front/module.js'; import './modules/travel/front/module.js'; import './modules/worker/front/module.js'; +import './modules/shelving/front/module.js'; core.run(vnInterceptor => { vnInterceptor.setApiPath(null); diff --git a/modules/shelving/back/methods/shelving/getSummary.js b/modules/shelving/back/methods/shelving/getSummary.js new file mode 100644 index 000000000..da357c7bf --- /dev/null +++ b/modules/shelving/back/methods/shelving/getSummary.js @@ -0,0 +1,52 @@ +module.exports = Self => { + Self.remoteMethod('getSummary', { + description: 'Returns the shelving summary', + accessType: 'READ', + accepts: { + arg: 'code', + type: 'string', + required: true, + description: 'The shelving code', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:code/getSummary`, + verb: 'GET' + } + }); + Self.getSummary = async code => { + let filter = { + where: {code: code}, + fields: [ + 'code', + 'parkingFk', + 'priority', + 'userFk', + 'isRecyclable' + ], + include: [ + { + relation: 'parking' + }, + { + relation: 'worker', + scope: { + fields: ['id', 'userFk'], + include: { + relation: 'user', + scope: { + fields: ['id', 'nickname'] + } + } + } + } + ] + }; + + return Self.app.models.Shelving.findOne(filter); + }; +}; diff --git a/modules/shelving/back/model-config.json b/modules/shelving/back/model-config.json new file mode 100644 index 000000000..ff4164b31 --- /dev/null +++ b/modules/shelving/back/model-config.json @@ -0,0 +1,8 @@ +{ + "Parking": { + "dataSource": "vn" + }, + "Shelving": { + "dataSource": "vn" + } +} diff --git a/modules/shelving/back/models/parking.json b/modules/shelving/back/models/parking.json new file mode 100644 index 000000000..7efcf72d3 --- /dev/null +++ b/modules/shelving/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/shelving/back/models/shelving.js b/modules/shelving/back/models/shelving.js new file mode 100644 index 000000000..3e27f5863 --- /dev/null +++ b/modules/shelving/back/models/shelving.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/shelving/getSummary')(Self); +}; diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json new file mode 100644 index 000000000..b28539942 --- /dev/null +++ b/modules/shelving/back/models/shelving.json @@ -0,0 +1,48 @@ +{ + "name": "Shelving", + "base": "VnModel", + "options": { + "mysql": { + "table": "shelving" + } + }, + "properties": { + "id": { + "type": "string", + "id": true, + "description": "Identifier", + "mysql": { + "columnName": "code" + } + }, + "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/shelving/front/basic-data/index.html b/modules/shelving/front/basic-data/index.html new file mode 100644 index 000000000..a36a9f85a --- /dev/null +++ b/modules/shelving/front/basic-data/index.html @@ -0,0 +1,52 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/shelving/front/basic-data/index.js b/modules/shelving/front/basic-data/index.js new file mode 100644 index 000000000..e17c9feee --- /dev/null +++ b/modules/shelving/front/basic-data/index.js @@ -0,0 +1,10 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnShelvingBasicData', { + template: require('./index.html'), + controller: Section, + bindings: { + shelving: '<' + } +}); diff --git a/modules/shelving/front/basic-data/locale/es.yml b/modules/shelving/front/basic-data/locale/es.yml new file mode 100644 index 000000000..e965ffc2e --- /dev/null +++ b/modules/shelving/front/basic-data/locale/es.yml @@ -0,0 +1,5 @@ +Notes: Notas +Active: Activo +Verified: Verificado +PayMethodChecked: Método de pago validado +Responsible for approving invoices: Responsable de aprobar las facturas \ No newline at end of file diff --git a/modules/shelving/front/card/index.html b/modules/shelving/front/card/index.html new file mode 100644 index 000000000..c83afc288 --- /dev/null +++ b/modules/shelving/front/card/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/shelving/front/card/index.js b/modules/shelving/front/card/index.js new file mode 100644 index 000000000..5e2ea9b12 --- /dev/null +++ b/modules/shelving/front/card/index.js @@ -0,0 +1,29 @@ +import ngModule from '../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + const filter = { + include: [ + {relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + }}, + {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/shelving/front/create/index.html b/modules/shelving/front/create/index.html new file mode 100644 index 000000000..c462b54a6 --- /dev/null +++ b/modules/shelving/front/create/index.html @@ -0,0 +1,30 @@ + + +
+ + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/shelving/front/create/index.js b/modules/shelving/front/create/index.js new file mode 100644 index 000000000..bb0e441eb --- /dev/null +++ b/modules/shelving/front/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('shelving.card.basicData', {id: res.data.id}) + ); + } +} + +ngModule.vnComponent('vnShelvingCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/shelving/front/create/index.spec.js b/modules/shelving/front/create/index.spec.js new file mode 100644 index 000000000..24fc80d21 --- /dev/null +++ b/modules/shelving/front/create/index.spec.js @@ -0,0 +1,122 @@ +import './index'; + +describe('Client', () => { + describe('Component vnClientCreate', () => { + let $scope; + let $state; + let controller; + + beforeEach(ngModule('client')); + + beforeEach(inject(($componentController, $rootScope, _$state_) => { + $scope = $rootScope.$new(); + $state = _$state_; + $scope.watcher = { + submit: () => { + return { + then: callback => { + callback({data: {id: '1234'}}); + } + }; + } + }; + const $element = angular.element(''); + controller = $componentController('vnClientCreate', {$element, $scope}); + })); + + it('should define and set scope, state and client properties', () => { + expect(controller.$).toBe($scope); + expect(controller.$state).toBe($state); + expect(controller.client.active).toBe(true); + }); + + describe('onSubmit()', () => { + it(`should call submit() on the watcher then expect a callback`, () => { + jest.spyOn($state, 'go'); + controller.onSubmit(); + + expect(controller.$state.go).toHaveBeenCalledWith('client.card.basicData', {id: '1234'}); + }); + }); + + describe('province() setter', () => { + it(`should set countryFk property`, () => { + controller.client.countryFk = null; + controller.province = { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }; + + expect(controller.client.countryFk).toEqual(2); + }); + }); + + describe('town() setter', () => { + it(`should set provinceFk property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.client.provinceFk).toEqual(1); + }); + + it(`should set provinceFk property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.postcode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town, provinceFk and contryFk properties`, () => { + controller.postcode = { + townFk: 1, + code: 46001, + town: { + id: 1, + name: 'New York', + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + } + } + }; + + expect(controller.client.city).toEqual('New York'); + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.countryFk).toEqual(2); + }); + }); + }); +}); diff --git a/modules/shelving/front/create/locale/es.yml b/modules/shelving/front/create/locale/es.yml new file mode 100644 index 000000000..31b7cd403 --- /dev/null +++ b/modules/shelving/front/create/locale/es.yml @@ -0,0 +1,11 @@ +Name: Nombre +Tax number: NIF/CIF +Business name: Razón social +Web user: Usuario Web +Email: E-mail +Create and edit: Crear y editar +You can save multiple emails: >- + Puede guardar varios correos electrónicos encadenándolos mediante comas + sin espacios, ejemplo: user@dominio.com, user2@dominio.com siendo el primer + correo electrónico el principal +The type of business must be filled in basic data: El tipo de negocio debe estar rellenado en datos básicos diff --git a/modules/shelving/front/descriptor/index.html b/modules/shelving/front/descriptor/index.html new file mode 100644 index 000000000..7ec836ed4 --- /dev/null +++ b/modules/shelving/front/descriptor/index.html @@ -0,0 +1,45 @@ + + + + Delete + + + +
+ + + + + + + {{::$ctrl.shelving.worker.user.nickname}} + + +
+
+
+ + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/descriptor/index.js b/modules/shelving/front/descriptor/index.js new file mode 100644 index 000000000..35d1d9892 --- /dev/null +++ b/modules/shelving/front/descriptor/index.js @@ -0,0 +1,66 @@ +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.id}`) + .then(() => this.$state.go('shelving.index')) + .then(() => this.vnApp.showSuccess(this.$t('Shelving removed'))); + } + + // loadData() { + // const filter = { + // fields: [ + // 'id', + // 'name', + // 'nickname', + // 'nif', + // 'payMethodFk', + // 'payDemFk', + // 'payDay', + // 'isActive', + // 'isSerious', + // 'account' + // ], + // include: [ + // { + // relation: 'payMethod', + // scope: { + // fields: ['id', 'name'] + // } + // }, + // { + // relation: 'payDem', + // scope: { + // fields: ['id', 'payDem'] + // } + // }, + // { + // relation: 'client', + // scope: { + // fields: ['id', 'fi'] + // } + // } + // ] + // }; + + // return this.getData(`Suppliers/${this.id}`, {filter}) + // .then(res => this.supplier = res.data); + // } +} + +ngModule.vnComponent('vnShelvingDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +}); diff --git a/modules/shelving/front/descriptor/index.spec.js b/modules/shelving/front/descriptor/index.spec.js new file mode 100644 index 000000000..8926fa4d1 --- /dev/null +++ b/modules/shelving/front/descriptor/index.spec.js @@ -0,0 +1,64 @@ +import './index.js'; + +describe('Supplier Component vnSupplierDescriptor', () => { + let $httpBackend; + let controller; + let $httpParamSerializer; + const supplier = {id: 1}; + + beforeEach(ngModule('supplier')); + + beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier}); + })); + + describe('loadData()', () => { + it('should perform ask for the supplier', () => { + const filter = { + fields: [ + 'id', + 'name', + 'nickname', + 'nif', + 'payMethodFk', + 'payDemFk', + 'payDay', + 'isActive', + 'isSerious', + 'account' + ], + include: [ + { + relation: 'payMethod', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'payDem', + scope: { + fields: ['id', 'payDem'] + } + }, + { + relation: 'client', + scope: { + fields: ['id', 'fi'] + } + } + ] + }; + const serializedParams = $httpParamSerializer({filter}); + let query = `Suppliers/${controller.supplier.id}?${serializedParams}`; + jest.spyOn(controller, 'getData'); + + $httpBackend.expect('GET', query).respond({id: 1}); + controller.loadData(); + $httpBackend.flush(); + + expect(controller.getData).toHaveBeenCalledTimes(1); + }); + }); +}); diff --git a/modules/shelving/front/descriptor/locale/es.yml b/modules/shelving/front/descriptor/locale/es.yml new file mode 100644 index 000000000..d889a9eee --- /dev/null +++ b/modules/shelving/front/descriptor/locale/es.yml @@ -0,0 +1,7 @@ +Tax number: NIF / CIF +All entries with current supplier: Todas las entradas con el proveedor actual +Go to client: Ir al cliente +Verified supplier: Proveedor verificado +Unverified supplier: Proveedor no verificado +Inactive supplier: Proveedor inactivo +Create invoiceIn: Crear factura recibida \ No newline at end of file diff --git a/modules/shelving/front/index.js b/modules/shelving/front/index.js new file mode 100644 index 000000000..df26602fc --- /dev/null +++ b/modules/shelving/front/index.js @@ -0,0 +1,10 @@ +export * from './module'; + +import './basic-data'; +import './card'; +import './create'; +import './descriptor'; +import './index/'; +import './main'; +import './search-panel'; +import './summary'; diff --git a/modules/shelving/front/index/index.html b/modules/shelving/front/index/index.html new file mode 100644 index 000000000..94ad75bfa --- /dev/null +++ b/modules/shelving/front/index/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/index/index.js b/modules/shelving/front/index/index.js new file mode 100644 index 000000000..04d8ea9cd --- /dev/null +++ b/modules/shelving/front/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.vnComponent('vnShelvingIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/shelving/front/index/locale/es.yml b/modules/shelving/front/index/locale/es.yml new file mode 100644 index 000000000..ad8a4f0bb --- /dev/null +++ b/modules/shelving/front/index/locale/es.yml @@ -0,0 +1,5 @@ +Payment deadline: Plazo de pago +Pay day: Dia de pago +Account: Cuenta +Pay method: Metodo de pago +Tax number: Nif \ No newline at end of file diff --git a/modules/shelving/front/locale/es.yml b/modules/shelving/front/locale/es.yml new file mode 100644 index 000000000..abb6a9775 --- /dev/null +++ b/modules/shelving/front/locale/es.yml @@ -0,0 +1 @@ +Accounts: Cuentas \ No newline at end of file diff --git a/modules/shelving/front/main/index.html b/modules/shelving/front/main/index.html new file mode 100644 index 000000000..20e29b5f9 --- /dev/null +++ b/modules/shelving/front/main/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/main/index.js b/modules/shelving/front/main/index.js new file mode 100644 index 000000000..63c5689b1 --- /dev/null +++ b/modules/shelving/front/main/index.js @@ -0,0 +1,33 @@ +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'} + ], + }; + } + + $onInit() { + console.log(this.$params); + } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return {id: {like: `%${value}%`}}; + case 'parkingFk': + case 'userFk': + case 'isRecyclable': + return {[param]: value}; + } + } +} + +ngModule.vnComponent('vnShelving', { + controller: Shelving, + template: require('./index.html') +}); diff --git a/modules/shelving/front/module.js b/modules/shelving/front/module.js new file mode 100644 index 000000000..8ba261ead --- /dev/null +++ b/modules/shelving/front/module.js @@ -0,0 +1,3 @@ +import {ng} from 'core/vendor'; + +export default ng.module('shelving', ['salix']); diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json new file mode 100644 index 000000000..e51ff9d25 --- /dev/null +++ b/modules/shelving/front/routes.json @@ -0,0 +1,71 @@ +{ + "module": "shelving", + "name": "Shelvings", + "icon" : "contact_support", + "dependencies": [], + "validations" : true, + "menus": { + "main": [ + {"state": "shelving.index", "icon": "contact_support"} + ], + "card": [ + {"state": "shelving.card.basicData", "icon": "settings"}, + {"state": "shelving.card.log", "icon": "history"} + ] + }, + "keybindings": [ + {"key": "s", "state": "shelving.index"} + ], + "routes": [ + { + "url": "/shelving", + "state": "shelving", + "abstract": true, + "component": "vn-shelving", + "description": "Shelvings" + }, + { + "url": "/index?q", + "state": "shelving.index", + "component": "vn-shelving-index", + "description": "Shelvings" + }, + { + "url": "/create", + "state": "shelving.create", + "component": "vn-shelving-create", + "description": "New shelving" + }, + { + "url": "/:id", + "state": "shelving.card", + "abstract": true, + "component": "vn-shelving-card" + }, + { + "url": "/summary", + "state": "shelving.card.summary", + "component": "vn-shelving-summary", + "description": "Summary", + "params": { + "shelving": "$ctrl.shelving" + } + }, + { + "url": "/basic-data", + "state": "shelving.card.basicData", + "component": "vn-shelving-basic-data", + "description": "Basic data", + "acl": ["administrative"], + "params": { + "shelving": "$ctrl.shelving" + } + }, + { + "url" : "/log", + "state": "shelving.card.log", + "component": "vn-shelving-log", + "description": "Log" + } + ] +} \ No newline at end of file diff --git a/modules/shelving/front/search-panel/index.html b/modules/shelving/front/search-panel/index.html new file mode 100644 index 000000000..b7ca068a5 --- /dev/null +++ b/modules/shelving/front/search-panel/index.html @@ -0,0 +1,43 @@ +
+
+ + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/shelving/front/search-panel/index.js b/modules/shelving/front/search-panel/index.js new file mode 100644 index 000000000..51b81538b --- /dev/null +++ b/modules/shelving/front/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.vnComponent('vnShelvingSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/shelving/front/search-panel/locale/es.yml b/modules/shelving/front/search-panel/locale/es.yml new file mode 100644 index 000000000..77253a4ef --- /dev/null +++ b/modules/shelving/front/search-panel/locale/es.yml @@ -0,0 +1,4 @@ +Province: Provincia +Country: País +Tax number: NIF / CIF +Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias \ No newline at end of file diff --git a/modules/shelving/front/summary/index.html b/modules/shelving/front/summary/index.html new file mode 100644 index 000000000..8b193c3ee --- /dev/null +++ b/modules/shelving/front/summary/index.html @@ -0,0 +1,51 @@ + +
+ + + + {{::$ctrl.summary.id}} +
+ + +

+ + Basic data + +

+ + + + + + + + + + {{$ctrl.summary.worker.user.nickname}} + + + + + +
+
+
+ + \ No newline at end of file diff --git a/modules/shelving/front/summary/index.js b/modules/shelving/front/summary/index.js new file mode 100644 index 000000000..10a905f1d --- /dev/null +++ b/modules/shelving/front/summary/index.js @@ -0,0 +1,41 @@ +import ngModule from '../module'; +import Summary from 'salix/components/summary'; +import './style.scss'; + +class Controller extends Summary { + set shelving(value) { + this._shelving = value; + this.summary = null; + if (!value) return; + + const filter = { + include: [ + {relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + }}, + {relation: 'parking'} + ] + }; + this.$http.get(`Shelvings/${value.id}`, {filter}) + .then(res => this.summary = res.data); + } + + get shelving() { + return this._shelving; + } +} + +ngModule.vnComponent('vnShelvingSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +}); diff --git a/modules/shelving/front/summary/index.spec.js b/modules/shelving/front/summary/index.spec.js new file mode 100644 index 000000000..aa44cd14f --- /dev/null +++ b/modules/shelving/front/summary/index.spec.js @@ -0,0 +1,32 @@ +import './index'; + +describe('Supplier', () => { + describe('Component vnSupplierSummary', () => { + let controller; + let $httpBackend; + let $scope; + + beforeEach(ngModule('supplier')); + + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { + $httpBackend = _$httpBackend_; + $scope = $rootScope.$new(); + const $element = angular.element(''); + controller = $componentController('vnSupplierSummary', {$element, $scope}); + })); + + describe('getSummary()', () => { + it('should perform a get asking for the supplier data', () => { + controller.supplier = {id: 1}; + + const query = `Suppliers/${controller.supplier.id}/getSummary`; + + $httpBackend.expectGET(query).respond({id: 1}); + controller.getSummary(); + $httpBackend.flush(); + + expect(controller.summary).toEqual({id: 1}); + }); + }); + }); +}); diff --git a/modules/shelving/front/summary/locale/es.yml b/modules/shelving/front/summary/locale/es.yml new file mode 100644 index 000000000..35291e579 --- /dev/null +++ b/modules/shelving/front/summary/locale/es.yml @@ -0,0 +1,12 @@ +Verified: Verificado +Country: País +Tax number: NIF / CIF +Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias +Is Farmer: Es agrícola +Sage tax type: Tipo de impuesto Sage +Sage transaction type: Tipo de transacción Sage +Sage withholding: Retencion Sage +Go to the supplier: Ir al proveedor +Responsible: Responsable +Supplier activity: Actividad proveedor +Healt register: Pasaporte sanitario \ No newline at end of file diff --git a/modules/shelving/front/summary/style.scss b/modules/shelving/front/summary/style.scss new file mode 100644 index 000000000..1eb6b2323 --- /dev/null +++ b/modules/shelving/front/summary/style.scss @@ -0,0 +1,7 @@ +@import "variables"; + +vn-client-summary { + .alert span { + color: $color-alert + } +} \ No newline at end of file From 5880efe966b12496b08c999d21cfa74863bc1e13 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 24 May 2022 12:51:00 +0200 Subject: [PATCH 04/15] refator: commented code deleted --- modules/shelving/front/descriptor/index.js | 40 ---------------------- 1 file changed, 40 deletions(-) diff --git a/modules/shelving/front/descriptor/index.js b/modules/shelving/front/descriptor/index.js index 35d1d9892..931dbb6dc 100644 --- a/modules/shelving/front/descriptor/index.js +++ b/modules/shelving/front/descriptor/index.js @@ -15,46 +15,6 @@ class Controller extends Descriptor { .then(() => this.$state.go('shelving.index')) .then(() => this.vnApp.showSuccess(this.$t('Shelving removed'))); } - - // loadData() { - // const filter = { - // fields: [ - // 'id', - // 'name', - // 'nickname', - // 'nif', - // 'payMethodFk', - // 'payDemFk', - // 'payDay', - // 'isActive', - // 'isSerious', - // 'account' - // ], - // include: [ - // { - // relation: 'payMethod', - // scope: { - // fields: ['id', 'name'] - // } - // }, - // { - // relation: 'payDem', - // scope: { - // fields: ['id', 'payDem'] - // } - // }, - // { - // relation: 'client', - // scope: { - // fields: ['id', 'fi'] - // } - // } - // ] - // }; - - // return this.getData(`Suppliers/${this.id}`, {filter}) - // .then(res => this.supplier = res.data); - // } } ngModule.vnComponent('vnShelvingDescriptor', { From eba6c149ba6c9e1b5988c472b8528443a1d9c4ff Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 7 Jun 2022 13:26:55 +0200 Subject: [PATCH 05/15] refactor --- modules/shelving/front/basic-data/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/shelving/front/basic-data/index.html b/modules/shelving/front/basic-data/index.html index a36a9f85a..cf66cc917 100644 --- a/modules/shelving/front/basic-data/index.html +++ b/modules/shelving/front/basic-data/index.html @@ -19,17 +19,17 @@ vn-one url="Parkings" label="Parking" - show-field="id" + show-field="code" value-field="id" ng-model="$ctrl.shelving.parkingFk"> - - + From ac344d6edda14eb8823d8eb62af624f8e70a5b67 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 14 Jul 2022 09:54:28 +0200 Subject: [PATCH 06/15] refactor: add column id PK and updated column code UQ --- db/changes/10480-june/00-shelving.sql | 14 ++++++ modules/shelving/back/models/shelving.json | 17 ++++--- modules/shelving/back/models/shelvingLog.json | 48 +++++++++++++++++++ modules/shelving/front/basic-data/index.html | 2 +- modules/shelving/front/create/index.html | 33 ++++++++++--- modules/shelving/front/create/index.js | 2 +- modules/shelving/front/create/locale/es.yml | 11 ----- modules/shelving/front/descriptor/index.html | 4 +- .../shelving/front/descriptor/locale/es.yml | 7 --- modules/shelving/front/index/index.html | 10 ++-- modules/shelving/front/index/locale/es.yml | 7 +-- modules/shelving/front/locale/es.yml | 1 - modules/shelving/front/log/index.html | 1 + modules/shelving/front/log/index.js | 7 +++ modules/shelving/front/main/index.html | 2 +- modules/shelving/front/main/index.js | 6 +-- modules/shelving/front/main/locale/es.yml | 1 + modules/shelving/front/routes.json | 2 +- .../shelving/front/search-panel/locale/es.yml | 5 +- modules/shelving/front/summary/index.html | 10 ++-- modules/shelving/front/summary/locale/es.yml | 17 ++----- 21 files changed, 133 insertions(+), 74 deletions(-) create mode 100644 db/changes/10480-june/00-shelving.sql create mode 100644 modules/shelving/back/models/shelvingLog.json delete mode 100644 modules/shelving/front/create/locale/es.yml delete mode 100644 modules/shelving/front/descriptor/locale/es.yml delete mode 100644 modules/shelving/front/locale/es.yml create mode 100644 modules/shelving/front/log/index.html create mode 100644 modules/shelving/front/log/index.js create mode 100644 modules/shelving/front/main/locale/es.yml diff --git a/db/changes/10480-june/00-shelving.sql b/db/changes/10480-june/00-shelving.sql new file mode 100644 index 000000000..045698e8f --- /dev/null +++ b/db/changes/10480-june/00-shelving.sql @@ -0,0 +1,14 @@ +ALTER TABLE `vn`.`itemShelving` DROP FOREIGN KEY itemShelving_fk2; +ALTER TABLE `vn`.`shelvingLog` DROP FOREIGN KEY shelvingLog_FK_ibfk_1; +ALTER TABLE `vn`.`smartTag` DROP FOREIGN KEY smartTag_shelving_fk; +ALTER TABLE `vn`.`workerShelving` DROP FOREIGN KEY workerShelving_shelving_fk; + +ALTER TABLE `vn`.`shelving` DROP PRIMARY KEY; +ALTER TABLE `vn`.`shelving` ADD id INT auto_increment PRIMARY KEY NULL; +ALTER TABLE `vn`.`shelving` CHANGE id id int(11) auto_increment NOT NULL FIRST; +ALTER TABLE `vn`.`shelving` ADD CONSTRAINT shelving_UN UNIQUE KEY (code); + +ALTER TABLE `vn`.`itemShelving` ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `vn`.`shelvingLog` ADD CONSTRAINT shelvingLog_FK_ibfk_1 FOREIGN KEY (originFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `vn`.`smartTag` ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`workerShelving` ADD CONSTRAINT workerShelving_FK_1 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index b28539942..c7fcb2560 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -8,20 +8,19 @@ }, "properties": { "id": { - "type": "string", + "type": "number", "id": true, - "description": "Identifier", - "mysql": { - "columnName": "code" - } + "description": "Identifier" + }, + "code": { + "type": "string", + "required": true }, "parkingFk": { - "type": "number", - "required": true + "type": "number" }, "isPrinted": { - "type": "boolean", - "required": true + "type": "boolean" }, "priority": { "type": "number" diff --git a/modules/shelving/back/models/shelvingLog.json b/modules/shelving/back/models/shelvingLog.json new file mode 100644 index 000000000..61eb0813f --- /dev/null +++ b/modules/shelving/back/models/shelvingLog.json @@ -0,0 +1,48 @@ +{ + "name": "ShelvingLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "shelvingLog" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "originFk": { + "type": "string", + "required": true + }, + "userFk": { + "type": "number", + "required": true + }, + "action": { + "type": "string" + }, + "creationDate": { + "type": "date" + }, + "description": { + "type": "string" + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "string" + }, + "newInstance": { + "type": "string" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + } + } +} diff --git a/modules/shelving/front/basic-data/index.html b/modules/shelving/front/basic-data/index.html index cf66cc917..68d61e169 100644 --- a/modules/shelving/front/basic-data/index.html +++ b/modules/shelving/front/basic-data/index.html @@ -11,7 +11,7 @@ diff --git a/modules/shelving/front/create/index.html b/modules/shelving/front/create/index.html index c462b54a6..edb3a7d3b 100644 --- a/modules/shelving/front/create/index.html +++ b/modules/shelving/front/create/index.html @@ -8,12 +8,33 @@
- - + + + + + + + + + + + + diff --git a/modules/shelving/front/create/index.js b/modules/shelving/front/create/index.js index bb0e441eb..22c28f496 100644 --- a/modules/shelving/front/create/index.js +++ b/modules/shelving/front/create/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section { onSubmit() { return this.$.watcher.submit().then(res => - this.$state.go('shelving.card.basicData', {id: res.data.id}) + this.$state.go('shelving.card.summary', {id: res.data.id}) ); } } diff --git a/modules/shelving/front/create/locale/es.yml b/modules/shelving/front/create/locale/es.yml deleted file mode 100644 index 31b7cd403..000000000 --- a/modules/shelving/front/create/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Name: Nombre -Tax number: NIF/CIF -Business name: Razón social -Web user: Usuario Web -Email: E-mail -Create and edit: Crear y editar -You can save multiple emails: >- - Puede guardar varios correos electrónicos encadenándolos mediante comas - sin espacios, ejemplo: user@dominio.com, user2@dominio.com siendo el primer - correo electrónico el principal -The type of business must be filled in basic data: El tipo de negocio debe estar rellenado en datos básicos diff --git a/modules/shelving/front/descriptor/index.html b/modules/shelving/front/descriptor/index.html index 7ec836ed4..1344bb52a 100644 --- a/modules/shelving/front/descriptor/index.html +++ b/modules/shelving/front/descriptor/index.html @@ -1,6 +1,6 @@ + value="{{$ctrl.shelving.code}}"> -
{{::shelving.id}}
-
{{::shelving.parking.code}}
-
{{::shelving.priority}}
+
{{::shelving.code}}
+ + + +
\ No newline at end of file diff --git a/modules/shelving/front/log/index.js b/modules/shelving/front/log/index.js new file mode 100644 index 000000000..588e0995a --- /dev/null +++ b/modules/shelving/front/log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnShelvingLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/shelving/front/main/index.html b/modules/shelving/front/main/index.html index 20e29b5f9..485ecd342 100644 --- a/modules/shelving/front/main/index.html +++ b/modules/shelving/front/main/index.html @@ -7,7 +7,7 @@ diff --git a/modules/shelving/front/main/index.js b/modules/shelving/front/main/index.js index 63c5689b1..96689fbd9 100644 --- a/modules/shelving/front/main/index.js +++ b/modules/shelving/front/main/index.js @@ -11,14 +11,10 @@ export default class Shelving extends ModuleMain { }; } - $onInit() { - console.log(this.$params); - } - exprBuilder(param, value) { switch (param) { case 'search': - return {id: {like: `%${value}%`}}; + return {code: {like: `%${value}%`}}; case 'parkingFk': case 'userFk': case 'isRecyclable': diff --git a/modules/shelving/front/main/locale/es.yml b/modules/shelving/front/main/locale/es.yml new file mode 100644 index 000000000..367908d36 --- /dev/null +++ b/modules/shelving/front/main/locale/es.yml @@ -0,0 +1 @@ +Search shelving by code, parking or worker: Busca matrículas por código, parking o trabajador \ No newline at end of file diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json index e51ff9d25..53fe8957a 100644 --- a/modules/shelving/front/routes.json +++ b/modules/shelving/front/routes.json @@ -2,7 +2,7 @@ "module": "shelving", "name": "Shelvings", "icon" : "contact_support", - "dependencies": [], + "dependencies": ["worker"], "validations" : true, "menus": { "main": [ diff --git a/modules/shelving/front/search-panel/locale/es.yml b/modules/shelving/front/search-panel/locale/es.yml index 77253a4ef..592ba0b0d 100644 --- a/modules/shelving/front/search-panel/locale/es.yml +++ b/modules/shelving/front/search-panel/locale/es.yml @@ -1,4 +1 @@ -Province: Provincia -Country: País -Tax number: NIF / CIF -Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias \ No newline at end of file +Search shelvings by code: Busca matriculas por código \ No newline at end of file diff --git a/modules/shelving/front/summary/index.html b/modules/shelving/front/summary/index.html index 8b193c3ee..61e44d278 100644 --- a/modules/shelving/front/summary/index.html +++ b/modules/shelving/front/summary/index.html @@ -1,12 +1,12 @@
- - {{::$ctrl.summary.id}} + {{::$ctrl.summary.code}}
@@ -20,7 +20,7 @@ + value="{{::$ctrl.summary.code}}"> {{$ctrl.summary.worker.user.nickname}} diff --git a/modules/shelving/front/summary/locale/es.yml b/modules/shelving/front/summary/locale/es.yml index 35291e579..d5d14d52a 100644 --- a/modules/shelving/front/summary/locale/es.yml +++ b/modules/shelving/front/summary/locale/es.yml @@ -1,12 +1,5 @@ -Verified: Verificado -Country: País -Tax number: NIF / CIF -Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias -Is Farmer: Es agrícola -Sage tax type: Tipo de impuesto Sage -Sage transaction type: Tipo de transacción Sage -Sage withholding: Retencion Sage -Go to the supplier: Ir al proveedor -Responsible: Responsable -Supplier activity: Actividad proveedor -Healt register: Pasaporte sanitario \ No newline at end of file +Code: Código +Parking: Parking +Priority: Prioridad +Worker: Trabajador +Recyclable: Reciclable \ No newline at end of file From c56ac1c192c347fc2bc5f52ccd9838be58514cd2 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 19 Jul 2022 13:35:17 +0200 Subject: [PATCH 07/15] feat: add log --- db/changes/10480-june/00-aclShelvingLog.sql | 3 +++ modules/shelving/back/model-config.json | 3 +++ .../{shelvingLog.json => shelving-log.json} | 22 ++++++++++++++----- modules/shelving/back/models/shelving.json | 6 ++++- modules/shelving/front/index.js | 1 + modules/shelving/front/log/index.html | 2 +- 6 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 db/changes/10480-june/00-aclShelvingLog.sql rename modules/shelving/back/models/{shelvingLog.json => shelving-log.json} (75%) diff --git a/db/changes/10480-june/00-aclShelvingLog.sql b/db/changes/10480-june/00-aclShelvingLog.sql new file mode 100644 index 000000000..dc75142d1 --- /dev/null +++ b/db/changes/10480-june/00-aclShelvingLog.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES + ('ShelvingLog','*','READ','ALLOW','ROLE','employee'); \ No newline at end of file diff --git a/modules/shelving/back/model-config.json b/modules/shelving/back/model-config.json index ff4164b31..b5619d8c5 100644 --- a/modules/shelving/back/model-config.json +++ b/modules/shelving/back/model-config.json @@ -4,5 +4,8 @@ }, "Shelving": { "dataSource": "vn" + }, + "ShelvingLog": { + "dataSource": "vn" } } diff --git a/modules/shelving/back/models/shelvingLog.json b/modules/shelving/back/models/shelving-log.json similarity index 75% rename from modules/shelving/back/models/shelvingLog.json rename to modules/shelving/back/models/shelving-log.json index 61eb0813f..fd30d8be8 100644 --- a/modules/shelving/back/models/shelvingLog.json +++ b/modules/shelving/back/models/shelving-log.json @@ -8,20 +8,20 @@ }, "properties": { "id": { - "type": "number", "id": true, - "description": "Identifier" + "type": "number", + "forceId": false }, "originFk": { "type": "string", "required": true }, "userFk": { - "type": "number", - "required": true + "type": "number" }, "action": { - "type": "string" + "type": "string", + "required": true }, "creationDate": { "type": "date" @@ -44,5 +44,15 @@ "changedModelValue": { "type": "string" } - } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } } diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index c7fcb2560..508ac428f 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -1,6 +1,10 @@ { "name": "Shelving", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ShelvingLog", + "showField": "id" + }, "options": { "mysql": { "table": "shelving" diff --git a/modules/shelving/front/index.js b/modules/shelving/front/index.js index df26602fc..2ad9bc1b9 100644 --- a/modules/shelving/front/index.js +++ b/modules/shelving/front/index.js @@ -8,3 +8,4 @@ import './index/'; import './main'; import './search-panel'; import './summary'; +import './log'; diff --git a/modules/shelving/front/log/index.html b/modules/shelving/front/log/index.html index e11d39a99..6ea349316 100644 --- a/modules/shelving/front/log/index.html +++ b/modules/shelving/front/log/index.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 7434532636af361a9d00a7c3a6446d05f9f07145 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 19 Jul 2022 13:38:06 +0200 Subject: [PATCH 08/15] feat: add translate --- modules/shelving/front/log/locale/es.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 modules/shelving/front/log/locale/es.yml diff --git a/modules/shelving/front/log/locale/es.yml b/modules/shelving/front/log/locale/es.yml new file mode 100644 index 000000000..c572b78d1 --- /dev/null +++ b/modules/shelving/front/log/locale/es.yml @@ -0,0 +1 @@ +Changed by: Cambiado por \ No newline at end of file From 771c86ba4b98848d9560bca023e1edaf7ae0b9d7 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 20 Jul 2022 12:40:30 +0200 Subject: [PATCH 09/15] fix: shelving log --- db/changes/10480-june/00-shelving.sql | 4 + .../shelving/back/models/shelving-log.json | 74 +++++++++---------- modules/shelving/front/log/index.html | 2 +- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/db/changes/10480-june/00-shelving.sql b/db/changes/10480-june/00-shelving.sql index 045698e8f..c66d164c4 100644 --- a/db/changes/10480-june/00-shelving.sql +++ b/db/changes/10480-june/00-shelving.sql @@ -12,3 +12,7 @@ ALTER TABLE `vn`.`itemShelving` ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (she ALTER TABLE `vn`.`shelvingLog` ADD CONSTRAINT shelvingLog_FK_ibfk_1 FOREIGN KEY (originFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `vn`.`smartTag` ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE `vn`.`workerShelving` ADD CONSTRAINT workerShelving_FK_1 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE vn.shelvingLog DROP FOREIGN KEY shelvingLog_FK_ibfk_1; +ALTER TABLE vn.shelvingLog MODIFY COLUMN originFk INT NOT NULL; +ALTER TABLE vn.shelvingLog ADD CONSTRAINT shelvingLog_FK FOREIGN KEY (originFk) REFERENCES vn.shelving(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/modules/shelving/back/models/shelving-log.json b/modules/shelving/back/models/shelving-log.json index fd30d8be8..a2267394e 100644 --- a/modules/shelving/back/models/shelving-log.json +++ b/modules/shelving/back/models/shelving-log.json @@ -6,45 +6,45 @@ "table": "shelvingLog" } }, - "properties": { - "id": { - "id": true, - "type": "number", + "properties": { + "id": { + "id": true, + "type": "number", "forceId": false - }, - "originFk": { - "type": "string", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", + }, + "originFk": { + "type": "number", "required": true - }, - "creationDate": { - "type": "date" - }, - "description": { - "type": "string" - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "string" - }, - "newInstance": { - "type": "string" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - } - }, + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, "relations": { "user": { "type": "belongsTo", diff --git a/modules/shelving/front/log/index.html b/modules/shelving/front/log/index.html index 6ea349316..8f0e6851c 100644 --- a/modules/shelving/front/log/index.html +++ b/modules/shelving/front/log/index.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From af4e7be229754634c231ace8ae8d5d55762919e2 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 20 Jul 2022 13:41:33 +0200 Subject: [PATCH 10/15] feat: add frontTest --- modules/shelving/front/card/index.spec.js | 26 ++++ modules/shelving/front/create/index.js | 2 +- modules/shelving/front/create/index.spec.js | 123 +++--------------- .../shelving/front/descriptor/index.spec.js | 61 ++------- modules/shelving/front/index/index.spec.js | 39 ++++++ modules/shelving/front/main/index.spec.js | 19 +++ modules/shelving/front/summary/index.spec.js | 32 ----- 7 files changed, 113 insertions(+), 189 deletions(-) create mode 100644 modules/shelving/front/card/index.spec.js create mode 100644 modules/shelving/front/index/index.spec.js create mode 100644 modules/shelving/front/main/index.spec.js delete mode 100644 modules/shelving/front/summary/index.spec.js diff --git a/modules/shelving/front/card/index.spec.js b/modules/shelving/front/card/index.spec.js new file mode 100644 index 000000000..85b1bd269 --- /dev/null +++ b/modules/shelving/front/card/index.spec.js @@ -0,0 +1,26 @@ +import './index'; + +describe('component vnShelvingCard', () => { + let controller; + let $httpBackend; + const data = {id: 1, code: 'AAA'}; + + beforeEach(ngModule('shelving')); + + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { + $httpBackend = _$httpBackend_; + + let $element = angular.element('
'); + controller = $componentController('vnShelvingCard', {$element}); + + $stateParams.id = data.id; + $httpBackend.whenRoute('GET', 'Shelvings/:id').respond(data); + })); + + it('should reload the controller data', () => { + controller.reload(); + $httpBackend.flush(); + + expect(controller.shelving).toEqual(data); + }); +}); diff --git a/modules/shelving/front/create/index.js b/modules/shelving/front/create/index.js index 22c28f496..bb0e441eb 100644 --- a/modules/shelving/front/create/index.js +++ b/modules/shelving/front/create/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section { onSubmit() { return this.$.watcher.submit().then(res => - this.$state.go('shelving.card.summary', {id: res.data.id}) + this.$state.go('shelving.card.basicData', {id: res.data.id}) ); } } diff --git a/modules/shelving/front/create/index.spec.js b/modules/shelving/front/create/index.spec.js index 24fc80d21..1642afc52 100644 --- a/modules/shelving/front/create/index.spec.js +++ b/modules/shelving/front/create/index.spec.js @@ -1,121 +1,28 @@ import './index'; +import watcher from 'core/mocks/watcher'; -describe('Client', () => { - describe('Component vnClientCreate', () => { - let $scope; - let $state; +fdescribe('Shelving', () => { + describe('Component vnShelvingCreate', () => { let controller; + let $element; - beforeEach(ngModule('client')); + beforeEach(ngModule('shelving')); - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = { - submit: () => { - return { - then: callback => { - callback({data: {id: '1234'}}); - } - }; - } - }; - const $element = angular.element(''); - controller = $componentController('vnClientCreate', {$element, $scope}); + beforeEach(inject(($componentController, $rootScope) => { + const $scope = $rootScope.$new(); + $scope.watcher = watcher; + $element = angular.element(''); + controller = $componentController('vnShelvingCreate', {$element, $scope}); + controller.$params = {}; })); - it('should define and set scope, state and client properties', () => { - expect(controller.$).toBe($scope); - expect(controller.$state).toBe($state); - expect(controller.client.active).toBe(true); - }); - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); + it(`should redirect to basic data by calling the $state.go function`, () => { + jest.spyOn(controller.$state, 'go'); + controller.onSubmit(); - expect(controller.$state.go).toHaveBeenCalledWith('client.card.basicData', {id: '1234'}); - }); - }); - - describe('province() setter', () => { - it(`should set countryFk property`, () => { - controller.client.countryFk = null; - controller.province = { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }; - - expect(controller.client.countryFk).toEqual(2); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.client.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.client.provinceFk).toEqual(1); - expect(controller.client.postcode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town, provinceFk and contryFk properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.client.city).toEqual('New York'); - expect(controller.client.provinceFk).toEqual(1); - expect(controller.client.countryFk).toEqual(2); + expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1234}); }); }); }); diff --git a/modules/shelving/front/descriptor/index.spec.js b/modules/shelving/front/descriptor/index.spec.js index 8926fa4d1..3ee33580b 100644 --- a/modules/shelving/front/descriptor/index.spec.js +++ b/modules/shelving/front/descriptor/index.spec.js @@ -1,64 +1,29 @@ import './index.js'; -describe('Supplier Component vnSupplierDescriptor', () => { +describe('component vnShelvingDescriptor', () => { let $httpBackend; let controller; - let $httpParamSerializer; - const supplier = {id: 1}; - beforeEach(ngModule('supplier')); + const shelving = {id: 1, code: 'AA6'}; + + beforeEach(ngModule('shelving')); beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier}); + controller = $componentController('vnShelvingDescriptor', {$element: null}, {shelving}); + jest.spyOn(controller.vnApp, 'showSuccess'); })); - describe('loadData()', () => { - it('should perform ask for the supplier', () => { - const filter = { - fields: [ - 'id', - 'name', - 'nickname', - 'nif', - 'payMethodFk', - 'payDemFk', - 'payDay', - 'isActive', - 'isSerious', - 'account' - ], - include: [ - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - const serializedParams = $httpParamSerializer({filter}); - let query = `Suppliers/${controller.supplier.id}?${serializedParams}`; - jest.spyOn(controller, 'getData'); + describe('onDelete()', () => { + it('should delete entity and go to index', () => { + controller.$state.go = jest.fn(); - $httpBackend.expect('GET', query).respond({id: 1}); - controller.loadData(); + $httpBackend.expectDELETE('Shelvings/1').respond(); + controller.onDelete(); $httpBackend.flush(); - expect(controller.getData).toHaveBeenCalledTimes(1); + expect(controller.$state.go).toHaveBeenCalledWith('shelving.index'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); }); diff --git a/modules/shelving/front/index/index.spec.js b/modules/shelving/front/index/index.spec.js new file mode 100644 index 000000000..aad79fb0e --- /dev/null +++ b/modules/shelving/front/index/index.spec.js @@ -0,0 +1,39 @@ +import './index.js'; +describe('Component vnShelvingIndex', () => { + let controller; + let $window; + let shelvings = [{ + id: 1, + code: 'AAA' + }, { + id: 2, + code: 'AA1' + }, { + id: 3, + code: 'AA2' + }]; + + beforeEach(ngModule('shelving')); + + beforeEach(inject(($componentController, _$window_) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnShelvingIndex', {$element}); + })); + + describe('preview()', () => { + it('should show the dialog summary', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + let event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.preview(event, shelvings[0]); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/modules/shelving/front/main/index.spec.js b/modules/shelving/front/main/index.spec.js new file mode 100644 index 000000000..dcfa912bc --- /dev/null +++ b/modules/shelving/front/main/index.spec.js @@ -0,0 +1,19 @@ +import './index'; + +describe('component vnShelving', () => { + let controller; + + beforeEach(ngModule('shelving')); + + beforeEach(inject($componentController => { + controller = $componentController('vnShelving', {$element: null}); + })); + + describe('exprBuilder()', () => { + it('should search by code', () => { + let expr = controller.exprBuilder('search', 'UXN'); + + expect(expr).toEqual({code: {like: '%UXN%'}},); + }); + }); +}); diff --git a/modules/shelving/front/summary/index.spec.js b/modules/shelving/front/summary/index.spec.js deleted file mode 100644 index aa44cd14f..000000000 --- a/modules/shelving/front/summary/index.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import './index'; - -describe('Supplier', () => { - describe('Component vnSupplierSummary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnSupplierSummary', {$element, $scope}); - })); - - describe('getSummary()', () => { - it('should perform a get asking for the supplier data', () => { - controller.supplier = {id: 1}; - - const query = `Suppliers/${controller.supplier.id}/getSummary`; - - $httpBackend.expectGET(query).respond({id: 1}); - controller.getSummary(); - $httpBackend.flush(); - - expect(controller.summary).toEqual({id: 1}); - }); - }); - }); -}); From 26f8996936396ea2a966fde0349035d380fd632d Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 20 Jul 2022 14:02:15 +0200 Subject: [PATCH 11/15] refactor: set vn-focus and move sql to new folder --- db/changes/{10470-family => 10480-june}/04-aclParking.sql | 0 db/changes/{10470-family => 10480-june}/04-aclShelving.sql | 0 modules/shelving/front/basic-data/locale/es.yml | 5 ----- modules/shelving/front/main/index.html | 1 + 4 files changed, 1 insertion(+), 5 deletions(-) rename db/changes/{10470-family => 10480-june}/04-aclParking.sql (100%) rename db/changes/{10470-family => 10480-june}/04-aclShelving.sql (100%) delete mode 100644 modules/shelving/front/basic-data/locale/es.yml diff --git a/db/changes/10470-family/04-aclParking.sql b/db/changes/10480-june/04-aclParking.sql similarity index 100% rename from db/changes/10470-family/04-aclParking.sql rename to db/changes/10480-june/04-aclParking.sql diff --git a/db/changes/10470-family/04-aclShelving.sql b/db/changes/10480-june/04-aclShelving.sql similarity index 100% rename from db/changes/10470-family/04-aclShelving.sql rename to db/changes/10480-june/04-aclShelving.sql diff --git a/modules/shelving/front/basic-data/locale/es.yml b/modules/shelving/front/basic-data/locale/es.yml deleted file mode 100644 index e965ffc2e..000000000 --- a/modules/shelving/front/basic-data/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Notes: Notas -Active: Activo -Verified: Verificado -PayMethodChecked: Método de pago validado -Responsible for approving invoices: Responsable de aprobar las facturas \ No newline at end of file diff --git a/modules/shelving/front/main/index.html b/modules/shelving/front/main/index.html index 485ecd342..3f3cc718b 100644 --- a/modules/shelving/front/main/index.html +++ b/modules/shelving/front/main/index.html @@ -6,6 +6,7 @@ Date: Wed, 27 Jul 2022 13:01:03 +0200 Subject: [PATCH 12/15] fix: update frontTest --- modules/shelving/front/create/index.spec.js | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/shelving/front/create/index.spec.js b/modules/shelving/front/create/index.spec.js index 1642afc52..0bdde9145 100644 --- a/modules/shelving/front/create/index.spec.js +++ b/modules/shelving/front/create/index.spec.js @@ -1,17 +1,26 @@ import './index'; -import watcher from 'core/mocks/watcher'; -fdescribe('Shelving', () => { +describe('Shelving', () => { describe('Component vnShelvingCreate', () => { + let $scope; + let $state; let controller; - let $element; beforeEach(ngModule('shelving')); - beforeEach(inject(($componentController, $rootScope) => { - const $scope = $rootScope.$new(); - $scope.watcher = watcher; - $element = angular.element(''); + beforeEach(inject(($componentController, $rootScope, _$state_) => { + $scope = $rootScope.$new(); + $state = _$state_; + $scope.watcher = { + submit: () => { + return { + then: callback => { + callback({data: {id: 1}}); + } + }; + } + }; + const $element = angular.element(''); controller = $componentController('vnShelvingCreate', {$element, $scope}); controller.$params = {}; })); @@ -22,7 +31,7 @@ fdescribe('Shelving', () => { controller.onSubmit(); - expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1234}); + expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1}); }); }); }); From 84036d582fcf56de2cba88c87e81a50662387de9 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 29 Jul 2022 13:42:52 +0200 Subject: [PATCH 13/15] fic: delete unnecessary acl --- modules/shelving/front/routes.json | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json index 53fe8957a..b99ca4cac 100644 --- a/modules/shelving/front/routes.json +++ b/modules/shelving/front/routes.json @@ -56,7 +56,6 @@ "state": "shelving.card.basicData", "component": "vn-shelving-basic-data", "description": "Basic data", - "acl": ["administrative"], "params": { "shelving": "$ctrl.shelving" } From 990fe17f487b1ff26092fefabe85a3373d294c30 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 29 Jul 2022 13:42:59 +0200 Subject: [PATCH 14/15] fix: correct transalte --- modules/shelving/front/search-panel/locale/es.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shelving/front/search-panel/locale/es.yml b/modules/shelving/front/search-panel/locale/es.yml index 592ba0b0d..bd19b1b33 100644 --- a/modules/shelving/front/search-panel/locale/es.yml +++ b/modules/shelving/front/search-panel/locale/es.yml @@ -1 +1 @@ -Search shelvings by code: Busca matriculas por código \ No newline at end of file +Search shelvings by code: Busca carros por código \ No newline at end of file From 83e5a01649e5be0cf2844c53f8a52d2ccf2283ee Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 29 Jul 2022 13:47:42 +0200 Subject: [PATCH 15/15] fix: correct translation --- modules/shelving/front/main/locale/es.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shelving/front/main/locale/es.yml b/modules/shelving/front/main/locale/es.yml index 367908d36..4c39469ce 100644 --- a/modules/shelving/front/main/locale/es.yml +++ b/modules/shelving/front/main/locale/es.yml @@ -1 +1 @@ -Search shelving by code, parking or worker: Busca matrículas por código, parking o trabajador \ No newline at end of file +Search shelving by code, parking or worker: Busca carros por código, parking o trabajador \ No newline at end of file