From a26652045c46efa6303c48f6db8c3c63b1454a6c Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Aug 2023 10:17:46 +0200 Subject: [PATCH] refs #5712 hotFix(docuware): tickets. hotFix(catalog): search_panel --- back/methods/docuware/checkFile.js | 7 +++---- back/methods/docuware/deliveryNoteEmail.js | 2 +- back/methods/docuware/specs/checkFile.spec.js | 16 +++------------- back/methods/docuware/upload.js | 2 +- .../order/front/catalog-search-panel/index.js | 4 ---- modules/order/front/catalog/index.js | 2 +- modules/order/front/catalog/index.spec.js | 4 ++-- .../back/methods/ticket/docuwareDownload.js | 10 +++++++++- modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/descriptor-menu/index.js | 7 ++++--- 10 files changed, 25 insertions(+), 30 deletions(-) diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index 19224057c..76789649f 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -71,11 +71,10 @@ module.exports = Self => { } try { - const response = await Self.get(fileCabinet, filter); - const [documents] = response.Items; - if (!documents) return false; + const [response] = await Self.get(fileCabinet, filter); + if (!response) return false; - return {id: documents.Id}; + return {id: response['Document ID']}; } catch (error) { return false; } diff --git a/back/methods/docuware/deliveryNoteEmail.js b/back/methods/docuware/deliveryNoteEmail.js index 1557a3a87..a654eb262 100644 --- a/back/methods/docuware/deliveryNoteEmail.js +++ b/back/methods/docuware/deliveryNoteEmail.js @@ -65,7 +65,7 @@ module.exports = Self => { const email = new Email('delivery-note', params); - const docuwareFile = await models.Docuware.download(ctx, id, 'deliveryNote'); + const docuwareFile = await models.Docuware.download(id, 'deliveryNote'); return email.send({ overrideAttachments: true, diff --git a/back/methods/docuware/specs/checkFile.spec.js b/back/methods/docuware/specs/checkFile.spec.js index 8460bb561..c60809e85 100644 --- a/back/methods/docuware/specs/checkFile.spec.js +++ b/back/methods/docuware/specs/checkFile.spec.js @@ -16,19 +16,9 @@ describe('docuware download()', () => { it('should return the document data', async() => { const docuwareId = 1; - const response = { - Items: [ - { - Id: docuwareId, - Fields: [ - { - FieldName: 'ESTADO', - Item: 'Firmado' - } - ] - } - ] - }; + const response = [{ + 'Document ID': docuwareId + }]; spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve(response)))); const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 096301e56..7055bf8d5 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -111,7 +111,7 @@ module.exports = Self => { throw new UserError('Action not allowed on the test environment'); // delete old - const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false); + const docuwareFile = await models.Docuware.checkFile(id, fileCabinet, false); if (docuwareFile) { const deleteJson = { 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}] diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index 21c0c50fa..b84243ca7 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -25,10 +25,6 @@ class Controller extends SearchPanel { this.filter.values.push({}); setTimeout(() => this.parentPopover.relocate()); } - - changeTag() { - - } } ngModule.vnComponent('vnOrderCatalogSearchPanel', { diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index c0777ebc9..f25c4a35e 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -236,7 +236,7 @@ class Controller extends Section { tagGroups: this.tagGroups, }; - return model.applyFilter({where: newFilter}, newParams); + return model.addFilter({where: newFilter}, newParams); } openPanel(event) { diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index 03d7c41ba..ef96e1ed0 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -191,14 +191,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - jest.spyOn(controller.$.model, 'applyFilter'); + jest.spyOn(controller.$.model, 'addFilter'); controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(controller.$.model.applyFilter).toHaveBeenCalledWith( + expect(controller.$.model.addFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tagGroups: []}); }); diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js index e9b74b1a9..7084bbdd4 100644 --- a/modules/ticket/back/methods/ticket/docuwareDownload.js +++ b/modules/ticket/back/methods/ticket/docuwareDownload.js @@ -32,6 +32,14 @@ module.exports = Self => { }); Self.docuwareDownload = async id => { + const models = Self.app.models; + const docuwareInfo = await models.Docuware.findOne({ + where: { + code: 'deliveryNote', + action: 'find' + } + }); + const filter = { condition: [ { @@ -50,6 +58,6 @@ module.exports = Self => { } ] }; - return Self.app.models.Docuware.download(id, 'deliveryNote', filter); + return models.Docuware.download(id, 'deliveryNote', filter); }; }; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index c37337253..14cb104be 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -42,4 +42,5 @@ module.exports = function(Self) { require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/saveSign')(Self); require('../methods/ticket/invoiceTickets')(Self); + require('../methods/ticket/docuwareDownload')(Self); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 360d93564..d1f39fd19 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -3,10 +3,11 @@ import Section from 'salix/components/section'; import './style.scss'; class Controller extends Section { - constructor($element, $, vnReport, vnEmail) { + constructor($element, $, vnReport, vnEmail, vnFile) { super($element, $); this.vnReport = vnReport; this.vnEmail = vnEmail; + this.vnFile = vnFile; } get ticketId() { @@ -322,7 +323,7 @@ class Controller extends Section { } docuwareDownload() { - this.vnFile.download(`api/Ticket/${this.ticket.id}/docuwareDownload`); + this.vnFile.download(`api/Tickets/${this.ticket.id}/docuwareDownload`); } setTicketWeight(weight) { @@ -335,7 +336,7 @@ class Controller extends Section { } } -Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; +Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail', 'vnFile']; ngModule.vnComponent('vnTicketDescriptorMenu', { template: require('./index.html'),