From f69fb45b90e8fd2255a46c74db81148a8b5d3a0d Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 15 Jun 2022 12:53:13 +0200 Subject: [PATCH] feat: it only sets the highest priority, in case that ticket doesn't already have the highest priority. --- modules/route/front/tickets/index.html | 22 +++++++++++------- modules/route/front/tickets/index.js | 28 ++++++++++++++++------- modules/route/front/tickets/locale/es.yml | 2 ++ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 49ad5c359..845e0daa9 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -11,7 +11,8 @@
- + +
+ icon="filter_alt_off"> + + - - - + @@ -64,8 +68,9 @@ @@ -123,6 +128,7 @@ +
diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js index 6d3744031..e78d9b8b7 100644 --- a/modules/route/front/tickets/index.js +++ b/modules/route/front/tickets/index.js @@ -20,14 +20,16 @@ class Controller extends Section { return highestPriority + 1; } - setHighestPriority(id) { + setHighestPriority(ticket) { const highestPriority = this.getHighestPriority(); - const params = {priority: highestPriority}; - const query = `Tickets/${id}/`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }); + if (highestPriority - 1 != ticket.priority) { + const params = {priority: highestPriority}; + const query = `Tickets/${ticket.id}/`; + this.$http.patch(query, params).then(res => { + ticket.priority = res.data.priority; + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } } setPriority(id, priority) { @@ -35,7 +37,6 @@ class Controller extends Section { let query = `Tickets/${id}/`; this.$http.patch(query, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); }); } @@ -50,6 +51,17 @@ class Controller extends Section { } } + setOrderedPriority(lines) { + let priority = 1; + for (const line of lines) { + this.$http.patch(`Tickets/${line.id}/`, {priority: priority}).then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + this.$.model.refresh(); + }); + priority++; + } + } + getSelectedItems(items) { const selectedItems = []; diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml index caccbfdc5..af78cac3f 100644 --- a/modules/route/front/tickets/locale/es.yml +++ b/modules/route/front/tickets/locale/es.yml @@ -14,3 +14,5 @@ The route doesn't have a vehicle: La ruta no tiene un vehículo Population: Población Unlink selected zone?: Desvincular zona seleccionada? Delete priority: Borrar orden +Renumber all tickets in current order: Renumerar todos los tickets con el orden actual +Assign highest priority: Asignar máxima prioridad \ No newline at end of file