feat(route.index): can edit fields
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-06-23 14:14:13 +02:00
parent 980ac50ba9
commit 3e43bf2024
3 changed files with 164 additions and 67 deletions

View File

@ -1,57 +1,129 @@
<vn-auto-search <vn-auto-search
model="model"> model="model">
</vn-auto-search> </vn-auto-search>
<vn-data-viewer <div class="vn-w-xl">
model="model"
class="vn-w-lg vn-mb-xl">
<vn-card> <vn-card>
<vn-table model="model"> <smart-table
<vn-thead> model="model"
<vn-tr> options="$ctrl.smartTableOptions"
<vn-th shrink> expr-builder="$ctrl.exprBuilder(param, value)">
<slot-table>
<table model="model">
<thead>
<tr>
<th shrink>
<vn-multi-check <vn-multi-check
model="model"> model="model">
</vn-multi-check> </vn-multi-check>
</vn-th> </th>
<vn-th field="id" number>Id</vn-th> <th field="id" number>
<vn-th field="workerFk">Worker</vn-th> <span translate>Id</span>
<vn-th field="agencyName">Agency</vn-th> </th>
<vn-th field="vehiclePlateNumber">Vehicle</vn-th> <th field="workerFk">
<vn-th field="created" shrink-date>Date</vn-th> <span translate>Worker</span>
<vn-th field="m3" number></vn-th> </th>
<vn-th field="description">Description</vn-th> <th field="agencyName">
<vn-th field="started">Start</vn-th> <span translate>Agency</span>
<vn-th field="finished">Finish</vn-th> </th>
<vn-th shrink></vn-th> <th field="vehiclePlateNumber">
</vn-tr> <span translate>Vehicle</span>
</vn-thead> </th>
<vn-tbody> <th field="created" shrink-date>
<a ng-repeat="route in model.data" <span translate>Date</span>
</th>
<th field="m3" number>
<span translate></span>
</th>
<th field="description">
<span translate>Description</span>
</th>
<th field="started">
<span translate>Hour started</span>
</th>
<th field="finished">
<span translate>Hour finished</span>
</th>
<th shrink></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="route in model.data"
class="clickable vn-tr search-result" class="clickable vn-tr search-result"
ui-sref="route.card.summary({id: {{::route.id}}})"
ng-attr-id="{{::route.id}}" vn-droppable="$ctrl.onDrop($event)"> ng-attr-id="{{::route.id}}" vn-droppable="$ctrl.onDrop($event)">
<vn-td shrink> <td shrink>
<vn-check <vn-check
ng-model="route.checked" ng-model="route.checked"
vn-click-stop> vn-click-stop>
</vn-check> </vn-check>
</vn-td> </td>
<vn-td number>{{::route.id | dashIfEmpty}}</vn-td> <td number>
<vn-td expand> <a
<span vn-tooltip="Go to route"
class="link" ui-sref="route.card.summary({id: {{::route.id}}})">
vn-click-stop="workerDescriptor.show($event, route.workerFk)"> {{::route.id | dashIfEmpty}}
{{::route.workerUserName}} </a>
</span> </td>
</vn-td> <td>
<vn-td>{{::route.agencyName | dashIfEmpty}}</vn-td> <vn-autocomplete
<vn-td>{{::route.vehiclePlateNumber | dashIfEmpty}}</vn-td> ng-model="route.workerFk"
<vn-td shrink-date>{{::route.created | dashIfEmpty | date:'dd/MM/yyyy'}}</vn-td> url="Workers/activeWithInheritedRole"
<vn-td number>{{::route.m3 | dashIfEmpty}}</vn-td> show-field="nickname"
<vn-td>{{::route.description | dashIfEmpty}}</vn-td> search-function="{firstName: $search}"
<vn-td expand>{{::route.started | dashIfEmpty | date:'dd/MM/yyyy HH:mm'}}</vn-td> value-field="id"
<vn-td expand>{{::route.finished | dashIfEmpty | date:'dd/MM/yyyy HH:mm'}}</vn-td> where="{role: 'employee'}"
<vn-td> on-change="$ctrl.updateAttributes(route)"
vn-click-stop>
<tpl-item>
<div>{{name}} - {{nickname}}</div>
</tpl-item>
</vn-autocomplete>
</td>
<td expand>
<vn-autocomplete
ng-model="route.agencyModeFk"
url="AgencyModes"
show-field="name"
value-field="id"
on-change="$ctrl.updateAttributes(route)"
vn-click-stop>
</vn-autocomplete>
</td>
<td expand>
<vn-autocomplete
ng-model="route.vehicleFk"
url="Vehicles"
show-field="numberPlate"
value-field="id"
on-change="$ctrl.updateAttributes(route)"
vn-click-stop>
</vn-autocomplete>
</td >
<td>
<vn-date-picker
ng-model="route.created"
on-change="$ctrl.updateAttributes(route)">
</vn-horizontal>
</td>
<td number>{{::route.m3 | dashIfEmpty}}</td>
<td>
<vn-textfield
ng-model="route.description"
on-change="$ctrl.updateAttributes(route)">
</vn-textfield>
</td>
<td expand>
<vn-input-time
ng-model="route.started"
on-change="$ctrl.updateAttributes(route)">
</vn-input-time>
</td>
<td expand>
<vn-input-time
ng-model="route.finished"
on-change="$ctrl.updateAttributes(route)">
</vn-input-time>
</td>
<td>
<vn-icon-button <vn-icon-button
vn-click-stop="$ctrl.showTicketPopup(route)" vn-click-stop="$ctrl.showTicketPopup(route)"
vn-tooltip="Añadir tickets" vn-tooltip="Añadir tickets"
@ -62,12 +134,14 @@
vn-tooltip="Preview" vn-tooltip="Preview"
icon="preview"> icon="preview">
</vn-icon-button> </vn-icon-button>
</vn-td> </td>
</a> </tr>
</vn-tbody> </tbody>
</vn-table> </table>
</slot-table>
</smart-table>
</vn-card> </vn-card>
</vn-data-viewer> </div>
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
<vn-route-summary <vn-route-summary

View File

@ -102,6 +102,26 @@ export default class Controller extends Section {
throw error; throw error;
}); });
} }
updateAttributes(route) {
if (route.started == null || route.finished == null)
return this.vnApp.showError(this.$t('You must select a valid time'));
if (route.created == null)
return this.vnApp.showError(this.$t('You must select a valid date'));
const params = {
workerFk: route.workerFk,
agencyModeFk: route.agencyModeFk,
vehicleFk: route.vehicleFk,
created: route.created,
description: route.description,
started: route.started,
finished: route.finished
};
const query = `Routes/${route.id}/`;
this.$http.patch(query, params).then(res => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
} }
Controller.$inject = ['$element', '$scope', 'vnReport']; Controller.$inject = ['$element', '$scope', 'vnReport'];

View File

@ -3,5 +3,8 @@ Download selected routes as PDF: Descargar rutas seleccionadas como PDF
Clone selected routes: Clonar rutas seleccionadas Clone selected routes: Clonar rutas seleccionadas
The date can't be empty: La fecha no puede estar vacía The date can't be empty: La fecha no puede estar vacía
Starting date: Fecha de inicio Starting date: Fecha de inicio
Finish: Fin Hour started: Hora inicio
Start: Inicio Hour finished: Hora fin
Go to route: Ir a la ruta
You must select a valid time: Debe seleccionar una hora válida
You must select a valid date: Debe seleccionar una fecha válida