From 77bc1b562ee6ffb92919a62c12d6d7e6d35c825f Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Wed, 28 Oct 2020 09:08:27 +0100 Subject: [PATCH 1/3] create section supplier log --- db/changes/10240-allSaints/00-supplierLog.sql | 20 +++++++ db/dump/fixtures.sql | 8 +-- .../supplier/back/models/supplier-log.json | 58 +++++++++++++++++++ modules/supplier/back/models/supplier.json | 5 +- modules/supplier/front/index.js | 1 + modules/supplier/front/log/index.html | 1 + modules/supplier/front/log/index.js | 7 +++ modules/supplier/front/routes.json | 5 ++ 8 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 db/changes/10240-allSaints/00-supplierLog.sql create mode 100644 modules/supplier/back/models/supplier-log.json create mode 100644 modules/supplier/front/log/index.html create mode 100644 modules/supplier/front/log/index.js diff --git a/db/changes/10240-allSaints/00-supplierLog.sql b/db/changes/10240-allSaints/00-supplierLog.sql new file mode 100644 index 0000000000..5ab76ac37b --- /dev/null +++ b/db/changes/10240-allSaints/00-supplierLog.sql @@ -0,0 +1,20 @@ +CREATE TABLE `vn`.`supplierLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT 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 `logSupplier_ibfk_1` (`originFk`), + KEY `supplierLog_ibfk_2` (`userFk`), + CONSTRAINT `supplierLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `supplierLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + + diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0bee9cf65a..b780952e1e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1208,11 +1208,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `phone`, `payDay`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `transactionTypeSageFk`) VALUES - (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 123456789, 15), - (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 987654321, 10), - (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 987123654, 15); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, 'A11111111', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, NULL, NULL), + (2, 'Farmer King', 'The farmer', 4000020002, 1, 'B22222222', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 8), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, 'C33333333', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, NULL, NULL); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/modules/supplier/back/models/supplier-log.json b/modules/supplier/back/models/supplier-log.json new file mode 100644 index 0000000000..9b66bdf740 --- /dev/null +++ b/modules/supplier/back/models/supplier-log.json @@ -0,0 +1,58 @@ +{ + "name": "SupplierLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "supplierLog" + } + }, + "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/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 41fc9c45cc..0a9d4846b5 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -1,6 +1,9 @@ { "name": "Supplier", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"SupplierLog" + }, "options": { "mysql": { "table": "supplier" diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index cb25b3b8ca..51550fccdf 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -3,3 +3,4 @@ export * from './module'; import './main'; import './index/'; import './search-panel'; +import './log'; diff --git a/modules/supplier/front/log/index.html b/modules/supplier/front/log/index.html new file mode 100644 index 0000000000..7895b585e1 --- /dev/null +++ b/modules/supplier/front/log/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/supplier/front/log/index.js b/modules/supplier/front/log/index.js new file mode 100644 index 0000000000..52a491c708 --- /dev/null +++ b/modules/supplier/front/log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnSupplierLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 21f1ceb263..e1ad0c5d1c 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -22,6 +22,11 @@ "state": "supplier.index", "component": "vn-supplier-index", "description": "Suppliers" + }, { + "url" : "/log", + "state": "supplier.card.log", + "component": "vn-supplier-log", + "description": "Log" } ] } \ No newline at end of file From ea6fc0fb0472a24b6efd1db3144494a121ec30ca Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 30 Oct 2020 07:23:21 +0100 Subject: [PATCH 2/3] Card fix --- modules/supplier/front/card/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/front/card/index.html b/modules/supplier/front/card/index.html index 11908bce0b..2c3c9df362 100644 --- a/modules/supplier/front/card/index.html +++ b/modules/supplier/front/card/index.html @@ -1,5 +1,5 @@ - + From ea8d9e70b0dbd8b2d2c43266a063ca35be17830a Mon Sep 17 00:00:00 2001 From: bernat Date: Fri, 30 Oct 2020 08:27:02 +0100 Subject: [PATCH 3/3] supplier log --- db/dump/fixtures.sql | 7 +------ e2e/paths/12-entry/01_summary.spec.js | 4 ++-- modules/supplier/back/model-config.json | 3 +++ modules/supplier/front/index.js | 4 ++-- modules/supplier/front/routes.json | 10 ++++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5ae2bda018..6bf5ee8fe0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1210,14 +1210,9 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `transactionTypeSageFk`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, 'A11111111', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, NULL, NULL), + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, NULL, NULL), (2, 'Farmer King', 'The farmer', 4000020002, 1, 'B22222222', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 8), (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, 'C33333333', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, NULL, NULL); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`) - VALUES - (1, 'Plants SL', 'Plants nick', 4000000001, 1, '06089160W', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15), - (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 10), - (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js index a6ac8dab12..b846bc4c89 100644 --- a/e2e/paths/12-entry/01_summary.spec.js +++ b/e2e/paths/12-entry/01_summary.spec.js @@ -21,10 +21,10 @@ describe('Entry summary path', () => { }); it(`should display details from the entry on the header`, async() => { - await page.waitForTextInElement(selectors.entrySummary.header, 'The king'); + await page.waitForTextInElement(selectors.entrySummary.header, 'The farmer'); const result = await page.waitToGetProperty(selectors.entrySummary.header, 'innerText'); - expect(result).toContain('The king'); + expect(result).toContain('The farmer'); }); it('should display some entry details like the reference', async() => { diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json index 9c2f8f391f..c1963a8cf2 100644 --- a/modules/supplier/back/model-config.json +++ b/modules/supplier/back/model-config.json @@ -4,5 +4,8 @@ }, "PayDem": { "dataSource": "vn" + }, + "SupplierLog": { + "dataSource": "vn" } } diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index c33fb931e0..a4017bbd98 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -1,9 +1,9 @@ export * from './module'; import './main'; +import './card'; +import './descriptor'; import './index/'; import './search-panel'; import './log'; import './summary'; -import './card'; -import './descriptor'; diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 7fe8fe0b78..24e8d86925 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -9,6 +9,7 @@ {"state": "supplier.index", "icon": "icon-supplier"} ], "card": [ + {"state": "supplier.card.log", "icon": "history"} ] }, "routes": [ @@ -24,10 +25,6 @@ "component": "vn-supplier-index", "description": "Suppliers" }, { - "url" : "/log", - "state": "supplier.card.log", - "component": "vn-supplier-log", - "description": "Log" "url": "/:id", "state": "supplier.card", "abstract": true, @@ -40,6 +37,11 @@ "params": { "supplier": "$ctrl.supplier" } + }, { + "url" : "/log", + "state": "supplier.card.log", + "component": "vn-supplier-log", + "description": "Log" } ] } \ No newline at end of file