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

View File

@ -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 = [];

View File

@ -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