refs #5517 Filter improved
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
a053764122
commit
49368a837b
|
@ -3,13 +3,18 @@
|
||||||
url="{{$ctrl.url}}"
|
url="{{$ctrl.url}}"
|
||||||
filter="$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
link="{originFk: $ctrl.originId}"
|
link="{originFk: $ctrl.originId}"
|
||||||
where="{changedModel: $ctrl.changedModel,
|
where="{changedModel: $ctrl.changedModel, changedModelId: $ctrl.changedModelId}"
|
||||||
changedModelId: $ctrl.changedModelId}"
|
|
||||||
data="$ctrl.logs"
|
data="$ctrl.logs"
|
||||||
order="creationDate DESC, id DESC"
|
order="creationDate DESC, id DESC"
|
||||||
limit="20"
|
limit="20"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
<vn-crud-model
|
||||||
|
url="{{$ctrl.url}}/{{$ctrl.originId}}/models"
|
||||||
|
data="models"
|
||||||
|
order="changedModel"
|
||||||
|
auto-load="true">
|
||||||
|
</vn-crud-model>
|
||||||
<vn-data-viewer model="model" class="vn-w-md">
|
<vn-data-viewer model="model" class="vn-w-md">
|
||||||
<vn-card>
|
<vn-card>
|
||||||
<table class="vn-table" model="model">
|
<table class="vn-table" model="model">
|
||||||
|
@ -120,10 +125,13 @@
|
||||||
ng-submit="$ctrl.applyFilter(filter)"
|
ng-submit="$ctrl.applyFilter(filter)"
|
||||||
ng-model-options="{updateOn: 'change blur'}"
|
ng-model-options="{updateOn: 'change blur'}"
|
||||||
class="vn-pa-md filter">
|
class="vn-pa-md filter">
|
||||||
<vn-textfield
|
<vn-autocomplete
|
||||||
label="Model"
|
label="Model"
|
||||||
ng-model="filter.changedModel">
|
ng-model="filter.changedModel"
|
||||||
</vn-textfield>
|
value-field="changedModel"
|
||||||
|
show-field="changedModel"
|
||||||
|
data="models">
|
||||||
|
</vn-autocomplete>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Id"
|
label="Id"
|
||||||
ng-model="filter.changedModelId">
|
ng-model="filter.changedModelId">
|
||||||
|
@ -135,7 +143,8 @@
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
fields="['id', 'name', 'nickname']"
|
fields="['id', 'name', 'nickname']"
|
||||||
search-function="$ctrl.searchUser($search)"
|
search-function="$ctrl.searchUser($search)"
|
||||||
url="VnUsers">
|
url="{{$ctrl.url}}/{{$ctrl.originId}}/editors"
|
||||||
|
order="nickname">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
<div>{{nickname}}</div>
|
<div>{{nickname}}</div>
|
||||||
<div class="text-secondary text-caption">{{name}}</div>
|
<div class="text-secondary text-caption">{{name}}</div>
|
||||||
|
@ -172,7 +181,7 @@
|
||||||
ng-model="filter.to">
|
ng-model="filter.to">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-button-bar vn-vertical class="vn-mt-sm">
|
<vn-button-bar vn-vertical class="vn-mt-sm">
|
||||||
<vn-submit label="Buscar"></vn-submit>
|
<vn-submit label="Filter"></vn-submit>
|
||||||
<vn-button
|
<vn-button
|
||||||
label="Reset"
|
label="Reset"
|
||||||
class="flat"
|
class="flat"
|
||||||
|
|
|
@ -21,9 +21,6 @@ export default class Controller extends Section {
|
||||||
};
|
};
|
||||||
|
|
||||||
$.filter = {};
|
$.filter = {};
|
||||||
$.$watch('filter.actions', () => this.applyFilter(), true);
|
|
||||||
$.$watch('filter.from', () => $.filter.to = $.filter.from);
|
|
||||||
|
|
||||||
this.filter = {
|
this.filter = {
|
||||||
include: [{
|
include: [{
|
||||||
relation: 'user',
|
relation: 'user',
|
||||||
|
@ -45,6 +42,23 @@ export default class Controller extends Section {
|
||||||
this.today.setHours(0, 0, 0, 0);
|
this.today.setHours(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$onInit() {
|
||||||
|
const {$} = this;
|
||||||
|
$.$watch(
|
||||||
|
() => [
|
||||||
|
$.filter.actions,
|
||||||
|
$.filter.changedModel,
|
||||||
|
$.filter.userFk
|
||||||
|
],
|
||||||
|
() => this.applyFilter(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$.$watch(
|
||||||
|
() => $.filter.from,
|
||||||
|
() => $.filter.to = $.filter.from
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
get logs() {
|
get logs() {
|
||||||
return this._logs;
|
return this._logs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('editors', {
|
||||||
|
description: 'Get the list of entity editors',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'The model id',
|
||||||
|
required: true
|
||||||
|
}, {
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'Object',
|
||||||
|
description: 'The user filter object'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: [Self],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/editors`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.editors = async(id, filter) => {
|
||||||
|
const res = await Self.find({
|
||||||
|
fields: ['userFk'],
|
||||||
|
where: {originFk: id}
|
||||||
|
});
|
||||||
|
const userIds = new Set(res.map(x => x.userFk));
|
||||||
|
|
||||||
|
filter = mergeFilters(filter, {
|
||||||
|
where: {id: {inq: [...userIds]}}
|
||||||
|
});
|
||||||
|
return await Self.app.models.VnUser.find(filter);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,44 @@
|
||||||
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('models', {
|
||||||
|
description: 'Get the list of entity models',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'The model id',
|
||||||
|
required: true
|
||||||
|
}, {
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'Object',
|
||||||
|
description: 'The filter object'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: [Self],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/models`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.models = async(id, filter) => {
|
||||||
|
filter = mergeFilters(filter, {
|
||||||
|
fields: ['changedModel'],
|
||||||
|
where: {
|
||||||
|
originFk: id,
|
||||||
|
changedModel: {neq: null}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const res = await Self.find(filter);
|
||||||
|
|
||||||
|
const set = new Set();
|
||||||
|
return res.filter(x => set.has(x.changedModel)
|
||||||
|
? false
|
||||||
|
: set.add(x.changedModel)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
module.exports = function(Self) {
|
||||||
|
Object.assign(Self, {
|
||||||
|
setup() {
|
||||||
|
Self.super_.setup.call(this);
|
||||||
|
require('../methods/log/editors')(this);
|
||||||
|
require('../methods/log/models')(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name": "Log",
|
||||||
|
"base": "VnModel"
|
||||||
|
}
|
|
@ -28,12 +28,14 @@ module.exports = function(Self) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register field ACL validation
|
// Register field ACL validation
|
||||||
/* this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx));
|
/*
|
||||||
|
this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx));
|
||||||
this.beforeRemote('updateAll', ctx => this.checkUpdateAcls(ctx));
|
this.beforeRemote('updateAll', ctx => this.checkUpdateAcls(ctx));
|
||||||
this.beforeRemote('patchOrCreate', ctx => this.checkInsertAcls(ctx));
|
this.beforeRemote('patchOrCreate', ctx => this.checkInsertAcls(ctx));
|
||||||
this.beforeRemote('create', ctx => this.checkInsertAcls(ctx));
|
this.beforeRemote('create', ctx => this.checkInsertAcls(ctx));
|
||||||
this.beforeRemote('replaceById', ctx => this.checkInsertAcls(ctx));
|
this.beforeRemote('replaceById', ctx => this.checkInsertAcls(ctx));
|
||||||
this.beforeRemote('replaceOrCreate', ctx => this.checkInsertAcls(ctx)); */
|
this.beforeRemote('replaceOrCreate', ctx => this.checkInsertAcls(ctx));
|
||||||
|
*/
|
||||||
|
|
||||||
this.remoteMethod('crud', {
|
this.remoteMethod('crud', {
|
||||||
description: `Create, update or/and delete instances from model with a single request`,
|
description: `Create, update or/and delete instances from model with a single request`,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "RoleLog",
|
"name": "RoleLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "account.roleLog"
|
"table": "account.roleLog"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "UserLog",
|
"name": "UserLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "account.userLog"
|
"table": "account.userLog"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimLog",
|
"name": "ClaimLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimLog"
|
"table": "claimLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ClientLog",
|
"name": "ClientLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "clientLog"
|
"table": "clientLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "EntryLog",
|
"name": "EntryLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "entryLog"
|
"table": "entryLog"
|
||||||
|
@ -55,4 +55,4 @@
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "InvoiceInLog",
|
"name": "InvoiceInLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "invoiceInLog"
|
"table": "invoiceInLog"
|
||||||
|
@ -58,4 +58,4 @@
|
||||||
"id DESC"
|
"id DESC"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ItemLog",
|
"name": "ItemLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "itemLog"
|
"table": "itemLog"
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"forceId": false
|
"forceId": false
|
||||||
},
|
},
|
||||||
"originFk": {
|
"originFk": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "RouteLog",
|
"name": "RouteLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "routeLog"
|
"table": "routeLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ShelvingLog",
|
"name": "ShelvingLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "shelvingLog"
|
"table": "shelvingLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "SupplierLog",
|
"name": "SupplierLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "supplierLog"
|
"table": "supplierLog"
|
||||||
|
@ -55,4 +55,4 @@
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "TicketLog",
|
"name": "TicketLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "ticketLog"
|
"table": "ticketLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "TravelLog",
|
"name": "TravelLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "travelLog"
|
"table": "travelLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "DeviceProductionLog",
|
"name": "DeviceProductionLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "deviceProductionLog"
|
"table": "deviceProductionLog"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "WorkerLog",
|
"name": "WorkerLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "workerLog"
|
"table": "workerLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ZoneLog",
|
"name": "ZoneLog",
|
||||||
"base": "VnModel",
|
"base": "Log",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "zoneLog"
|
"table": "zoneLog"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"order": ["creationDate DESC", "id DESC"]
|
"order": ["creationDate DESC", "id DESC"]
|
||||||
|
|
Loading…
Reference in New Issue