Compare commits

...

11 Commits

Author SHA1 Message Date
Carlos Satorres 365c209d9f refs #5066 metodo getVehiclesSorted
gitea/salix/pipeline/head This commit looks good Details
2023-04-19 15:09:52 +02:00
Carlos Satorres c69864aa3b merge
gitea/salix/pipeline/head This commit looks good Details
2023-04-18 15:53:15 +02:00
Carlos Satorres f13f02c829 refs #5066 e2e
gitea/salix/pipeline/head This commit looks good Details
2023-04-18 15:25:06 +02:00
Carlos Satorres e13ecabddf refs #5066 back y html
gitea/salix/pipeline/head There was a failure building this commit Details
2023-04-14 15:23:10 +02:00
Carlos Satorres fcf7ac0ad7 Merge branch '5066-order-vehicle-by-warehouse' of https://gitea.verdnatura.es/verdnatura/salix into 5066-order-vehicle-by-warehouse
gitea/salix/pipeline/head This commit looks good Details
2023-04-14 08:24:59 +02:00
Carlos Satorres be5cff6a22 refs #5066 implementacion warehouse 2023-04-14 08:24:55 +02:00
Carlos Satorres a1efb356a0 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5066-order-vehicle-by-warehouse 2023-04-13 14:07:16 +02:00
Javi Gallego e3250f62b1 Merge branch 'dev' into 5066-order-vehicle-by-warehouse
gitea/salix/pipeline/head This commit looks good Details
2023-04-03 15:00:16 +02:00
Javi Gallego b22cbbba76 minor changes 2023-04-03 14:58:39 +02:00
Pau e54afb2321 refs #5066 @3h fix back route so that the e2e does not fail
gitea/salix/pipeline/head This commit looks good Details
2023-01-31 11:54:19 +01:00
Pau a378831149 refs#5066 @2h order vehicles by user warehouse
gitea/salix/pipeline/head This commit looks good Details
2023-01-31 09:21:07 +01:00
12 changed files with 157 additions and 18 deletions

View File

@ -0,0 +1,3 @@
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
VALUES
('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee');

View File

