refs #5066 copy project from the other
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-04-20 08:23:46 +02:00
parent 6f2aa0f618
commit b45b0ff826
5 changed files with 51 additions and 1 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,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,3 @@
module.exports = Self => {
require('../methods/vehicle/getVehiclesSorted')(Self);
};

View File

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

View File

@ -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', {