Merge pull request '6146-route-sugestedTicket-error' (!1722) from 6146-route-sugestedTicket-error into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1722
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Javi Gallego 2023-08-25 12:54:52 +00:00
commit cfbd24c721
2 changed files with 23 additions and 8 deletions

View File

@ -24,7 +24,14 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const route = await Self.app.models.Route.findById(id, null, myOptions);
const route = await Self.app.models.Route.findById(id, {
include: {
relation: 'agencyMode',
scope: {
fields: ['name']
}
}
}, myOptions);
const zoneAgencyModes = await Self.app.models.ZoneAgencyMode.find({
where: {
@ -35,11 +42,13 @@ module.exports = Self => {
const zoneIds = [];
for (let zoneAgencyMode of zoneAgencyModes)
zoneIds.push(zoneAgencyMode.zoneFk);
const minDate = new Date(route.created);
minDate.setHours(0, 0, 0, 0);
const maxDate = new Date(route.created);
maxDate.setHours(23, 59, 59, 59);
let tickets = await Self.app.models.Ticket.find({
where: {
zoneFk: {inq: zoneIds},
@ -80,6 +89,12 @@ module.exports = Self => {
]
}, myOptions);
return tickets;
return tickets.map(ticket => {
const simpleTicket = ticket.toJSON();
return {
...simpleTicket,
agencyName: route.agencyMode().name
};
});
};
};

View File

@ -19,17 +19,17 @@
<vn-thead>
<vn-tr>
<vn-th shrink>
<vn-multi-check
<vn-multi-check
model="model">
</vn-multi-check>
</vn-th>
<vn-th number>Ticket</vn-th>
<vn-th>Client</vn-th>
<vn-th shrink>Province</vn-th>
<vn-th shrink>
<vn-th shrink>
<span translate>
Population
</span>
Population
</span>
</vn-th>
<vn-th expand>PC</vn-th>
<vn-th>Address</vn-th>
@ -39,7 +39,7 @@
<vn-tbody>
<vn-tr ng-repeat="ticket in $ctrl.possibleTickets">
<vn-td shrink>
<vn-check
<vn-check
ng-model="ticket.checked">
</vn-check>
</vn-td>
@ -62,7 +62,7 @@
<vn-icon-button
icon="link_off"
class="pointer"
title="{{'Unlink zone' | translate: {zoneName: ticket.zone.name, agencyName: ticket.agencyMode.name} }}"
title="{{'Unlink zone' | translate: {zoneName: ticket.zone.name, agencyName: ticket.agencyName} }}"
ng-click="unlinkZoneConfirmation.show(ticket)">
</vn-icon-button>
</vn-td>