refs #5334 mod search-panel
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-06-01 11:30:28 +02:00
parent eb6953a2b6
commit 4c7c7f5c96
5 changed files with 37 additions and 44 deletions

View File

@ -51,40 +51,29 @@ module.exports = Self => {
Self.filter = async(ctx, filter) => { Self.filter = async(ctx, filter) => {
let conn = Self.dataSource.connector; let conn = Self.dataSource.connector;
console.log('ENTRY');
let where = buildFilter(ctx.args, (param, value) => { let where = buildFilter(ctx.args, (param, value) => {
switch (param) { switch (param) {
case 'search': case 'search':
return /^\d+$/.test(value) return /^\d+$/.test(value)
? {'d.id': value} ? {'id': value}
: {or: [ : {or: [
{'d.code': {like: `%${value}%`}}, {'code': {like: `%${value}%`}},
{'d.name': {like: `%${value}%`}} {'name': {like: `%${value}%`}}
]}; ]};
case 'id': case 'id':
return {'d.id': value}; return {'id': value};
case 'code': case 'code':
return {'d.code': value}; return {'code': value};
case 'name': case 'name':
return {'d.name': {like: `%${value}%`}}; return {'name': {like: `%${value}%`}};
} }
}); });
filter = mergeFilters(ctx.args.filter, {where}); filter = mergeFilters(ctx.args.filter, {where});
console.log(filter);
let stmts = []; const departments = await Self.app.models.Department.find(filter);
let stmt; console.log(departments);
return departments;
stmt = new ParameterizedSQL(
`SELECT id, code, name
FROM department d`
);
stmt.merge(conn.makeSuffix(filter));
let itemsIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql);
return itemsIndex === 0 ? result : result[itemsIndex];
}; };
}; };

View File

@ -36,16 +36,20 @@
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield <vn-autocomplete
vn-one ng-model="$ctrl.department.workerFk"
label="Boss department" url="Workers/activeWithInheritedRole"
ng-model="$ctrl.department.workerFk"> show-field="nickname"
</vn-textfield> search-function="{firstName: $search}"
<vn-textfield label="Boss department">
vn-one </vn-autocomplete>
label="Self-consumption customer" <vn-autocomplete
ng-model="$ctrl.department.clientFk"> ng-model="$ctrl.department.clientFk"
</vn-textfield> url="Clients/"
show-field="name"
search-function="{firstName: $search}"
label="Self-consumption customer">
</vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-check <vn-check

View File

@ -29,10 +29,14 @@
value="{{$ctrl.department.worker.firstName}} {{$ctrl.department.worker.secondName}}"> value="{{$ctrl.department.worker.firstName}} {{$ctrl.department.worker.secondName}}">
</vn-label-value> </vn-label-value>
</div> </div>
<vn-icon-button vn-anchor="{state: 'worker.index', params: {q: {departmentFk: $ctrl.$params.id}}}" <div class="quicklinks">
<div ng-transclude="btnOne">
<vn-quick-link vn-anchor="{state: 'worker.index', params: {q: {departmentFk: $ctrl.$params.id} } }"
vn-tooltip="Department workers" vn-tooltip="Department workers"
icon="icon-ticket"> icon="icon-ticket">
</vn-icon-button> </vn-quick-link>
</div>
</div>
</slot-body> </slot-body>
</vn-descriptor-content> </vn-descriptor-content>
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
@ -44,8 +48,3 @@
on-accept="$ctrl.deleteDepartment()" on-accept="$ctrl.deleteDepartment()"
question="You are going to delete this department"> question="You are going to delete this department">
</vn-confirm> </vn-confirm>
<!-- Upload photo dialog -->
<!-- <vn-upload-photo
vn-id="uploadPhoto"
on-response="$ctrl.onUploadResponse()">
</vn-upload-photo>

View File

@ -7,7 +7,7 @@
<vn-portal slot="topbar"> <vn-portal slot="topbar">
<vn-searchbar <vn-searchbar
vn-focus vn-focus
panel="vn-worker-search-panel" panel="vn-worker-department-search-panel"
info="Search workers by id, firstName, lastName or user name" info="Search workers by id, firstName, lastName or user name"
model="model" model="model"
base-state="worker.department"> base-state="worker.department">

View File

@ -3,7 +3,7 @@
"name": "Workers", "name": "Workers",
"icon" : "icon-worker", "icon" : "icon-worker",
"validations" : true, "validations" : true,
"dependencies": ["account", "worker"], "dependencies": ["account"],
"menus": { "menus": {
"main": [ "main": [
{"state": "worker.index", "icon": "icon-worker"}, {"state": "worker.index", "icon": "icon-worker"},
@ -124,7 +124,8 @@
"url": "/department?q", "url": "/department?q",
"state": "worker.department", "state": "worker.department",
"component": "vn-worker-department", "component": "vn-worker-department",
"description":"Departments" "description":"Departments",
"acl":["hr"]
}, { }, {
"url": "/:id", "url": "/:id",
"state": "worker.department.card", "state": "worker.department.card",