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 values = {
|
||||
worker: 'adminBossNick',
|
||||
vehicle: '1111-IMK - Warehouse One',
|
||||
vehicle: '1111-IMK',
|
||||
created: nextMonth,
|
||||
kmStart: 1,
|
||||
kmEnd: 2,
|
||||
|
|
|
@ -174,6 +174,7 @@ export default class Autocomplete extends Field {
|
|||
|
||||
refreshDisplayed() {
|
||||
let display = '';
|
||||
let hasTemplate = this.$transclude && this.$transclude.isSlotFilled('tplItem');
|
||||
|
||||
if (this._selection && this.showField) {
|
||||
if (this.multiple && Array.isArray(this._selection)) {
|
||||
|
@ -181,8 +182,19 @@ export default class Autocomplete extends Field {
|
|||
if (display.length > 0) display += ', ';
|
||||
display += item[this.showField];
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
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;
|
||||
|
|
|
@ -18,11 +18,13 @@ module.exports = Self => {
|
|||
|
||||
Self.getVehiclesSorted = async warehouseFk => {
|
||||
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
|
||||
JOIN warehouse w ON w.id = v.warehouseFk
|
||||
ORDER BY v.warehouseFk = ? DESC, v.numberPlate ASC`, [warehouseFk]);
|
||||
|
||||
JOIN warehouse w ON w.id = v.warehouseFk
|
||||
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]);
|
||||
return vehicles;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -25,19 +25,17 @@
|
|||
<vn-autocomplete
|
||||
ng-model="$ctrl.route.vehicleFk"
|
||||
data="$ctrl.vehicles"
|
||||
show-field="numberPlate"
|
||||
show-field="description"
|
||||
order="order"
|
||||
value-field="id"
|
||||
label="Vehicle">
|
||||
<tpl-item>
|
||||
{{numberPlate}} - {{name}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
label="Created"
|
||||
ng-model="$ctrl.route.created"
|
||||
vn-name="created">
|
||||
vn-name="created">
|
||||
</vn-date-picker>
|
||||
<vn-autocomplete
|
||||
ng-model="$ctrl.route.agencyModeFk"
|
||||
|
|
Loading…
Reference in New Issue