diff --git a/db/changes/10480-june/00-ACL.sql b/db/changes/10480-june/00-ACL.sql index 3236ff1fd..2e863be34 100644 --- a/db/changes/10480-june/00-ACL.sql +++ b/db/changes/10480-june/00-ACL.sql @@ -1,4 +1,6 @@ INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) VALUES + ('ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'), + ('ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'), ('Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'), ('Client','updateUser','WRITE','ALLOW','ROLE','salesPerson'); diff --git a/db/changes/10480-june/01-claimObservation.sql b/db/changes/10480-june/01-claimObservation.sql new file mode 100644 index 000000000..8dc126a9e --- /dev/null +++ b/db/changes/10480-june/01-claimObservation.sql @@ -0,0 +1,13 @@ +CREATE TABLE `vn`.`claimObservation` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `claimFk` int(10) unsigned NOT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, + `text` text COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `worker_key` (`workerFk`), + KEY `claim_key` (`claimFk`), + KEY `claimObservation_created_IDX` (`created`) USING BTREE, + CONSTRAINT `claimObservation_ibfk_1` FOREIGN KEY (`claimFk`) REFERENCES `vn`.`claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `claimObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE +) COMMENT='Todas las observaciones referentes a una reclamación' \ No newline at end of file diff --git a/db/changes/10480-june/02-claimTextMigration.sql b/db/changes/10480-june/02-claimTextMigration.sql new file mode 100644 index 000000000..fa5f6fe83 --- /dev/null +++ b/db/changes/10480-june/02-claimTextMigration.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`claimObservation` (`claimFk`, `text`, `created`) +SELECT `id`, `observation`, `created` FROM `vn`.`claim` \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5629455a9..01dc0486c 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1729,12 +1729,19 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, ( 6, 'mana', 'Mana', 1, 4, 0), ( 7, 'lack', 'Faltas', 1, 2, 0); -INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`) +INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`) VALUES - (1, util.VN_CURDATE(), 1, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', 1101, 18, 3, 0, util.VN_CURDATE(), 0), - (2, util.VN_CURDATE(), 2, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', 1101, 18, 3, 0, util.VN_CURDATE(), 1), - (3, util.VN_CURDATE(), 3, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', 1101, 18, 1, 1, util.VN_CURDATE(), 5), - (4, util.VN_CURDATE(), 3, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', 1104, 18, 5, 0, util.VN_CURDATE(), 10); + (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0), + (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1), + (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5), + (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10); + +INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) + VALUES + (1, 18, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', util.VN_CURDATE()), + (2, 18, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', util.VN_CURDATE()), + (3, 18, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', util.VN_CURDATE()), + (4, 18, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', util.VN_CURDATE()); INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 15bd24416..46dd41856 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -730,7 +730,7 @@ export default { claimSummary: { header: 'vn-claim-summary > vn-card > h5', state: 'vn-claim-summary vn-label-value[label="State"] > section > span', - observation: 'vn-claim-summary vn-textarea[ng-model="$ctrl.summary.claim.observation"]', + observation: 'vn-claim-summary vn-horizontal.text', firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span', firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img', itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor', @@ -742,7 +742,6 @@ export default { }, claimBasicData: { claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]', - observation: 'vn-textarea[ng-model="$ctrl.claim.observation"]', packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]', hasToPickUpCheckbox: 'vn-claim-basic-data vn-check[ng-model="$ctrl.claim.hasToPickUp"]', saveButton: `button[type=submit]` @@ -772,6 +771,12 @@ export default { secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', saveDevelopmentButton: 'button[type=submit]' }, + claimNote: { + addNoteFloatButton: 'vn-float-button', + note: 'vn-textarea[ng-model="$ctrl.note.text"]', + saveButton: 'button[type=submit]', + firstNoteText: 'vn-claim-note .text' + }, claimAction: { importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', anyLine: 'vn-claim-action vn-tbody > vn-tr', diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js index 2e2286939..0a08cad9f 100644 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ b/e2e/paths/06-claim/01_basic_data.spec.js @@ -22,8 +22,6 @@ describe('Claim edit basic data path', () => { it(`should edit claim state and observation fields`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado'); - await page.clearTextarea(selectors.claimBasicData.observation); - await page.write(selectors.claimBasicData.observation, 'edited observation'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '2'); await page.waitToClick(selectors.claimBasicData.saveButton); @@ -59,13 +57,6 @@ describe('Claim edit basic data path', () => { expect(hasToPickUpCheckbox).toBe('checked'); }); - it('should confirm the claim observation was edited', async() => { - const result = await page - .waitToGetProperty(selectors.claimBasicData.observation, 'value'); - - expect(result).toEqual('edited observation'); - }); - it('should confirm the claim packages was edited', async() => { const result = await page .waitToGetProperty(selectors.claimBasicData.packages, 'value'); @@ -75,8 +66,6 @@ describe('Claim edit basic data path', () => { it(`should edit the claim to leave it untainted`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente'); - await page.clearTextarea(selectors.claimBasicData.observation); - await page.write(selectors.claimBasicData.observation, 'Observation one'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '0'); await page.waitToClick(selectors.claimBasicData.saveButton); diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 589b3b6cb..00b021f88 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -37,7 +37,7 @@ describe('Claim summary path', () => { }); it('should display the observation', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'value'); + const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'innerText'); expect(result).toContain('Wisi forensibus mnesarchum in cum. Per id impetus abhorreant'); }); diff --git a/e2e/paths/06-claim/07_note.spec.js b/e2e/paths/06-claim/07_note.spec.js new file mode 100644 index 000000000..830f77cbe --- /dev/null +++ b/e2e/paths/06-claim/07_note.spec.js @@ -0,0 +1,46 @@ +import selectors from '../../helpers/selectors'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Claim Add note path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('salesPerson', 'claim'); + await page.accessToSearchResult('2'); + await page.accessToSection('claim.card.note.index'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should reach the claim note index`, async() => { + await page.waitForState('claim.card.note.index'); + }); + + it(`should click on the add new note button`, async() => { + await page.waitToClick(selectors.claimNote.addNoteFloatButton); + await page.waitForState('claim.card.note.create'); + }); + + it(`should create a new note`, async() => { + await page.waitForSelector(selectors.claimNote.note); + await page.type(`${selectors.claimNote.note} textarea`, 'The delivery was unsuccessful'); + await page.waitToClick(selectors.claimNote.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should redirect back to the claim notes page`, async() => { + await page.waitForState('claim.card.note.index'); + }); + + it('should confirm the note was created', async() => { + const result = await page.waitToGetProperty(selectors.claimNote.firstNoteText, 'innerText'); + + expect(result).toEqual('The delivery was unsuccessful'); + }); +}); diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index 0accbf920..8ab39eb45 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -84,6 +84,20 @@ module.exports = Self => { }; promises.push(Self.app.models.ClaimBeginning.find(filter, myOptions)); + // Claim observations + filter = { + where: {claimFk: id}, + include: [ + { + relation: 'worker', + scope: { + fields: ['id', 'firstName', 'lastName'] + } + } + ] + }; + promises.push(Self.app.models.ClaimObservation.find(filter, myOptions)); + // Claim developments filter = { where: {claimFk: id}, @@ -138,8 +152,9 @@ module.exports = Self => { summary.isEditable = await Self.isEditable(ctx, id, myOptions); [summary.claim] = res[0]; summary.salesClaimed = res[1]; - summary.developments = res[2]; - summary.actions = res[3]; + summary.observations = res[2]; + summary.developments = res[3]; + summary.actions = res[4]; return summary; }; diff --git a/modules/claim/back/methods/claim/specs/getSummary.spec.js b/modules/claim/back/methods/claim/specs/getSummary.spec.js index 6eb920b29..c4d01ecdc 100644 --- a/modules/claim/back/methods/claim/specs/getSummary.spec.js +++ b/modules/claim/back/methods/claim/specs/getSummary.spec.js @@ -19,6 +19,7 @@ describe('claim getSummary()', () => { expect(keys).toContain('claim'); expect(keys).toContain('salesClaimed'); expect(keys).toContain('developments'); + expect(keys).toContain('observations'); expect(keys).toContain('actions'); expect(keys).toContain('isEditable'); diff --git a/modules/claim/back/model-config.json b/modules/claim/back/model-config.json index d4d772b58..e99a455ac 100644 --- a/modules/claim/back/model-config.json +++ b/modules/claim/back/model-config.json @@ -38,6 +38,9 @@ "ClaimLog": { "dataSource": "vn" }, + "ClaimObservation": { + "dataSource": "vn" + }, "ClaimContainer": { "dataSource": "claimStorage" } diff --git a/modules/claim/back/models/claim-observation.json b/modules/claim/back/models/claim-observation.json new file mode 100644 index 000000000..e882ad09d --- /dev/null +++ b/modules/claim/back/models/claim-observation.json @@ -0,0 +1,43 @@ +{ + "name": "ClaimObservation", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "relation": "claim" + }, + "options": { + "mysql": { + "table": "claimObservation" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "claimFk": { + "type": "number", + "required": true + }, + "text": { + "type": "string", + "required": true + }, + "created": { + "type": "date" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "claim": { + "type": "belongsTo", + "model": "Claim", + "foreignKey": "claimFk" + } + } +} \ No newline at end of file diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 28fd92472..7a91e180a 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -51,15 +51,6 @@ label="Packages received" ng-model="$ctrl.claim.packages"> - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/claim/front/note/create/index.js b/modules/claim/front/note/create/index.js new file mode 100644 index 000000000..40ae9309b --- /dev/null +++ b/modules/claim/front/note/create/index.js @@ -0,0 +1,22 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + this.note = { + claimFk: parseInt(this.$params.id), + workerFk: window.localStorage.currentUserWorkerId, + text: null + }; + } + + cancel() { + this.$state.go('claim.card.note.index', {id: this.$params.id}); + } +} + +ngModule.vnComponent('vnClaimNoteCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/claim/front/note/index/index.html b/modules/claim/front/note/index/index.html new file mode 100644 index 000000000..8ffe19c2b --- /dev/null +++ b/modules/claim/front/note/index/index.html @@ -0,0 +1,32 @@ + + + + + + + {{::note.worker.firstName}} {{::note.worker.lastName}} + {{::note.created | date:'dd/MM/yyyy HH:mm'}} + + + {{::note.text}} + + + + + + + \ No newline at end of file diff --git a/modules/claim/front/note/index/index.js b/modules/claim/front/note/index/index.js new file mode 100644 index 000000000..5a2fd96d3 --- /dev/null +++ b/modules/claim/front/note/index/index.js @@ -0,0 +1,25 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + this.filter = { + order: 'created DESC', + }; + this.include = { + relation: 'worker', + scope: { + fields: ['id', 'firstName', 'lastName'] + } + }; + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnClaimNote', { + template: require('./index.html'), + controller: Controller, +}); diff --git a/modules/claim/front/note/index/style.scss b/modules/claim/front/note/index/style.scss new file mode 100644 index 000000000..44ae2cee7 --- /dev/null +++ b/modules/claim/front/note/index/style.scss @@ -0,0 +1,5 @@ +vn-client-note { + .note:last-child { + margin-bottom: 0; + } +} \ No newline at end of file diff --git a/modules/claim/front/routes.json b/modules/claim/front/routes.json index 5f08255be..d02ea6f6c 100644 --- a/modules/claim/front/routes.json +++ b/modules/claim/front/routes.json @@ -12,6 +12,7 @@ {"state": "claim.card.basicData", "icon": "settings"}, {"state": "claim.card.detail", "icon": "icon-details"}, {"state": "claim.card.photos", "icon": "image"}, + {"state": "claim.card.note.index", "icon": "insert_drive_file"}, {"state": "claim.card.development", "icon": "icon-traceability"}, {"state": "claim.card.action", "icon": "icon-actions"}, {"state": "claim.card.log", "icon": "history"} @@ -27,17 +28,20 @@ "abstract": true, "component": "vn-claim", "description": "Claims" - }, { + }, + { "url": "/index?q", "state": "claim.index", "component": "vn-claim-index", "description": "Claims" - }, { + }, + { "url": "/:id", "state": "claim.card", "abstract": true, "component": "vn-claim-card" - }, { + }, + { "url": "/summary", "state": "claim.card.summary", "component": "vn-claim-summary", @@ -45,7 +49,8 @@ "params": { "claim": "$ctrl.claim" } - }, { + }, + { "url": "/basic-data", "state": "claim.card.basicData", "component": "vn-claim-basic-data", @@ -54,7 +59,8 @@ "claim": "$ctrl.claim" }, "acl": ["salesPerson"] - }, { + }, + { "url": "/detail", "state": "claim.card.detail", "component": "vn-claim-detail", @@ -63,7 +69,32 @@ "claim": "$ctrl.claim" }, "acl": ["salesPerson"] - }, { + }, + { + "url": "/note", + "state": "claim.card.note", + "component": "ui-view", + "abstract": true, + "acl": ["salesPerson"] + }, + { + "url": "/index", + "state": "claim.card.note.index", + "component": "vn-claim-note", + "description": "Notes", + "params": { + "claim": "$ctrl.claim" + }, + "acl": ["salesPerson"] + }, + { + "url": "/create", + "state": "claim.card.note.create", + "component": "vn-claim-note-create", + "description": "New note", + "acl": ["salesPerson"] + }, + { "url": "/development", "state": "claim.card.development", "component": "vn-claim-development", @@ -72,7 +103,8 @@ "claim": "$ctrl.claim" }, "acl": ["claimManager"] - }, { + }, + { "url": "/action", "state": "claim.card.action", "component": "vn-claim-action", @@ -81,7 +113,8 @@ "claim": "$ctrl.claim" }, "acl": ["claimManager"] - }, { + }, + { "url": "/photos", "state": "claim.card.photos", "component": "vn-claim-photos", @@ -89,7 +122,8 @@ "params": { "claim": "$ctrl.claim" } - }, { + }, + { "url" : "/log", "state": "claim.card.log", "component": "vn-claim-log", diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 5d90da516..0c12aa2e6 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -1,11 +1,12 @@ - - {{::$ctrl.summary.claim.id}} - {{::$ctrl.summary.claim.client.name}} - - - - - + + + + Observations + + + + Observations + + + + {{::note.worker.firstName}} {{::note.worker.lastName}} + {{::note.created | date:'dd/MM/yyyy HH:mm'}} + + + {{::note.text}} + + +