From e6a72d0f09cde13b80947d43ca66ee1774228120 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 18 Jun 2020 15:26:15 +0200 Subject: [PATCH] clean code refactor --- .../back/methods/ticket-tracking/setDelivered.js | 4 ++-- modules/ticket/front/index/index.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/ticket-tracking/setDelivered.js b/modules/ticket/back/methods/ticket-tracking/setDelivered.js index 94cbad7a2..509f5b446 100644 --- a/modules/ticket/back/methods/ticket-tracking/setDelivered.js +++ b/modules/ticket/back/methods/ticket-tracking/setDelivered.js @@ -35,11 +35,11 @@ module.exports = Self => { let worker = await models.Worker.findOne({where: {userFk: userId}}); let promises = []; - for (let i = 0; i < ticketIds.length; i++) { + for (let id of ticketIds) { let promise = models.TicketTracking.changeState(ctx, { stateFk: state.id, workerFk: worker.id, - ticketFk: ticketIds[i] + ticketFk: id }); promises.push(promise); } diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 0cf076d61..2c8b9b83c 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -4,6 +4,10 @@ import UserError from 'core/lib/user-error'; import './style.scss'; export default class Controller extends Section { + constructor($element, $, vnReport) { + super($element, $); + this.vnReport = vnReport; + } setDelivered() { const checkedTickets = this.checked; let ids = []; @@ -25,13 +29,9 @@ export default class Controller extends Section { openDeliveryNotes(ids) { for (let id of ids) { - const params = { - authorization: this.vnToken.token, - ticketId: id - }; - - const serializedParams = this.$httpParamSerializer(params); - window.open(`api/report/delivery-note?${serializedParams}`); ``; + this.vnReport.show('delivery-note', { + ticketId: id, + }); } } @@ -156,6 +156,7 @@ export default class Controller extends Section { return [minHour, maxHour]; } } +Controller.$inject = ['$element', '$scope', 'vnReport']; ngModule.component('vnTicketIndex', { template: require('./index.html'),