diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 9d6fddbe6..9e4898be9 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -197,6 +197,7 @@ describe('Ticket Edit sale path', () => { }); it('should check in the history that logs has been added', async() => { + await page.reload({waitUntil: ['networkidle0', 'domcontentloaded']}); await page.waitToClick(selectors.ticketSales.firstSaleHistoryButton); await page.waitForSelector(selectors.ticketSales.firstSaleHistory); const result = await page.countElement(selectors.ticketSales.firstSaleHistory); diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index 3e45b3fb5..321e8e24e 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -87,6 +87,14 @@ module.exports = Self => { for (let problem of problems) saleProblems.set(problem.saleFk, problem); + const ticketLog = await Self.rawSql(`SELECT DISTINCT changedModelId + FROM ticketLog tl + WHERE changedModel = 'Sale' + AND originFk = ?`, [id], myOptions); + const salesWithLogs = ticketLog.map(sale => { + return sale.changedModelId; + }); + for (let sale of sales) { const problems = saleProblems.get(sale.id); const itemStock = itemAvailable.get(sale.itemFk); @@ -98,6 +106,8 @@ module.exports = Self => { sale.hasTicketRequest = problems.hasTicketRequest; sale.hasComponentLack = problems.hasComponentLack; } + if (salesWithLogs.includes(sale.id)) + sale.$hasLogs = true; } return sales; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index fd259e120..8764417a8 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -211,7 +211,8 @@ vn-none vn-tooltip="History" icon="history" - ng-click="log.open()"> + ng-click="log.open()" + ng-show="sale.$hasLogs">