From 5a19e5801f9af4a12d0f7b9cdcc3daa0c92e28a7 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 Jan 2023 11:50:54 +0100 Subject: [PATCH 1/7] fix: enabled button when an error occurs --- front/core/components/smart-table/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 770dcdf32..24d121aac 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -589,7 +589,8 @@ export default class SmartTable extends Component { refresh() { this.isRefreshing = true; this.model.refresh() - .then(() => this.isRefreshing = false); + .then(() => this.isRefreshing = false) + .catch(() => this.isRefreshing = false); } } From 9eb65507b5d165f80fb39a3a798613c4137c23d9 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 Jan 2023 14:43:31 +0100 Subject: [PATCH 2/7] fix: elimino this.model.refresh que siempre daba fallo --- front/core/components/smart-table/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 24d121aac..79c5c17c8 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -231,7 +231,6 @@ export default class SmartTable extends Component { } this.model.order = order; - this.refresh(); } registerColumns() { @@ -479,7 +478,6 @@ export default class SmartTable extends Component { const params = {q: JSON.stringify(stateFilter)}; this.$state.go(this.$state.current.name, params, {location: 'replace'}); - this.refresh(); } applySort() { @@ -500,7 +498,6 @@ export default class SmartTable extends Component { const params = {q: JSON.stringify(stateFilter)}; this.$state.go(this.$state.current.name, params, {location: 'replace'}); - this.refresh(); } filterSanitizer(field) { From 5a70fd4779d3c2bcd850c719b34761b8e0e32d0d Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 24 Jan 2023 14:45:35 +0100 Subject: [PATCH 3/7] fix: las peticiones no colisionan --- front/core/components/smart-table/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 79c5c17c8..416d24d16 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -231,6 +231,7 @@ export default class SmartTable extends Component { } this.model.order = order; + this.refresh(); } registerColumns() { @@ -477,7 +478,8 @@ export default class SmartTable extends Component { const params = {q: JSON.stringify(stateFilter)}; - this.$state.go(this.$state.current.name, params, {location: 'replace'}); + this.$state.go(this.$state.current.name, params, {location: 'replace'}) + .then(() => this.refresh()); } applySort() { @@ -497,7 +499,8 @@ export default class SmartTable extends Component { stateFilter.tableOrder = order; const params = {q: JSON.stringify(stateFilter)}; - this.$state.go(this.$state.current.name, params, {location: 'replace'}); + this.$state.go(this.$state.current.name, params, {location: 'replace'}) + .then(() => this.refresh()); } filterSanitizer(field) { From 51400b1c747e1cf9e1e2552c2e241de7dadb60e1 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 26 Jan 2023 08:19:52 +0100 Subject: [PATCH 4/7] =?UTF-8?q?reactor:=20eliminado=20try=20y=20catch,=20y?= =?UTF-8?q?=20a=C3=B1adido=20finally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/core/components/smart-table/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 416d24d16..ad9883950 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -589,8 +589,7 @@ export default class SmartTable extends Component { refresh() { this.isRefreshing = true; this.model.refresh() - .then(() => this.isRefreshing = false) - .catch(() => this.isRefreshing = false); + .finally(() => this.isRefreshing = false); } } From b1de5bc94e263814a4efc71473b2d5931ad58b92 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 27 Jan 2023 10:06:46 +0100 Subject: [PATCH 5/7] refs #5174, fix banch being created from another branch and not from dev --- e2e/helpers/selectors.js | 12 +- modules/ticket/front/weekly/index.html | 187 ++++++++++++++----------- modules/ticket/front/weekly/index.js | 39 ++++++ 3 files changed, 150 insertions(+), 88 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a1412f431..d405278a5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -562,15 +562,15 @@ export default { payoutBank: '.vn-dialog vn-autocomplete[ng-model="$ctrl.bankFk"]', payoutDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]', submitPayout: '.vn-dialog button[response="accept"]', - searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', + searchWeeklyResult: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr', searchResultDate: 'vn-ticket-summary [label=Landed] span', topbarSearch: 'vn-searchbar', moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]', - fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(4)', - fiveWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(5)', - weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr', - firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', - firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', + fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)', + fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)', + weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr', + firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]', + firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]' }, createTicketView: { diff --git a/modules/ticket/front/weekly/index.html b/modules/ticket/front/weekly/index.html index 3c739d5f9..ca3b6e662 100644 --- a/modules/ticket/front/weekly/index.html +++ b/modules/ticket/front/weekly/index.html @@ -17,87 +17,110 @@ model="model"> - - - - - - Ticket ID - Client - Shipment - Agency - Warehouse - Salesperson - - - - - - - - {{weekly.ticketFk}} - - - - - {{::weekly.clientName}} - - - - - - - - - - - {{::weekly.warehouseName}} - - - {{::weekly.userName}} - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Ticket ID + + Client + + Shipment + + Agency + + Warehouse + + Salesperson +
+ + {{weekly.ticketFk}} + + + + {{::weekly.clientName}} + + + + + + + + {{weekly.warehouseName}} + + {{::weekly.userName}} + + + + +
+
+
+
@@ -112,4 +135,4 @@ on-accept="$ctrl.onDeleteWeeklyAccept($data)" question="This ticket will be removed from weekly tickets! Continue anyway?" message="You are going to delete this weekly ticket"> - + \ No newline at end of file diff --git a/modules/ticket/front/weekly/index.js b/modules/ticket/front/weekly/index.js index 71365c4b3..a10ff7184 100644 --- a/modules/ticket/front/weekly/index.js +++ b/modules/ticket/front/weekly/index.js @@ -1,3 +1,4 @@ + import ngModule from '../module'; import Section from 'salix/components/section'; @@ -15,6 +16,44 @@ export default class Controller extends Section { {id: 5, name: 'Saturday'}, {id: 6, name: 'Sunday'} ]; + + this.smartTableOptions = { + activeButtons: { + search: true, + shownColumns: true, + }, + columns: [ + { + field: 'ticketFk', + searchable: false + }, + { + field: 'clientName', + }, + { + field: 'weekDay', + searchable: false, + }, + { + field: 'agencyModeFk', + searchable: false, + }, + { + field: 'warehouseFk', + searchable: false, + }, + { + field: 'nickname', + }, + ] + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'clientName': return {'c.name': value}; + case 'nickName': return {'u.name': value}; + } } onUpdate(ticketFk, field, value) { From 4a587049fcb0ac30d878d0ed13a30691fe6f7d06 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 15:13:38 +0100 Subject: [PATCH 6/7] feat(recover-password): use user refs #5170 --- back/methods/account/recover-password.js | 17 +++++++++++++---- e2e/helpers/selectors.js | 2 +- e2e/paths/01-salix/04_recoverPassword.spec.js | 14 +++++++++++++- .../components/recover-password/index.html | 4 ++-- .../salix/components/recover-password/index.js | 2 +- .../components/recover-password/locale/es.yml | 1 + 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/back/methods/account/recover-password.js b/back/methods/account/recover-password.js index ddea76829..787a45284 100644 --- a/back/methods/account/recover-password.js +++ b/back/methods/account/recover-password.js @@ -3,9 +3,9 @@ module.exports = Self => { description: 'Send email to the user', accepts: [ { - arg: 'email', + arg: 'user', type: 'string', - description: 'The email of user', + description: 'The user name or email', required: true } ], @@ -15,11 +15,20 @@ module.exports = Self => { } }); - Self.recoverPassword = async function(email) { + Self.recoverPassword = async function(user) { const models = Self.app.models; + const usesEmail = user.indexOf('@') !== -1; + if (!usesEmail) { + const account = await models.Account.findOne({ + fields: ['email'], + where: {name: user} + }); + user = account.email; + } + try { - await models.user.resetPassword({email, emailTemplate: 'recover-password'}); + await models.user.resetPassword({email: user, emailTemplate: 'recover-password'}); } catch (err) { if (err.code === 'EMAIL_NOT_FOUND') return; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 986c6547b..3e8904572 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -31,7 +31,7 @@ export default { }, recoverPassword: { recoverPasswordButton: 'vn-login a[ui-sref="recover-password"]', - email: 'vn-recover-password vn-textfield[ng-model="$ctrl.email"]', + email: 'vn-recover-password vn-textfield[ng-model="$ctrl.user"]', sendEmailButton: 'vn-recover-password vn-submit', }, accountIndex: { diff --git a/e2e/paths/01-salix/04_recoverPassword.spec.js b/e2e/paths/01-salix/04_recoverPassword.spec.js index e6cb02ab1..aa0389648 100644 --- a/e2e/paths/01-salix/04_recoverPassword.spec.js +++ b/e2e/paths/01-salix/04_recoverPassword.spec.js @@ -26,7 +26,7 @@ describe('RecoverPassword path', async() => { expect(message.text).toContain('Notification sent!'); }); - it('should send email', async() => { + it('should send email using email', async() => { await page.waitForState('login'); await page.waitToClick(selectors.recoverPassword.recoverPasswordButton); @@ -37,4 +37,16 @@ describe('RecoverPassword path', async() => { expect(message.text).toContain('Notification sent!'); }); + + it('should send email using username', async() => { + await page.waitForState('login'); + await page.waitToClick(selectors.recoverPassword.recoverPasswordButton); + + await page.write(selectors.recoverPassword.email, 'BruceWayne'); + await page.waitToClick(selectors.recoverPassword.sendEmailButton); + const message = await page.waitForSnackbar(); + await page.waitForState('login'); + + expect(message.text).toContain('Notification sent!'); + }); }); diff --git a/front/salix/components/recover-password/index.html b/front/salix/components/recover-password/index.html index 73f5401d9..5121f81bd 100644 --- a/front/salix/components/recover-password/index.html +++ b/front/salix/components/recover-password/index.html @@ -1,7 +1,7 @@
Recover password
Date: Thu, 2 Feb 2023 11:34:13 +0100 Subject: [PATCH 7/7] fix: frontTest --- front/core/components/smart-table/index.spec.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/front/core/components/smart-table/index.spec.js b/front/core/components/smart-table/index.spec.js index 5fd4c33b7..5a1be98e1 100644 --- a/front/core/components/smart-table/index.spec.js +++ b/front/core/components/smart-table/index.spec.js @@ -160,7 +160,7 @@ describe('Component smartTable', () => { describe('applySort()', () => { it('should call the $state go and model refresh without making changes on the model order', () => { controller.$state = { - go: jest.fn(), + go: jest.fn().mockReturnValue(new Promise(resolve => resolve())), current: { name: 'section' } @@ -171,13 +171,12 @@ describe('Component smartTable', () => { expect(controller.model.order).toBeUndefined(); expect(controller.$state.go).toHaveBeenCalled(); - expect(controller.refresh).toHaveBeenCalled(); }); it('should call the $state go and model refresh after setting model order according to the controller sortCriteria', () => { const orderBy = {field: 'myField', sortType: 'ASC'}; controller.$state = { - go: jest.fn(), + go: jest.fn().mockReturnValue(new Promise(resolve => resolve())), current: { name: 'section' } @@ -190,7 +189,6 @@ describe('Component smartTable', () => { expect(controller.model.order).toEqual(`${orderBy.field} ${orderBy.sortType}`); expect(controller.$state.go).toHaveBeenCalled(); - expect(controller.refresh).toHaveBeenCalled(); }); }); @@ -293,12 +291,10 @@ describe('Component smartTable', () => { controller.$inputsScope = { searchProps: {} }; - jest.spyOn(controller, 'refresh'); controller.defaultFilter(); expect(controller.model.addFilter).toHaveBeenCalled(); - expect(controller.refresh).toHaveBeenCalled(); }); });