Merge pull request '4033-route' (#1050) from 4033-route into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1050 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
2cfc3cfe42
|
@ -835,14 +835,16 @@ export default {
|
||||||
confirmButton: '.vn-confirm.shown button[response="accept"]',
|
confirmButton: '.vn-confirm.shown button[response="accept"]',
|
||||||
},
|
},
|
||||||
routeIndex: {
|
routeIndex: {
|
||||||
anyResult: 'vn-table a',
|
anyResult: 'vn-route-index tbody > tr',
|
||||||
firstRouteCheckbox: 'a:nth-child(1) vn-td:nth-child(1) > vn-check',
|
firstRouteCheckbox: 'vn-route-index tbody > tr:nth-child(1) > td:nth-child(1) > vn-check',
|
||||||
addNewRouteButton: 'vn-route-index a[ui-sref="route.create"]',
|
addNewRouteButton: 'vn-route-index a[ui-sref="route.create"]',
|
||||||
cloneButton: 'vn-route-index button > vn-icon[icon="icon-clone"]',
|
cloneButton: 'vn-route-index button > vn-icon[icon="icon-clone"]',
|
||||||
submitClonationButton: 'tpl-buttons > button[response="accept"]',
|
submitClonationButton: 'tpl-buttons > button[response="accept"]',
|
||||||
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
|
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
|
||||||
searchAgencyAutocomlete: 'vn-route-search-panel vn-autocomplete[ng-model="filter.agencyModeFk"]',
|
searchAgencyAutocomlete: 'vn-route-search-panel vn-autocomplete[ng-model="filter.agencyModeFk"]',
|
||||||
advancedSearchButton: 'vn-route-search-panel button[type=submit]',
|
advancedSearchButton: 'vn-route-search-panel button[type=submit]',
|
||||||
|
previewButton: 'vn-route-index tbody > tr:nth-child(7) > td:nth-child(11) > vn-icon-button[icon="preview"]',
|
||||||
|
|
||||||
},
|
},
|
||||||
createRouteView: {
|
createRouteView: {
|
||||||
worker: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
|
worker: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
|
||||||
|
@ -862,6 +864,8 @@ export default {
|
||||||
firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor',
|
firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor',
|
||||||
firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span',
|
firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span',
|
||||||
firstClientDescriptor: '.vn-popover.shown vn-client-descriptor',
|
firstClientDescriptor: '.vn-popover.shown vn-client-descriptor',
|
||||||
|
goToRouteSummaryButton: 'vn-route-summary > vn-card > h5 > a',
|
||||||
|
|
||||||
},
|
},
|
||||||
routeBasicData: {
|
routeBasicData: {
|
||||||
worker: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
|
worker: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
|
||||||
|
|
|
@ -9,7 +9,8 @@ describe('Route summary path', () => {
|
||||||
browser = await getBrowser();
|
browser = await getBrowser();
|
||||||
page = browser.page;
|
page = browser.page;
|
||||||
await page.loginAndModule('employee', 'route');
|
await page.loginAndModule('employee', 'route');
|
||||||
await page.waitToClick('vn-route-index vn-tbody > a:nth-child(7)');
|
await page.waitToClick(selectors.routeIndex.previewButton);
|
||||||
|
await page.waitToClick(selectors.routeSummary.goToRouteSummaryButton);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
|
@ -34,6 +35,8 @@ describe('Route summary path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should click on the first ticket ID making the descriptor popover visible', async() => {
|
it('should click on the first ticket ID making the descriptor popover visible', async() => {
|
||||||
|
await page.waitForState('route.card.summary');
|
||||||
|
await page.waitForTimeout(250);
|
||||||
await page.waitToClick(selectors.routeSummary.firstTicketID);
|
await page.waitToClick(selectors.routeSummary.firstTicketID);
|
||||||
await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor);
|
await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor);
|
||||||
const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor);
|
const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor);
|
||||||
|
|
|
@ -143,9 +143,6 @@
|
||||||
},
|
},
|
||||||
"packingShelve": {
|
"packingShelve": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
|
||||||
"weightByPiece": {
|
|
||||||
"type": "number"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -49,7 +49,8 @@ module.exports = Self => {
|
||||||
a.city,
|
a.city,
|
||||||
am.name AS agencyModeName,
|
am.name AS agencyModeName,
|
||||||
u.nickname AS userNickname,
|
u.nickname AS userNickname,
|
||||||
vn.ticketTotalVolume(t.id) AS volume
|
vn.ticketTotalVolume(t.id) AS volume,
|
||||||
|
tob.description
|
||||||
FROM route r
|
FROM route r
|
||||||
JOIN ticket t ON t.routeFk = r.id
|
JOIN ticket t ON t.routeFk = r.id
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"isOk": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"commissionWorkCenterFk": {
|
"commissionWorkCenterFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,11 @@
|
||||||
label="Hour finished"
|
label="Hour finished"
|
||||||
ng-model="$ctrl.route.finished">
|
ng-model="$ctrl.route.finished">
|
||||||
</vn-input-time>
|
</vn-input-time>
|
||||||
|
<vn-check
|
||||||
|
class="vn-mr-md"
|
||||||
|
label="Is served"
|
||||||
|
ng-model="$ctrl.route.isOk">
|
||||||
|
</vn-check>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textArea
|
<vn-textArea
|
||||||
|
|
|
@ -5,3 +5,4 @@ Km end: Km de fin
|
||||||
Description: Descripción
|
Description: Descripción
|
||||||
Hour started: Hora inicio
|
Hour started: Hora inicio
|
||||||
Hour finished: Hora fin
|
Hour finished: Hora fin
|
||||||
|
Is served: Se ha servido
|
||||||
|
|
|
@ -18,7 +18,8 @@ class Controller extends ModuleCard {
|
||||||
'started',
|
'started',
|
||||||
'finished',
|
'finished',
|
||||||
'cost',
|
'cost',
|
||||||
'zoneFk'
|
'zoneFk',
|
||||||
|
'isOk'
|
||||||
],
|
],
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,8 @@ class Controller extends Descriptor {
|
||||||
recipient: workerUser.emailUser.email,
|
recipient: workerUser.emailUser.email,
|
||||||
id: this.id
|
id: this.id
|
||||||
});
|
});
|
||||||
|
const params = {isOk: true};
|
||||||
|
return this.$http.patch(`Routes/${this.id}`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVolume() {
|
updateVolume() {
|
||||||
|
|
|
@ -1,69 +1,164 @@
|
||||||
<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)">
|
||||||
<vn-multi-check
|
<slot-actions>
|
||||||
model="model">
|
<section class="header">
|
||||||
</vn-multi-check>
|
<vn-tool-bar class="vn-mb-md">
|
||||||
</vn-th>
|
<vn-button
|
||||||
<vn-th field="id" number>Id</vn-th>
|
icon="icon-clone"
|
||||||
<vn-th th-id="worker">Worker</vn-th>
|
ng-show="$ctrl.totalChecked > 0"
|
||||||
<vn-th th-id="agency">Agency</vn-th>
|
ng-click="$ctrl.openClonationDialog()"
|
||||||
<vn-th th-id="vehicle">Vehicle</vn-th>
|
vn-tooltip="Clone selected routes">
|
||||||
<vn-th th-id="created" shrink-date>Date</vn-th>
|
</vn-button>
|
||||||
<vn-th th-id="m3" number>m³</vn-th>
|
<vn-button
|
||||||
<vn-th th-id="description">Description</vn-th>
|
icon="cloud_download"
|
||||||
<vn-th shrink></vn-th>
|
ng-show="$ctrl.totalChecked > 0"
|
||||||
</vn-tr>
|
ng-click="$ctrl.showRouteReport()"
|
||||||
</vn-thead>
|
vn-tooltip="Download selected routes as PDF">
|
||||||
<vn-tbody>
|
</vn-button>
|
||||||
<a ng-repeat="route in model.data"
|
<vn-button
|
||||||
class="clickable vn-tr search-result"
|
icon="check"
|
||||||
ui-sref="route.card.summary({id: {{::route.id}}})"
|
ng-show="$ctrl.totalChecked > 0"
|
||||||
ng-attr-id="{{::route.id}}" vn-droppable="$ctrl.onDrop($event)">
|
ng-click="$ctrl.markAsServed()"
|
||||||
<vn-td shrink>
|
vn-tooltip="Mark as served">
|
||||||
<vn-check
|
</vn-button>
|
||||||
ng-model="route.checked"
|
</section>
|
||||||
vn-click-stop>
|
</slot-actions>
|
||||||
</vn-check>
|
<slot-table>
|
||||||
</vn-td>
|
<table model="model">
|
||||||
<vn-td number>{{::route.id | dashIfEmpty}}</vn-td>
|
<thead>
|
||||||
<vn-td expand>
|
<tr>
|
||||||
<span
|
<th shrink>
|
||||||
class="link"
|
<vn-multi-check
|
||||||
vn-click-stop="workerDescriptor.show($event, route.workerFk)">
|
model="model">
|
||||||
{{::route.workerUserName}}
|
</vn-multi-check>
|
||||||
</span>
|
</th>
|
||||||
</vn-td>
|
<th field="id" number>
|
||||||
<vn-td>{{::route.agencyName | dashIfEmpty}}</vn-td>
|
<span translate>Id</span>
|
||||||
<vn-td>{{::route.vehiclePlateNumber | dashIfEmpty}}</vn-td>
|
</th>
|
||||||
<vn-td shrink-date>{{::route.created | dashIfEmpty | date:'dd/MM/yyyy'}}</vn-td>
|
<th field="workerFk">
|
||||||
<vn-td number>{{::route.m3 | dashIfEmpty}}</vn-td>
|
<span translate>Worker</span>
|
||||||
<vn-td>{{::route.description | dashIfEmpty}}</vn-td>
|
</th>
|
||||||
<vn-td>
|
<th field="agencyName">
|
||||||
<vn-icon-button
|
<span translate>Agency</span>
|
||||||
vn-click-stop="$ctrl.showTicketPopup(route)"
|
</th>
|
||||||
vn-tooltip="Añadir tickets"
|
<th field="vehiclePlateNumber">
|
||||||
icon="icon-ticketAdd">
|
<span translate>Vehicle</span>
|
||||||
</vn-icon-button>
|
</th>
|
||||||
<vn-icon-button
|
<th field="created" shrink-date>
|
||||||
vn-click-stop="$ctrl.preview(route)"
|
<span translate>Date</span>
|
||||||
vn-tooltip="Preview"
|
</th>
|
||||||
icon="preview">
|
<th field="m3" number>
|
||||||
</vn-icon-button>
|
<span translate>m³</span>
|
||||||
</vn-td>
|
</th>
|
||||||
</a>
|
<th field="description">
|
||||||
</vn-tbody>
|
<span translate>Description</span>
|
||||||
</vn-table>
|
</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"
|
||||||
|
ng-attr-id="{{::route.id}}" vn-droppable="$ctrl.onDrop($event)">
|
||||||
|
<td shrink>
|
||||||
|
<vn-check
|
||||||
|
ng-model="route.checked"
|
||||||
|
vn-click-stop>
|
||||||
|
</vn-check>
|
||||||
|
</td>
|
||||||
|
<td number>{{::route.id | dashIfEmpty}}</td>
|
||||||
|
<td>
|
||||||
|
<vn-autocomplete
|
||||||
|
ng-model="route.workerFk"
|
||||||
|
url="Workers/activeWithInheritedRole"
|
||||||
|
show-field="nickname"
|
||||||
|
search-function="{firstName: $search}"
|
||||||
|
value-field="id"
|
||||||
|
where="{role: 'employee'}"
|
||||||
|
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-click-stop="$ctrl.showTicketPopup(route)"
|
||||||
|
vn-tooltip="Añadir tickets"
|
||||||
|
icon="icon-ticketAdd">
|
||||||
|
</vn-icon-button>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-click-stop="$ctrl.preview(route)"
|
||||||
|
vn-tooltip="Preview"
|
||||||
|
icon="preview">
|
||||||
|
</vn-icon-button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</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
|
||||||
|
@ -88,20 +183,6 @@
|
||||||
|
|
||||||
<div fixed-bottom-right>
|
<div fixed-bottom-right>
|
||||||
<vn-vertical style="align-items: center;">
|
<vn-vertical style="align-items: center;">
|
||||||
<vn-button class="round sm vn-mb-sm"
|
|
||||||
icon="icon-clone"
|
|
||||||
ng-show="$ctrl.totalChecked > 0"
|
|
||||||
ng-click="$ctrl.openClonationDialog()"
|
|
||||||
vn-tooltip="Clone selected routes"
|
|
||||||
tooltip-position="left">
|
|
||||||
</vn-button>
|
|
||||||
<vn-button class="round sm vn-mb-sm"
|
|
||||||
icon="cloud_download"
|
|
||||||
ng-show="$ctrl.totalChecked > 0"
|
|
||||||
ng-click="$ctrl.showRouteReport()"
|
|
||||||
vn-tooltip="Download selected routes as PDF"
|
|
||||||
tooltip-position="left">
|
|
||||||
</vn-button>
|
|
||||||
<a ui-sref="route.create" vn-bind="+">
|
<a ui-sref="route.create" vn-bind="+">
|
||||||
<vn-button class="round md vn-mb-sm"
|
<vn-button class="round md vn-mb-sm"
|
||||||
icon="add"
|
icon="add"
|
||||||
|
|
|
@ -102,6 +102,36 @@ 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!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
markAsServed() {
|
||||||
|
const routes = [];
|
||||||
|
for (let route of this.checked)
|
||||||
|
routes.push(route.id);
|
||||||
|
|
||||||
|
const params = {isOk: true};
|
||||||
|
for (let routeId of routes)
|
||||||
|
this.$http.patch(`Routes/${routeId}`, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', 'vnReport'];
|
Controller.$inject = ['$element', '$scope', 'vnReport'];
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('Component vnRouteIndex', () => {
|
||||||
const $element = angular.element('<vn-route-index></vn-route-index>');
|
const $element = angular.element('<vn-route-index></vn-route-index>');
|
||||||
controller = $componentController('vnRouteIndex', {$element});
|
controller = $componentController('vnRouteIndex', {$element});
|
||||||
controller.$.model = crudModel;
|
controller.$.model = crudModel;
|
||||||
controller.$.model.data = [{id: 1}, {id: 2}, {id: 3}];
|
controller.$.model.data = [{id: 1, checked: true}, {id: 2}, {id: 3}];
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('checked() getter', () => {
|
describe('checked() getter', () => {
|
||||||
|
@ -148,4 +148,13 @@ describe('Component vnRouteIndex', () => {
|
||||||
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('markAsServed()', () => {
|
||||||
|
it('should perform a HTTP patch query', () => {
|
||||||
|
const data = {isOk: true};
|
||||||
|
$httpBackend.expect('PATCH', `Routes/1`, data).respond();
|
||||||
|
controller.markAsServed();
|
||||||
|
$httpBackend.flush();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,3 +3,9 @@ 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
|
||||||
|
Hour started: Hora 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
|
||||||
|
Mark as served: Marcar como servidas
|
|
@ -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"
|
||||||
|
@ -24,10 +25,19 @@
|
||||||
vn-tooltip="Open buscaman"
|
vn-tooltip="Open buscaman"
|
||||||
icon="icon-buscaman">
|
icon="icon-buscaman">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
|
<vn-button
|
||||||
|
disabled="!$ctrl.isChecked"
|
||||||
|
ng-click="$ctrl.deletePriority()"
|
||||||
|
vn-tooltip="Delete priority"
|
||||||
|
icon="filter_alt_off">
|
||||||
|
</vn-button>
|
||||||
|
<vn-button
|
||||||
|
ng-click="$ctrl.setOrderedPriority($ctrl.tickets)"
|
||||||
|
vn-tooltip="Renumber all tickets in the order you see on the screen"
|
||||||
|
icon="format_list_numbered">
|
||||||
|
</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>
|
||||||
|
@ -35,6 +45,7 @@
|
||||||
model="model">
|
model="model">
|
||||||
</vn-multi-check>
|
</vn-multi-check>
|
||||||
</vn-th>
|
</vn-th>
|
||||||
|
<vn-th shrink></vn-th>
|
||||||
<vn-th field="priority">Order</vn-th>
|
<vn-th field="priority">Order</vn-th>
|
||||||
<vn-th field="street" expand>Street</vn-th>
|
<vn-th field="street" expand>Street</vn-th>
|
||||||
<vn-th field="city">City</vn-th>
|
<vn-th field="city">City</vn-th>
|
||||||
|
@ -45,6 +56,7 @@
|
||||||
<vn-th field="id" number>Ticket</vn-th>
|
<vn-th field="id" number>Ticket</vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
|
<vn-th shrink></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
|
@ -54,13 +66,20 @@
|
||||||
ng-model="ticket.checked">
|
ng-model="ticket.checked">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
<vn-td>
|
||||||
|
<vn-icon-button
|
||||||
|
icon="low_priority"
|
||||||
|
ng-click="$ctrl.setHighestPriority(ticket)"
|
||||||
|
vn-tooltip="Assign highest priority"
|
||||||
|
tabindex="-1">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
|
on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
|
||||||
ng-model="ticket.priority"
|
ng-model="ticket.priority"
|
||||||
rule="Ticket"
|
rule="Ticket"
|
||||||
class="dense"
|
class="dense">
|
||||||
display-controls=true>
|
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td expand title="{{::ticket.street}}">{{::ticket.street}}</vn-td>
|
<vn-td expand title="{{::ticket.street}}">{{::ticket.street}}</vn-td>
|
||||||
|
@ -98,9 +117,18 @@
|
||||||
tabindex="-1">
|
tabindex="-1">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
</vn-tr>
|
<vn-td>
|
||||||
|
<vn-icon-button
|
||||||
|
ng-if="::ticket.description"
|
||||||
|
vn-tooltip="{{::ticket.description}}"
|
||||||
|
icon="icon-notes"
|
||||||
|
tabindex="-1">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-td>
|
||||||
|
</a>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
|
</section>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</form>
|
</form>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
|
|
|
@ -20,15 +20,48 @@ class Controller extends Section {
|
||||||
return highestPriority + 1;
|
return highestPriority + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHighestPriority(ticket) {
|
||||||
|
const highestPriority = this.getHighestPriority();
|
||||||
|
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) {
|
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();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletePriority() {
|
||||||
|
const lines = this.getSelectedItems(this.tickets);
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
this.$http.patch(`Tickets/${line.id}/`, {priority: null}).then(() => {
|
||||||
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
|
this.$.model.refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = [];
|
||||||
|
|
||||||
|
@ -57,8 +90,10 @@ class Controller extends Section {
|
||||||
let lines = this.getSelectedItems(this.tickets);
|
let lines = this.getSelectedItems(this.tickets);
|
||||||
|
|
||||||
let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=';
|
let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=';
|
||||||
lines.forEach(line => {
|
lines.forEach((line, index) => {
|
||||||
addresses = addresses + '+to:' + line.postalCode + ' ' + line.city + ' ' + line.street;
|
const previusLine = lines[index - 1] ? lines[index - 1].street : null;
|
||||||
|
if (previusLine != line.street)
|
||||||
|
addresses = addresses + '+to:' + line.postalCode + ' ' + line.city + ' ' + line.street;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.open(url + addresses, '_blank');
|
window.open(url + addresses, '_blank');
|
||||||
|
|
|
@ -58,9 +58,23 @@ describe('Route', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setHighestPriority()', () => {
|
||||||
|
it('should set a ticket highest priority', () => {
|
||||||
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
controller.$.model.data = [{priority: 3}];
|
||||||
|
const ticket = {id: 1, priority: 2};
|
||||||
|
const res = {data: {priority: 4}};
|
||||||
|
|
||||||
|
$httpBackend.expectPATCH(`Tickets/${ticket.id}/`).respond(res);
|
||||||
|
controller.setHighestPriority(ticket);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('setPriority()', () => {
|
describe('setPriority()', () => {
|
||||||
it('should set a ticket priority', () => {
|
it('should set a ticket priority', () => {
|
||||||
jest.spyOn(controller.$.model, 'refresh');
|
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
const ticketId = 1;
|
const ticketId = 1;
|
||||||
const priority = 999;
|
const priority = 999;
|
||||||
|
@ -69,6 +83,35 @@ describe('Route', () => {
|
||||||
controller.setPriority(ticketId, priority);
|
controller.setPriority(ticketId, priority);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('deletePriority()', () => {
|
||||||
|
it('should delete priority of all tickets', () => {
|
||||||
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
controller.tickets = [{id: 1, checked: true}];
|
||||||
|
|
||||||
|
$httpBackend.expectPATCH(`Tickets/${controller.tickets[0].id}/`).respond();
|
||||||
|
controller.deletePriority();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||||
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('setOrderedPriority()', () => {
|
||||||
|
it('should set priority of all tickets starting by 1', () => {
|
||||||
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
const tickets = [{id: 1, checked: true}];
|
||||||
|
|
||||||
|
$httpBackend.expectPATCH(`Tickets/${tickets[0].id}/`).respond();
|
||||||
|
controller.setOrderedPriority(tickets);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||||
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,3 +13,6 @@ The route's vehicle doesn't have a delivery point: El vehículo de la ruta no ti
|
||||||
The route doesn't have a vehicle: La ruta no tiene un vehículo
|
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
|
||||||
|
Renumber all tickets in the order you see on the screen: Renumerar todos los tickets con el orden que ves por pantalla
|
||||||
|
Assign highest priority: Asignar máxima prioridad
|
Loading…
Reference in New Issue