2449 - Autocompletion
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
3c203e4c8c
commit
fa344f4ff6
|
@ -248,7 +248,8 @@ export default class Autocomplete extends Field {
|
|||
'where',
|
||||
'order',
|
||||
'limit',
|
||||
'searchFunction'
|
||||
'searchFunction',
|
||||
'whereFunction'
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -290,6 +291,7 @@ ngModule.vnComponent('vnAutocomplete', {
|
|||
limit: '<?',
|
||||
translateFields: '<?',
|
||||
searchFunction: '&?',
|
||||
whereFunction: '&?',
|
||||
fetchFunction: '<?'
|
||||
},
|
||||
transclude: {
|
||||
|
|
|
@ -409,6 +409,9 @@ export default class DropDown extends Popover {
|
|||
? null
|
||||
: this.searchFunction({$search: this._search});
|
||||
|
||||
if (this.whereFunction)
|
||||
this.where = this.whereFunction();
|
||||
|
||||
Object.assign(filter, {
|
||||
fields: this.getFields(),
|
||||
include: this.include,
|
||||
|
|
|
@ -59,21 +59,24 @@
|
|||
initial-data="$ctrl.ticket.companyFk">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-id="agencyMode"
|
||||
vn-one
|
||||
url="AgencyModes/isActive"
|
||||
url="AgencyModes/byWarehouse"
|
||||
label="Agency"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.agencyModeId">
|
||||
ng-model="$ctrl.agencyModeId"
|
||||
where="{warehouseFk: $ctrl.warehouseId}">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
data="zones"
|
||||
url="Zones"
|
||||
label="Zone"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.zoneId"
|
||||
vn-acl="productionBoss">
|
||||
vn-acl="productionBoss"
|
||||
where-function="$ctrl.zoneWhere()">
|
||||
<tpl-item>
|
||||
<span>{{::name}} - Max. {{::hour | date: 'HH:mm'}} h.</span>
|
||||
</tpl-item>
|
||||
|
|
|
@ -56,12 +56,14 @@ class Controller extends Component {
|
|||
set warehouseId(value) {
|
||||
if (value != this.ticket.warehouseFk) {
|
||||
this.ticket.warehouseFk = value;
|
||||
this.getShipped({
|
||||
this.ticket.agencyModeFk = null;
|
||||
this.ticket.zoneFk = null;
|
||||
/* this.getShipped({
|
||||
landed: this.ticket.landed,
|
||||
addressFk: this.ticket.addressFk,
|
||||
agencyModeFk: this.ticket.agencyModeFk,
|
||||
warehouseFk: value
|
||||
});
|
||||
}); */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,6 +243,12 @@ class Controller extends Component {
|
|||
|| !this.ticket.companyFk || !this.ticket.shipped || !this.ticket.landed
|
||||
|| !this.ticket.zoneFk;
|
||||
}
|
||||
|
||||
zoneWhere() {
|
||||
if (this.agencyModeId)
|
||||
return {agencyModeFk: this.agencyModeId};
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketBasicDataStepOne', {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('byWarehouse', {
|
||||
description: 'Returns a list of agencies from a warehouse',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string`
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/byWarehouse`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.byWarehouse = async filter => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const where = {isActive: true};
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
let stmt = new ParameterizedSQL(
|
||||
`SELECT id, name
|
||||
FROM (
|
||||
SELECT DISTINCT am.id, am.name, am.isActive, zw.warehouseFk
|
||||
FROM zoneWarehouse zw
|
||||
JOIN zone z ON z.id = zw.zoneFk
|
||||
JOIN agencyMode am ON am.id = z.agencyModeFk) am`);
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
return conn.executeStmt(stmt);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/agency-mode/byWarehouse')(Self);
|
||||
};
|
Loading…
Reference in New Issue