@ -22,7 +22,7 @@ describe('Route basic Data path', () => {
nextMonth.setMonth(nextMonth.getMonth() + 1); nextMonth.setMonth(nextMonth.getMonth() + 1);
await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick'); await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick');
await page.autocompleteSearch(selectors.routeBasicData.vehicle, '1111-IMK'); await page.autocompleteSearch(selectors.routeBasicData.vehicle, '3333-BAT - Warehouse One');
await page.pickDate(selectors.routeBasicData.createdDate, nextMonth); await page.pickDate(selectors.routeBasicData.createdDate, nextMonth);
await page.clearInput(selectors.routeBasicData.kmStart); await page.clearInput(selectors.routeBasicData.kmStart);
await page.write(selectors.routeBasicData.kmStart, '1'); await page.write(selectors.routeBasicData.kmStart, '1');
@ -46,7 +46,7 @@ describe('Route basic Data path', () => {
it('should confirm the vehicle was edited', async() => { it('should confirm the vehicle was edited', async() => {
const vehicle = await page.waitToGetProperty(selectors.routeBasicData.vehicle, 'value'); const vehicle = await page.waitToGetProperty(selectors.routeBasicData.vehicle, 'value');
expect(vehicle).toEqual('1111-IMK'); expect(vehicle).toEqual('1111-IMK - Warehouse One');
}); });
it('should confirm the km start was edited', async() => { it('should confirm the km start was edited', async() => {

View File

@ -155,7 +155,11 @@
"Warehouse inventory not set": "Almacén inventario no está establecido", "Warehouse inventory not set": "Almacén inventario no está establecido",
"Component cost not set": "Componente coste no está estabecido", "Component cost not set": "Componente coste no está estabecido",
"Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2", "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2",
<<<<<<< HEAD
"Description cannot be blank": "Description cannot be blank"
=======
"Description cannot be blank": "Description cannot be blank", "Description cannot be blank": "Description cannot be blank",
"Added observation": "Added observation", "Added observation": "Added observation",
"Comment added to client": "Comment added to client" "Comment added to client": "Comment added to client"
>>>>>>> 6f2aa0f618e129f0baf42a6bbbb3f7075d3faf90
} }

View File

@ -273,7 +273,9 @@
"Not exist this branch": "La rama no existe", "Not exist this branch": "La rama no existe",
"This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado",
"Insert a date range": "Inserte un rango de fechas", "Insert a date range": "Inserte un rango de fechas",
"Added observation": "{{user}} añadió esta observacion: {{text}}", "Added observation": "{{user}} añadió esta observacion: {{text}}",
"Comment added to client": "Observación añadida al cliente {{clientFk}}", "Comment added to client": "Observación añadida al cliente {{clientFk}}",
"Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen" "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen",
} "Valid priorities: 1,2,3": "Valid priorities: 1,2,3",
"No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº 2": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº 2"
}

View File

@ -59,12 +59,6 @@ module.exports = Self => {
fields: ['id', 'name'] fields: ['id', 'name']
} }
}, },
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name']
}
},
{ {
relation: 'address', relation: 'address',
scope: { scope: {

View File

@ -0,0 +1,88 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethodCtx('currentWarehouse', {
description: 'Get the vehicles with the ones on the current warehouse first',
accessType: 'READ',
accepts: [{
arg: 'filter',
type: 'object',
description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string`
}],
returns: {
type: 'array',
root: true
},
http: {
path: `/currentWarehouse`,
verb: 'GET'
}
});
Self.currentWarehouse = async(ctx, filter, options) => {
const models = Self.app.models;
const conn = Self.dataSource.connector;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
let worker = await models.UserConfig.findOne({
where: {
userFk: ctx.req.accessToken.userId
},
}, myOptions);
if (!worker) throw new Error('User not found');
/* const query =
`SELECT v.id, v.numberPlate, v.warehouseFk
FROM vehicle v
ORDER BY warehouseFk = ${worker.warehouseFk} DESC`;*/
let stmt = new ParameterizedSQL(
`SELECT v.id, v.numberPlate, v.warehouseFk
FROM vehicle v`,
null, myOptions);
if (filter.order) {
delete filter.order;
let order = 'ORDER BY warehouseFk = ' + worker.warehouseFk + ' DESC';
if (!filter.where) {
stmt.merge(order);
stmt.merge(conn.makeSuffix(filter));
} else {
let limit = filter.limit;
delete filter.limit;
stmt.merge(conn.makeSuffix(filter));
stmt.merge(order);
stmt.merge(conn.makeLimit({limit}));
}
const result = await conn.executeStmt(stmt);
if (tx) await tx.commit();
return result;
} else {
stmt.merge(conn.makeSuffix(filter));
const result = await conn.executeStmt(stmt);
if (tx) await tx.commit();
return result;
}
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,28 @@
module.exports = Self => {
Self.remoteMethod('getVehiclesSorted', {
description: 'Sort the vehicles by a warehouse',
accessType: 'WRITE',
accepts: [{
arg: 'warehouseFk',
type: 'number'
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getVehiclesSorted`,
verb: `POST`
}
});
Self.getVehiclesSorted = async warehouseFk => {
const vehicles = await Self.rawSql(`
SELECT v.id, v.numberPlate, w.name
FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk
ORDER BY v.warehouseFk = ? DESC, v.numberPlate ASC`, [warehouseFk]);
return vehicles;
};
};

View File

@ -0,0 +1,4 @@
module.exports = Self => {
require('../methods/vehicle/currentWarehouse')(Self);
require('../methods/vehicle/getVehiclesSorted')(Self);
};

View File

@ -23,11 +23,14 @@
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete <vn-autocomplete
vn-one vn-one
ng-model="$ctrl.route.vehicleFk" ng-model="$ctrl.route.vehicleFk"
url="Vehicles" data="$ctrl.vehicles"
show-field="numberPlate" show-field="numberPlate"
value-field="id" value-field="id"
label="Vehicle"> label="Vehicle">
<tpl-item>
{{numberPlate}} - {{name}}
</tpl-item>
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>

View File

@ -7,6 +7,19 @@ class Controller extends Section {
this.card.reload() this.card.reload()
); );
} }
constructor($element, $) {
super($element, $);
this.$http.get(`UserConfigs/getUserConfig`)
.then(res => {
if (res && res.data) {
this.$http.post(`Vehicles/getVehiclesSorted`, {warehouseFk: res.data.warehouseFk})
.then(res => {
if (res && res.data)
this.vehicles = res.data;
});
}
});
}
} }
ngModule.vnComponent('vnRouteBasicData', { ngModule.vnComponent('vnRouteBasicData', {

View File

@ -62,7 +62,7 @@
<vn-icon-button <vn-icon-button
icon="link_off" icon="link_off"
class="pointer" class="pointer"
title="{{'Unlink zone' | translate: {zoneName: ticket.zone.name, agencyName: ticket.agencyMode.name} }}" title="{{'Unlink zone' | translate: {zoneName: ticket.zone.name, agencyName: $ctrl.route.agencyMode.name} }}"
ng-click="unlinkZoneConfirmation.show(ticket)"> ng-click="unlinkZoneConfirmation.show(ticket)">
</vn-icon-button> </vn-icon-button>
</vn-td> </vn-td>

View File

@ -165,7 +165,7 @@
<vn-route-ticket-popup <vn-route-ticket-popup
vn-id="ticketPopup" vn-id="ticketPopup"
route="$ctrl.$params" route="$ctrl.route"
parent-reload="$ctrl.$.model.refresh()"> parent-reload="$ctrl.$.model.refresh()">
</vn-route-ticket-popup> </vn-route-ticket-popup>
<div fixed-bottom-right> <div fixed-bottom-right>