From b0bed3c1c4974f03b599eb31efba049fbec0d14f Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 3 Jun 2021 16:14:52 +0200 Subject: [PATCH] invoiceInLog section, model and table --- db/changes/10330-jun2021/00-invoiceInLog.sql | 18 ++++++ db/changes/10330-jun2021/deleteMe.keep | 1 - modules/entry/back/models/entry.json | 2 +- modules/entry/front/routes.json | 24 +++++--- modules/invoiceIn/back/model-config.json | 3 + .../invoiceIn/back/models/invoice-in-log.json | 61 +++++++++++++++++++ modules/invoiceIn/back/models/invoice-in.json | 5 +- modules/invoiceIn/front/index.js | 1 + modules/invoiceIn/front/log/index.html | 1 + modules/invoiceIn/front/log/index.js | 7 +++ modules/invoiceIn/front/routes.json | 14 ++++- 11 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 db/changes/10330-jun2021/00-invoiceInLog.sql delete mode 100644 db/changes/10330-jun2021/deleteMe.keep create mode 100644 modules/invoiceIn/back/models/invoice-in-log.json create mode 100644 modules/invoiceIn/front/log/index.html create mode 100644 modules/invoiceIn/front/log/index.js diff --git a/db/changes/10330-jun2021/00-invoiceInLog.sql b/db/changes/10330-jun2021/00-invoiceInLog.sql new file mode 100644 index 000000000..899c6c63f --- /dev/null +++ b/db/changes/10330-jun2021/00-invoiceInLog.sql @@ -0,0 +1,18 @@ +CREATE TABLE `vn`.`invoiceInLog` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `originFk` MEDIUMINT UNSIGNED NOT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `invoiceInLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceInLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/changes/10330-jun2021/deleteMe.keep b/db/changes/10330-jun2021/deleteMe.keep deleted file mode 100644 index 5b815cc65..000000000 --- a/db/changes/10330-jun2021/deleteMe.keep +++ /dev/null @@ -1 +0,0 @@ -Delete me!! \ No newline at end of file diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index 78d3c5e4f..d8bd079a2 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -6,7 +6,7 @@ }, "options": { "mysql": { - "table": "entry" + "table": "entry" } }, "properties": { diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index c9f0efffd..37dda7584 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -26,30 +26,35 @@ "abstract": true, "component": "vn-entry", "description": "Entries" - }, { + }, + { "url": "/index?q", "state": "entry.index", "component": "vn-entry-index", "description": "Entries", "acl": ["buyer", "administrative"] - }, { + }, + { "url": "/latest-buys?q", "state": "entry.latestBuys", "component": "vn-entry-latest-buys", "description": "Latest buys", "acl": ["buyer", "administrative"] - }, { + }, + { "url": "/create?supplierFk&travelFk&companyFk", "state": "entry.create", "component": "vn-entry-create", "description": "New entry", "acl": ["buyer", "administrative"] - }, { + }, + { "url": "/:id", "state": "entry.card", "abstract": true, "component": "vn-entry-card" - }, { + }, + { "url": "/summary", "state": "entry.card.summary", "component": "vn-entry-summary", @@ -58,7 +63,8 @@ "entry": "$ctrl.entry" }, "acl": ["buyer", "administrative"] - }, { + }, + { "url": "/basic-data", "state": "entry.card.basicData", "component": "vn-entry-basic-data", @@ -67,7 +73,8 @@ "entry": "$ctrl.entry" }, "acl": ["buyer", "administrative"] - },{ + }, + { "url": "/observation", "state": "entry.card.observation", "component": "vn-entry-observation", @@ -76,7 +83,8 @@ "entry": "$ctrl.entry" }, "acl": ["buyer", "administrative"] - },{ + }, + { "url" : "/log", "state": "entry.card.log", "component": "vn-entry-log", diff --git a/modules/invoiceIn/back/model-config.json b/modules/invoiceIn/back/model-config.json index 88d227ba3..467d6f7f9 100644 --- a/modules/invoiceIn/back/model-config.json +++ b/modules/invoiceIn/back/model-config.json @@ -4,5 +4,8 @@ }, "InvoiceInDueDay": { "dataSource": "vn" + }, + "InvoiceInLog": { + "dataSource": "vn" } } diff --git a/modules/invoiceIn/back/models/invoice-in-log.json b/modules/invoiceIn/back/models/invoice-in-log.json new file mode 100644 index 000000000..a5d0cba56 --- /dev/null +++ b/modules/invoiceIn/back/models/invoice-in-log.json @@ -0,0 +1,61 @@ +{ + "name": "InvoiceInLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceInLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": [ + "creationDate DESC", + "id DESC" + ] + } +} \ No newline at end of file diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json index ad14fb511..7b0c3315a 100644 --- a/modules/invoiceIn/back/models/invoice-in.json +++ b/modules/invoiceIn/back/models/invoice-in.json @@ -1,6 +1,9 @@ { "name": "InvoiceIn", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "InvoiceInLog" + }, "options": { "mysql": { "table": "invoiceIn" diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index 6c175d9a0..2102b338f 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -8,3 +8,4 @@ import './descriptor'; import './descriptor-popover'; import './summary'; import './basic-data'; +import './log'; diff --git a/modules/invoiceIn/front/log/index.html b/modules/invoiceIn/front/log/index.html new file mode 100644 index 000000000..2cfc9dfb1 --- /dev/null +++ b/modules/invoiceIn/front/log/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/invoiceIn/front/log/index.js b/modules/invoiceIn/front/log/index.js new file mode 100644 index 000000000..7a018de0f --- /dev/null +++ b/modules/invoiceIn/front/log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnInvoiceInLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index 05eff347b..5f842f760 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -12,6 +12,10 @@ { "state": "invoiceIn.card.basicData", "icon": "settings" + }, + { + "state": "invoiceIn.card.log", + "icon": "history" } ] }, @@ -53,7 +57,15 @@ "description": "Basic data", "params": { "invoice-in": "$ctrl.invoiceIn" - } + }, + "acl": ["administrative"] + }, + { + "url": "/log", + "state": "invoiceIn.card.log", + "component": "vn-invoice-in-log", + "description": "Log", + "acl": ["administrative"] } ] } \ No newline at end of file