feat: it only sets the highest priority, in case that ticket doesn't already have the highest priority.
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-06-15 12:53:13 +02:00
parent cc23913c9e
commit f69fb45b90
3 changed files with 36 additions and 16 deletions

View File

@ -11,7 +11,8 @@
<form <form
class="vn-w-xl" class="vn-w-xl"
name="form"> name="form">
<vn-card class="vn-pa-lg"> <vn-card>
<section class="vn-pa-md">
<vn-tool-bar> <vn-tool-bar>
<vn-button <vn-button
icon="icon-wand" icon="icon-wand"
@ -26,14 +27,17 @@
</vn-button> </vn-button>
<vn-button <vn-button
disabled="!$ctrl.isChecked" disabled="!$ctrl.isChecked"
ng-click="$ctrl.deletePriority()()" ng-click="$ctrl.deletePriority()"
vn-tooltip="Delete priority" vn-tooltip="Delete priority"
icon="contact_support"> icon="filter_alt_off">
</vn-button>
<vn-button
ng-click="$ctrl.setOrderedPriority($ctrl.tickets)"
vn-tooltip="Renumber all tickets in current order"
icon="format_list_numbered">
</vn-button> </vn-button>
</vn-tool-bar> </vn-tool-bar>
</vn-card> <vn-table class="vn-pt-md" model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)">
<vn-card class="vn-mt-lg">
<vn-table model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)">
<vn-thead> <vn-thead>
<vn-tr> <vn-tr>
<vn-th shrink> <vn-th shrink>
@ -64,8 +68,9 @@
</vn-td> </vn-td>
<vn-td> <vn-td>
<vn-icon-button <vn-icon-button
icon="add_circle" icon="low_priority"
ng-click="$ctrl.setHighestPriority(ticket.id)" ng-click="$ctrl.setHighestPriority(ticket)"
vn-tooltip="Assign highest priority"
tabindex="-1"> tabindex="-1">
</vn-icon-button> </vn-icon-button>
</vn-td> </vn-td>
@ -123,6 +128,7 @@
</a> </a>
</vn-tbody> </vn-tbody>
</vn-table> </vn-table>
</section>
</vn-card> </vn-card>
</form> </form>
</vn-data-viewer> </vn-data-viewer>

View File

@ -20,22 +20,23 @@ class Controller extends Section {
return highestPriority + 1; return highestPriority + 1;
} }
setHighestPriority(id) { setHighestPriority(ticket) {
const highestPriority = this.getHighestPriority(); const highestPriority = this.getHighestPriority();
if (highestPriority - 1 != ticket.priority) {
const params = {priority: highestPriority}; const params = {priority: highestPriority};
const query = `Tickets/${id}/`; const query = `Tickets/${ticket.id}/`;
this.$http.patch(query, params).then(() => { this.$http.patch(query, params).then(res => {
ticket.priority = res.data.priority;
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
this.$.model.refresh();
}); });
} }
}
setPriority(id, priority) { setPriority(id, priority) {
let params = {priority: priority}; let params = {priority: priority};
let query = `Tickets/${id}/`; let query = `Tickets/${id}/`;
this.$http.patch(query, params).then(() => { this.$http.patch(query, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); 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) { getSelectedItems(items) {
const selectedItems = []; const selectedItems = [];

View File

@ -14,3 +14,5 @@ The route doesn't have a vehicle: La ruta no tiene un vehículo
Population: Población Population: Población
Unlink selected zone?: Desvincular zona seleccionada? Unlink selected zone?: Desvincular zona seleccionada?
Delete priority: Borrar orden 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