From 7200aa3dfc2762a93668c86487a492bb7fa7b281 Mon Sep 17 00:00:00 2001 From: bernat Date: Fri, 30 Oct 2020 10:23:42 +0100 Subject: [PATCH 1/6] fixtures and sql for supplierContact --- .../10240-allSaints/00-supplier_contact.sql | 24 +++++++++++++++++++ db/dump/fixtures.sql | 7 ++++++ 2 files changed, 31 insertions(+) create mode 100644 db/changes/10240-allSaints/00-supplier_contact.sql diff --git a/db/changes/10240-allSaints/00-supplier_contact.sql b/db/changes/10240-allSaints/00-supplier_contact.sql new file mode 100644 index 0000000000..5054366b0f --- /dev/null +++ b/db/changes/10240-allSaints/00-supplier_contact.sql @@ -0,0 +1,24 @@ +CREATE TABLE `vn`.`supplierContact` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `supplierFk` INT(11) NULL DEFAULT NULL, + `phone` VARCHAR(16) NULL DEFAULT NULL, + `mobile` VARCHAR(16) NULL DEFAULT NULL, + `email` VARCHAR(255) NULL DEFAULT NULL, + `observation` TEXT NULL DEFAULT NULL, + `name` VARCHAR(255) NULL DEFAULT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +ALTER TABLE `vn`.`supplierContact` +ADD CONSTRAINT `supplier_id` + FOREIGN KEY (`supplierFk`) + REFERENCES `vn`.`supplier` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO vn.supplierContact(supplierFk,phone,mobile,email,observation,`name`) + SELECT r.Id_Proveedor,c.Telefono,c.Movil,c.email,c.Notas,concat(c.Nombre," ", IFNULL(c.Apellidos,"")) + FROM vn2008.Contactos c + JOIN vn2008.Relaciones r ON r.Id_Contacto = c.Id_Contacto + JOIN vn.supplier s ON s.id = r.Id_Proveedor; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index cc3f2f689f..0ca1a88206 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1214,6 +1214,13 @@ INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif` (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 `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) + VALUES + (1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'), + (2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'), + (3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL), + (4, 442, 321654987, NULL, NULL, 'observation442', NULL); + INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES (1, 2, 'available', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL), -- 2.40.1 From 18ebbe80d7cd92564aa52604f753c7d257deb8cc Mon Sep 17 00:00:00 2001 From: bernat Date: Fri, 30 Oct 2020 11:40:12 +0100 Subject: [PATCH 2/6] supplier contact --- modules/supplier/back/model-config.json | 3 + .../back/models/supplier-contact.json | 49 ++++++++++++ modules/supplier/front/contact/index.html | 77 +++++++++++++++++++ modules/supplier/front/contact/index.js | 27 +++++++ modules/supplier/front/contact/style.scss | 10 +++ modules/supplier/front/index.js | 1 + modules/supplier/front/routes.json | 22 +++++- 7 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 modules/supplier/back/models/supplier-contact.json create mode 100644 modules/supplier/front/contact/index.html create mode 100644 modules/supplier/front/contact/index.js create mode 100644 modules/supplier/front/contact/style.scss diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json index c1963a8cf2..34d152bc6b 100644 --- a/modules/supplier/back/model-config.json +++ b/modules/supplier/back/model-config.json @@ -7,5 +7,8 @@ }, "SupplierLog": { "dataSource": "vn" + }, + "SupplierContact": { + "dataSource": "vn" } } diff --git a/modules/supplier/back/models/supplier-contact.json b/modules/supplier/back/models/supplier-contact.json new file mode 100644 index 0000000000..accb2acd6b --- /dev/null +++ b/modules/supplier/back/models/supplier-contact.json @@ -0,0 +1,49 @@ +{ + "name": "SupplierContact", + "base": "VnModel", + "options": { + "mysql": { + "table": "supplierContact" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "supplierFk": { + "type": "String" + }, + "phone": { + "type": "String" + }, + "mobile": { + "type": "String" + }, + "email": { + "type": "String" + }, + "observation": { + "type": "String" + }, + "name": { + "type": "String" + } + }, + "relations": { + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "supplierFk" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/supplier/front/contact/index.html b/modules/supplier/front/contact/index.html new file mode 100644 index 0000000000..f0921875f6 --- /dev/null +++ b/modules/supplier/front/contact/index.html @@ -0,0 +1,77 @@ + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + +
\ No newline at end of file diff --git a/modules/supplier/front/contact/index.js b/modules/supplier/front/contact/index.js new file mode 100644 index 0000000000..48db3d5267 --- /dev/null +++ b/modules/supplier/front/contact/index.js @@ -0,0 +1,27 @@ +import ngModule from '../module'; +import './style.scss'; +import Section from 'salix/components/section'; + +class Controller extends Section { + add() { + this.$.model.insert({ + supplierFk: this.supplier.id + }); + } + + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + }); + } +} + +ngModule.vnComponent('vnSupplierContact', { + template: require('./index.html'), + controller: Controller, + bindings: { + supplier: '<' + } +}); diff --git a/modules/supplier/front/contact/style.scss b/modules/supplier/front/contact/style.scss new file mode 100644 index 0000000000..84e98050df --- /dev/null +++ b/modules/supplier/front/contact/style.scss @@ -0,0 +1,10 @@ +@import "variables"; + + +.contact { + max-width: $width-lg; + margin-bottom: 10px; + padding-right: 10px; + padding-left: 10px; + border: 1px solid $color-marginal; +} diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index a4017bbd98..2b7d735415 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -7,3 +7,4 @@ import './index/'; import './search-panel'; import './log'; import './summary'; +import './contact'; diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 24e8d86925..d679dd9798 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.contact", "icon": "contact_phone"}, {"state": "supplier.card.log", "icon": "history"} ] }, @@ -19,17 +20,20 @@ "abstract": true, "component": "vn-supplier", "description": "Suppliers" - }, { + }, + { "url": "/index?q", "state": "supplier.index", "component": "vn-supplier-index", "description": "Suppliers" - }, { + }, + { "url": "/:id", "state": "supplier.card", "abstract": true, "component": "vn-supplier-card" - }, { + }, + { "url": "/summary", "state": "supplier.card.summary", "component": "vn-supplier-summary", @@ -37,11 +41,21 @@ "params": { "supplier": "$ctrl.supplier" } - }, { + }, + { "url" : "/log", "state": "supplier.card.log", "component": "vn-supplier-log", "description": "Log" + }, + { + "url": "/contact", + "state": "supplier.card.contact", + "component": "vn-supplier-contact", + "description": "Contacts", + "params": { + "supplier": "$ctrl.supplier" + } } ] } \ No newline at end of file -- 2.40.1 From 89c9a1e8586caed31261e9b86bcabfaac8f3d7b4 Mon Sep 17 00:00:00 2001 From: bernat Date: Fri, 30 Oct 2020 13:26:56 +0100 Subject: [PATCH 3/6] add title in notes.contact --- modules/supplier/front/contact/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/supplier/front/contact/index.html b/modules/supplier/front/contact/index.html index f0921875f6..45d7ec356c 100644 --- a/modules/supplier/front/contact/index.html +++ b/modules/supplier/front/contact/index.html @@ -49,6 +49,7 @@ label="Notes" ng-model="contact.observation" rule="SupplierContact" + title="{{contact.observation}}" vn-focus> -- 2.40.1 From e700f1186303a76b378f8e31fff0604778aaf39c Mon Sep 17 00:00:00 2001 From: bernat Date: Mon, 2 Nov 2020 11:14:21 +0100 Subject: [PATCH 4/6] acls --- db/changes/10250/00-ACL.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/changes/10250/00-ACL.sql diff --git a/db/changes/10250/00-ACL.sql b/db/changes/10250/00-ACL.sql new file mode 100644 index 0000000000..c9d8fd456f --- /dev/null +++ b/db/changes/10250/00-ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('supplier', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SupplierContact', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); -- 2.40.1 From 0e7c294f46b38af13d39fa37b55bb3be2f4235bb Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 2 Nov 2020 13:23:03 +0100 Subject: [PATCH 5/6] e2e path for supplier contacts --- e2e/helpers/selectors.js | 11 +++ .../01_summary_and_descriptor.spec.js | 2 +- e2e/paths/13-supplier/02_contact.spec.js | 84 +++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 e2e/paths/13-supplier/02_contact.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f34491ba3b..52e359687d 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -912,5 +912,16 @@ export default { alias: 'vn-supplier-descriptor vn-label-value[label="Alias"]', clientButton: 'vn-supplier-descriptor vn-icon[icon="person"]', entriesButton: 'vn-supplier-descriptor vn-icon[icon="icon-entry"]', + }, + supplierContact: { + anyContact: 'vn-supplier-contact > form > vn-card > div', + addNewContact: 'vn-supplier-contact vn-icon[icon="add_circle"]', + thirdContactName: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.name"]', + thirdContactPhone: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.phone"]', + thirdContactMobile: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.mobile"]', + thirdContactEmail: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.email"]', + thirdContactNotes: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.observation"]', + saveButton: 'vn-supplier-contact button[type="submit"]', + thirdContactDeleteButton: 'vn-supplier-contact div:nth-child(3) vn-icon-button[icon="delete"]' } }; diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js index 953a9ee283..21609fced6 100644 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Supplier descriptor path', () => { +describe('Supplier summary & descriptor path', () => { let browser; let page; diff --git a/e2e/paths/13-supplier/02_contact.spec.js b/e2e/paths/13-supplier/02_contact.spec.js new file mode 100644 index 0000000000..9a102cf936 --- /dev/null +++ b/e2e/paths/13-supplier/02_contact.spec.js @@ -0,0 +1,84 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Supplier contact path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'supplier'); + await page.accessToSearchResult('1'); + await page.accessToSection('supplier.card.contact'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should create a new contact', async() => { + await page.waitToClick(selectors.supplierContact.addNewContact); + await page.write(selectors.supplierContact.thirdContactName, 'The tester'); + await page.write(selectors.supplierContact.thirdContactPhone, '99 999 99 99'); + await page.write(selectors.supplierContact.thirdContactMobile, '555 55 55 55'); + await page.write(selectors.supplierContact.thirdContactEmail, 'testing@puppeteer.com'); + await page.write(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); + await page.waitToClick(selectors.supplierContact.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('Data saved!'); + }); + + it(`should reload the section and count the contacts`, async() => { + await page.reloadSection('supplier.card.contact'); + const result = await page.countElement(selectors.supplierContact.anyContact); + + expect(result).toEqual(3); + }); + + it(`should check the new contact name was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactName, 'value'); + + expect(result).toContain('The tester'); + }); + + it(`should check the new contact phone was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactPhone, 'value'); + + expect(result).toContain('99 999 99 99'); + }); + + it(`should check the new contact mobile was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactMobile, 'value'); + + expect(result).toContain('555 55 55 55'); + }); + + it(`should check the new contact email was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactEmail, 'value'); + + expect(result).toContain('testing@puppeteer.com'); + }); + + it(`should check the new contact note was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value'); + + expect(result).toContain('the end to end integration tester'); + }); + + it(`should remove the created contact`, async() => { + await page.waitToClick(selectors.supplierContact.thirdContactDeleteButton, 'value'); + await page.waitToClick(selectors.supplierContact.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('Data saved!'); + }); + + it(`should reload the section and count the amount of contacts went back to 2`, async() => { + await page.reloadSection('supplier.card.contact'); + const result = await page.countElement(selectors.supplierContact.anyContact); + + expect(result).toEqual(2); + }); +}); -- 2.40.1 From 7ac18074951a27552207e11d6fd3155c175ae68c Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 2 Nov 2020 14:04:11 +0100 Subject: [PATCH 6/6] removed focus from html template --- modules/supplier/front/contact/index.html | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/supplier/front/contact/index.html b/modules/supplier/front/contact/index.html index 45d7ec356c..4a791a4bca 100644 --- a/modules/supplier/front/contact/index.html +++ b/modules/supplier/front/contact/index.html @@ -25,22 +25,19 @@ vn-one label="Phone" ng-model="contact.phone" - rule="SupplierContact" - vn-focus> + rule="SupplierContact"> + rule="SupplierContact"> + rule="SupplierContact"> @@ -49,8 +46,7 @@ label="Notes" ng-model="contact.observation" rule="SupplierContact" - title="{{contact.observation}}" - vn-focus> + title="{{contact.observation}}">