This commit is contained in:
parent
91edc09057
commit
d8e7c2700a
|
@ -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 - Warehouse One',
|
vehicle: '1111-IMK',
|
||||||
created: nextMonth,
|
created: nextMonth,
|
||||||
kmStart: 1,
|
kmStart: 1,
|
||||||
kmEnd: 2,
|
kmEnd: 2,
|
||||||
|
|
|
@ -174,6 +174,7 @@ 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)) {
|
||||||
|
@ -181,8 +182,19 @@ 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;
|
||||||
|
|
|
@ -18,11 +18,13 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.getVehiclesSorted = async warehouseFk => {
|
Self.getVehiclesSorted = async warehouseFk => {
|
||||||
const vehicles = await Self.rawSql(`
|
const vehicles = await Self.rawSql(`
|
||||||
SELECT v.id, v.numberPlate, w.name
|
SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order',
|
||||||
|
v.id,
|
||||||
|
v.warehouseFk,
|
||||||
|
CONCAT(v.numberPlate, ' - ', w.name) as description
|
||||||
FROM vehicle v
|
FROM vehicle v
|
||||||
JOIN warehouse w ON w.id = v.warehouseFk
|
JOIN warehouse w ON w.id = v.warehouseFk
|
||||||
ORDER BY v.warehouseFk = ? DESC, v.numberPlate ASC`, [warehouseFk]);
|
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]);
|
||||||
|
|
||||||
return vehicles;
|
return vehicles;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,12 +25,10 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
ng-model="$ctrl.route.vehicleFk"
|
ng-model="$ctrl.route.vehicleFk"
|
||||||
data="$ctrl.vehicles"
|
data="$ctrl.vehicles"
|
||||||
show-field="numberPlate"
|
show-field="description"
|
||||||
|
order="order"
|
||||||
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>
|
||||||
|
|
Loading…
Reference in New Issue