Compare commits
11 Commits
dev
...
5066-order
Author | SHA1 | Date |
---|---|---|
Carlos Satorres | 365c209d9f | |
Carlos Satorres | c69864aa3b | |
Carlos Satorres | f13f02c829 | |
Carlos Satorres | e13ecabddf | |
Carlos Satorres | fcf7ac0ad7 | |
Carlos Satorres | be5cff6a22 | |
Carlos Satorres | a1efb356a0 | |
Javi Gallego | e3250f62b1 | |
Javi Gallego | b22cbbba76 | |
Pau | e54afb2321 | |
Pau | a378831149 |
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES
|
||||
('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee');
|
|
@ -22,7 +22,7 @@ describe('Route basic Data path', () => {
|
|||
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
||||
|
||||
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.clearInput(selectors.routeBasicData.kmStart);
|
||||
await page.write(selectors.routeBasicData.kmStart, '1');
|
||||
|
@ -46,7 +46,7 @@ describe('Route basic Data path', () => {
|
|||
it('should confirm the vehicle was edited', async() => {
|
||||
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() => {
|
||||
|
|
|
@ -155,7 +155,11 @@
|
|||
"Warehouse inventory not set": "Almacén inventario no está establecido",
|
||||
"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",
|
||||
<<<<<<< HEAD
|
||||
"Description cannot be blank": "Description cannot be blank"
|
||||
=======
|
||||
"Description cannot be blank": "Description cannot be blank",
|
||||
"Added observation": "Added observation",
|
||||
"Comment added to client": "Comment added to client"
|
||||
>>>>>>> 6f2aa0f618e129f0baf42a6bbbb3f7075d3faf90
|
||||
}
|
|
@ -273,7 +273,9 @@
|
|||
"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",
|
||||
"Insert a date range": "Inserte un rango de fechas",
|
||||
"Added observation": "{{user}} añadió esta observacion: {{text}}",
|
||||
"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"
|
||||
}
|
||||
"Added observation": "{{user}} añadió esta observacion: {{text}}",
|
||||
"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",
|
||||
"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"
|
||||
}
|
|
@ -59,12 +59,6 @@ module.exports = Self => {
|
|||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'agencyMode',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'address',
|
||||
scope: {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -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;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/vehicle/currentWarehouse')(Self);
|
||||
require('../methods/vehicle/getVehiclesSorted')(Self);
|
||||
};
|
|
@ -23,11 +23,14 @@
|
|||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.route.vehicleFk"
|
||||
url="Vehicles"
|
||||
show-field="numberPlate"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.route.vehicleFk"
|
||||
data="$ctrl.vehicles"
|
||||
show-field="numberPlate"
|
||||
value-field="id"
|
||||
label="Vehicle">
|
||||
<tpl-item>
|
||||
{{numberPlate}} - {{name}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
|
|
|
@ -7,6 +7,19 @@ class Controller extends Section {
|
|||
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', {
|
||||
|
|
|
@ -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: $ctrl.route.agencyMode.name} }}"
|
||||
ng-click="unlinkZoneConfirmation.show(ticket)">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
|
||||
<vn-route-ticket-popup
|
||||
vn-id="ticketPopup"
|
||||
route="$ctrl.$params"
|
||||
route="$ctrl.route"
|
||||
parent-reload="$ctrl.$.model.refresh()">
|
||||
</vn-route-ticket-popup>
|
||||
<div fixed-bottom-right>
|
||||
|
|
Loading…
Reference in New Issue