5066-vehicleSorted #1467
|
@ -1,3 +1,3 @@
|
||||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||||
VALUES
|
VALUES
|
||||||
('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee');
|
('Vehicle','sorted','WRITE','ALLOW','employee');
|
|
@ -24,7 +24,7 @@ describe('Route basic Data path', () => {
|
||||||
const form = 'vn-route-basic-data form';
|
const form = 'vn-route-basic-data form';
|
||||||
const values = {
|
const values = {
|
||||||
worker: 'adminBossNick',
|
worker: 'adminBossNick',
|
||||||
vehicle: '1111-IMK',
|
vehicle: '1111-IMK - Warehouse One',
|
||||||
created: nextMonth,
|
created: nextMonth,
|
||||||
kmStart: 1,
|
kmStart: 1,
|
||||||
kmEnd: 2,
|
kmEnd: 2,
|
||||||
|
|
|
@ -174,7 +174,6 @@ export default class Autocomplete extends Field {
|
||||||
|
|
||||||
refreshDisplayed() {
|
refreshDisplayed() {
|
||||||
let display = '';
|
let display = '';
|
||||||
let hasTemplate = this.$transclude && this.$transclude.isSlotFilled('tplItem');
|
|
||||||
|
|
||||||
if (this._selection && this.showField) {
|
if (this._selection && this.showField) {
|
||||||
if (this.multiple && Array.isArray(this._selection)) {
|
if (this.multiple && Array.isArray(this._selection)) {
|
||||||
|
@ -182,19 +181,8 @@ export default class Autocomplete extends Field {
|
||||||
if (display.length > 0) display += ', ';
|
if (display.length > 0) display += ', ';
|
||||||
display += item[this.showField];
|
display += item[this.showField];
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
display = this._selection[this.showField];
|
display = this._selection[this.showField];
|
||||||
if (hasTemplate) {
|
|
||||||
let template = this.$transclude(() => {}, null, 'tplItem');
|
|
||||||
const element = template[0];
|
|
||||||
const description = element.querySelector('.text-secondary');
|
|
||||||
if (description) description.remove();
|
|
||||||
|
|
||||||
const displayElement = angular.element(element);
|
|
||||||
const displayText = displayElement.text();
|
|
||||||
display = this.$interpolate(displayText)(this._selection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.input.value = display;
|
this.input.value = display;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getVehiclesSorted', {
|
Self.remoteMethod('sorted', {
|
||||||
description: 'Sort the vehicles by warehouse',
|
description: 'Sort the vehicles by warehouse',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -11,12 +11,12 @@ module.exports = Self => {
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
path: `/getVehiclesSorted`,
|
path: `/sorted`,
|
||||||
verb: `POST`
|
verb: `POST`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getVehiclesSorted = async warehouseFk => {
|
Self.sorted = async warehouseFk => {
|
||||||
const vehicles = await Self.rawSql(`
|
const vehicles = await Self.rawSql(`
|
||||||
SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order',
|
SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order',
|
||||||
v.id,
|
v.id,
|
|
@ -1,3 +1,3 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/vehicle/getVehiclesSorted')(Self);
|
require('../methods/vehicle/sorted')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
show-field="description"
|
show-field="description"
|
||||||
order="order"
|
order="order"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
label="Vehicle">
|
label="Vehicle"
|
||||||
|
vn-name="vehicle">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Controller extends Section {
|
||||||
this.$http.get(`UserConfigs/getUserConfig`)
|
this.$http.get(`UserConfigs/getUserConfig`)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
this.$http.post(`Vehicles/getVehiclesSorted`, {warehouseFk: res.data.warehouseFk})
|
this.$http.post(`Vehicles/sorted`, {warehouseFk: res.data.warehouseFk})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res && res.data)
|
if (res && res.data)
|
||||||
this.vehicles = res.data;
|
this.vehicles = res.data;
|
||||||
|
|
Loading…
Reference in New Issue