refs #5066 back y html
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-04-14 15:23:10 +02:00
parent fcf7ac0ad7
commit e13ecabddf
5 changed files with 41 additions and 4 deletions

View File

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

View File

@ -0,0 +1,31 @@
module.exports = Self => {
Self.remoteMethodCtx('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(ctx, options) => {
const args = ctx.args;
const vehicles = await Self.rawSql(`
SELECT v.id, v.numberPlate, w.name
FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk
WHERE v.warehouseFk = ?
ORDER BY v.warehouseFk DESC, v.numberPlate ASC`, args.warehouseFk);
return [vehicles];
};
};

View File

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

View File

@ -25,16 +25,14 @@
<vn-autocomplete
vn-one
ng-model="$ctrl.route.vehicleFk"
url="Vehicles"
fields="['warehouseFk']"
include="{relation: 'warehouse'}"
data="$ctrl.vehicles"
show-field="numberPlate"
value-field="id"
label="Vehicle">
<tpl-item>
{{numberPlate}} - {{warehouse.name}}
</tpl-item>
</vn-autocomplete>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker

View File

@ -7,6 +7,10 @@ class Controller extends Section {
this.card.reload()
);
}
constructor($element, $) {
super($element, $);
this.$http.post(`Vehicles/getVehiclesSorted`, {params: {warehouseFk: 1}});
}
}
ngModule.vnComponent('vnRouteBasicData', {