From a19064cb1b6088c491630caced5428081865ceec Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 12:23:37 +0100 Subject: [PATCH 1/4] Nueva tabla entryObservation y he juntado la consulta de 1260-navidad con 1260-holydays --- db/changes/10260-holidays/00-ACL.sql | 3 ++- db/changes/10260-holidays/00-entryObservation.sql | 11 +++++++++++ db/changes/10260-navidad/00-acl.sql | 2 -- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/changes/10260-holidays/00-entryObservation.sql delete mode 100644 db/changes/10260-navidad/00-acl.sql diff --git a/db/changes/10260-holidays/00-ACL.sql b/db/changes/10260-holidays/00-ACL.sql index 1f8045bc7..e72e6fa73 100644 --- a/db/changes/10260-holidays/00-ACL.sql +++ b/db/changes/10260-holidays/00-ACL.sql @@ -1 +1,2 @@ -INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES ('Image', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee') \ No newline at end of file +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES ('Image', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('PayDem', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10260-holidays/00-entryObservation.sql b/db/changes/10260-holidays/00-entryObservation.sql new file mode 100644 index 000000000..f72d64b01 --- /dev/null +++ b/db/changes/10260-holidays/00-entryObservation.sql @@ -0,0 +1,11 @@ +CREATE TABLE `vn`.`entryObservation` ( + id int NOT NULL AUTO_INCREMENT, + entryFk int NOT NULL, + observationTypeFk TINYINT(3) UNSIGNED, + description TEXT, + PRIMARY KEY (id), + CONSTRAINT entry_id_entryFk + FOREIGN KEY (entryFk) REFERENCES entry(id), + CONSTRAINT observationType_id_observationTypeFk + FOREIGN KEY (observationTypeFk) REFERENCES observationType(id) +); \ No newline at end of file diff --git a/db/changes/10260-navidad/00-acl.sql b/db/changes/10260-navidad/00-acl.sql deleted file mode 100644 index 9fba4786b..000000000 --- a/db/changes/10260-navidad/00-acl.sql +++ /dev/null @@ -1,2 +0,0 @@ - INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES ('PayDem', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); From 2948747da3497c2f016b74481f84852bc9390243 Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 12:25:12 +0100 Subject: [PATCH 2/4] Seccion nueva, "Note" mas campo entryObservation --- modules/entry/back/model-config.json | 3 + .../entry/back/models/entry-observation.js | 9 +++ .../entry/back/models/entry-observation.json | 38 ++++++++++ modules/entry/front/index.js | 1 + modules/entry/front/note/index.html | 72 +++++++++++++++++++ modules/entry/front/note/index.js | 20 ++++++ modules/entry/front/routes.json | 11 ++- 7 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 modules/entry/back/models/entry-observation.js create mode 100644 modules/entry/back/models/entry-observation.json create mode 100644 modules/entry/front/note/index.html create mode 100644 modules/entry/front/note/index.js diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 0e37b947f..eddef9c41 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -7,5 +7,8 @@ }, "EntryLog": { "dataSource": "vn" + }, + "EntryObservation": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/entry-observation.js b/modules/entry/back/models/entry-observation.js new file mode 100644 index 000000000..77d15d85c --- /dev/null +++ b/modules/entry/back/models/entry-observation.js @@ -0,0 +1,9 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`The observation type can't be repeated`); + return err; + }); +}; diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json new file mode 100644 index 000000000..87d3fd964 --- /dev/null +++ b/modules/entry/back/models/entry-observation.json @@ -0,0 +1,38 @@ +{ + "name": "EntryObservation", + "base": "Loggable", + "log": { + "model": "EntryLog", + "relation": "entry" + }, + "options": { + "mysql": { + "table": "entryObservation" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + } + }, + "relations": { + "entry": { + "type": "belongsTo", + "model": "Entry", + "foreignKey": "entryFk", + "required": true + }, + "observationType": { + "type": "belongsTo", + "model": "ObservationType", + "foreignKey": "observationTypeFk", + "required": true + } + } +} diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index e92f23fc1..14aecc8db 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -10,6 +10,7 @@ import './latest-buys-search-panel'; import './descriptor'; import './descriptor-popover'; import './card'; +import './note'; import './summary'; import './log'; import './buy'; diff --git a/modules/entry/front/note/index.html b/modules/entry/front/note/index.html new file mode 100644 index 000000000..5f3c7f77e --- /dev/null +++ b/modules/entry/front/note/index.html @@ -0,0 +1,72 @@ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/entry/front/note/index.js b/modules/entry/front/note/index.js new file mode 100644 index 000000000..fccd60913 --- /dev/null +++ b/modules/entry/front/note/index.js @@ -0,0 +1,20 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + }); + } +} + +ngModule.vnComponent('vnEntryObservation', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index a430a95fa..010e738b3 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -12,6 +12,7 @@ "card": [ {"state": "entry.card.basicData", "icon": "settings"}, {"state": "entry.card.buy", "icon": "icon-lines"}, + {"state": "entry.card.observation", "icon": "insert_drive_file"}, {"state": "entry.card.log", "icon": "history"} ] }, @@ -61,7 +62,15 @@ "params": { "entry": "$ctrl.entry" } - }, { + },{ + "url": "/observation", + "state": "entry.card.observation", + "component": "vn-entry-observation", + "description": "Notes", + "params": { + "entry": "$ctrl.entry" + } + },{ "url" : "/log", "state": "entry.card.log", "component": "vn-entry-log", From 3517bdea415feb31b282ced953e66e90f94141ec Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 13:31:55 +0100 Subject: [PATCH 3/4] =?UTF-8?q?A=C3=B1adido=20a=20las=20foreignKeys=20el?= =?UTF-8?q?=20valor=20UNIQUE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/10260-holidays/00-entryObservation.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/changes/10260-holidays/00-entryObservation.sql b/db/changes/10260-holidays/00-entryObservation.sql index f72d64b01..6184cf3bd 100644 --- a/db/changes/10260-holidays/00-entryObservation.sql +++ b/db/changes/10260-holidays/00-entryObservation.sql @@ -8,4 +8,7 @@ CREATE TABLE `vn`.`entryObservation` ( FOREIGN KEY (entryFk) REFERENCES entry(id), CONSTRAINT observationType_id_observationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES observationType(id) -); \ No newline at end of file +); + +ALTER TABLE `vn`.`entryObservation` +ADD UNIQUE INDEX `entryFk_observationTypeFk_UNIQUE` (`entryFk` ASC,`observationTypeFk` ASC); \ No newline at end of file From 259842c22de493210ffba283a7826ef5fd4a5bf8 Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 13:32:58 +0100 Subject: [PATCH 4/4] Retirado el parametro required por no utilizarse --- modules/entry/back/models/entry-observation.json | 3 +-- modules/ticket/back/models/ticket-observation.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json index 87d3fd964..535735d83 100644 --- a/modules/entry/back/models/entry-observation.json +++ b/modules/entry/back/models/entry-observation.json @@ -25,8 +25,7 @@ "entry": { "type": "belongsTo", "model": "Entry", - "foreignKey": "entryFk", - "required": true + "foreignKey": "entryFk" }, "observationType": { "type": "belongsTo", diff --git a/modules/ticket/back/models/ticket-observation.json b/modules/ticket/back/models/ticket-observation.json index 51469c7a6..ba4f85ce8 100644 --- a/modules/ticket/back/models/ticket-observation.json +++ b/modules/ticket/back/models/ticket-observation.json @@ -25,8 +25,7 @@ "ticket": { "type": "belongsTo", "model": "Ticket", - "foreignKey": "ticketFk", - "required": true + "foreignKey": "ticketFk" }, "observationType": { "type": "belongsTo",