2878 - Splitted method into activeWithRole and activeWithInheritedRole
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8c9ad39762
commit
6b8074e32f
|
@ -28,10 +28,10 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
disabled="false"
|
disabled="false"
|
||||||
ng-model="$ctrl.claim.workerFk"
|
ng-model="$ctrl.claim.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'salesPerson'}"
|
||||||
label="Attended by">
|
label="Attended by">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
ng-model="claimDevelopment.workerFk"
|
ng-model="claimDevelopment.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
|
|
@ -25,20 +25,20 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.salesPersonFk"
|
ng-model="filter.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'salesPerson'}"
|
||||||
label="Salesperson">
|
label="Salesperson">
|
||||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.attenderFk"
|
ng-model="filter.attenderFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'salesPerson'}"
|
||||||
label="Attended by">
|
label="Attended by">
|
||||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -8,7 +8,6 @@ const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
// Methods
|
// Methods
|
||||||
require('../methods/client/activeWorkersWithRole')(Self);
|
|
||||||
require('../methods/client/getCard')(Self);
|
require('../methods/client/getCard')(Self);
|
||||||
require('../methods/client/createWithUser')(Self);
|
require('../methods/client/createWithUser')(Self);
|
||||||
require('../methods/client/listWorkers')(Self);
|
require('../methods/client/listWorkers')(Self);
|
||||||
|
|
|
@ -54,11 +54,11 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="$ctrl.client.salesPersonFk"
|
ng-model="$ctrl.client.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'salesPerson'}"
|
||||||
label="Salesperson"
|
label="Salesperson"
|
||||||
vn-acl="salesAssistant">
|
vn-acl="salesAssistant">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.buyerId"
|
ng-model="filter.buyerId"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'buyer'}"
|
||||||
label="Buyer">
|
label="Buyer">
|
||||||
<tpl-item>{{nickname}}</tpl-item>
|
<tpl-item>{{nickname}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Salesperson"
|
label="Salesperson"
|
||||||
ng-model="$ctrl.client.salesPersonFk"
|
ng-model="$ctrl.client.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
show-field="firstName"
|
show-field="firstName"
|
||||||
where="{role: 'employee'}">
|
where="{role: 'salesPerson'}">
|
||||||
<tpl-item>{{firstName}} {{lastName}}</tpl-item>
|
<tpl-item>{{firstName}} {{lastName}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.salesPersonFk"
|
ng-model="filter.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
show-field="firstName"
|
show-field="firstName"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
|
|
@ -39,11 +39,11 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
disabled="false"
|
disabled="false"
|
||||||
ng-model="filter.salesPersonFk"
|
ng-model="filter.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'buyer'}"
|
||||||
label="Buyer">
|
label="Buyer">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.buyerFk"
|
ng-model="filter.buyerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRolee"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.attenderFk"
|
ng-model="filter.attenderFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'buyer'}"
|
||||||
label="Atender">
|
label="Atender">
|
||||||
<tpl-item>{{nickname}}</tpl-item>
|
<tpl-item>{{nickname}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -42,11 +42,11 @@
|
||||||
vn-one
|
vn-one
|
||||||
disabled="false"
|
disabled="false"
|
||||||
ng-model="filter.salesPersonFk"
|
ng-model="filter.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'buyer'}"
|
||||||
label="Buyer">
|
label="Buyer">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.workerFk"
|
ng-model="filter.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'salesPerson'}"
|
||||||
label="Sales person">
|
label="Sales person">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="$ctrl.route.workerFk"
|
ng-model="$ctrl.route.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Worker"
|
label="Worker"
|
||||||
ng-model="$ctrl.route.workerFk"
|
ng-model="$ctrl.route.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
where="{role: 'employee'}">
|
where="{role: 'employee'}">
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.workerFk"
|
ng-model="filter.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="$ctrl.supplier.workerFk"
|
ng-model="$ctrl.supplier.workerFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.buyerId"
|
ng-model="filter.buyerId"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'buyer'}"
|
||||||
label="Buyer">
|
label="Buyer">
|
||||||
<tpl-item>{{nickname}}</tpl-item>
|
<tpl-item>{{nickname}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Buyer"
|
label="Buyer"
|
||||||
ng-model="$ctrl.ticketRequest.attenderFk"
|
ng-model="$ctrl.ticketRequest.attenderFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
where="{role: 'buyer'}"
|
where="{role: 'buyer'}"
|
||||||
search-function="{firstName: $search}">
|
search-function="{firstName: $search}">
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="filter.salesPersonFk"
|
ng-model="filter.salesPersonFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'employee'}"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
ng-if="$ctrl.isPickerDesignedState"
|
ng-if="$ctrl.isPickerDesignedState"
|
||||||
ng-model="$ctrl.workerFk"
|
ng-model="$ctrl.workerFk"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
|
|
|
@ -3,26 +3,7 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('activeWorkersWithRole', {
|
Self.activeWorkers = async(query, filter) => {
|
||||||
description: 'Returns actives workers with salesperson role',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'filter',
|
|
||||||
type: 'Object',
|
|
||||||
description: 'Filter defining where and paginated data',
|
|
||||||
required: true
|
|
||||||
}],
|
|
||||||
returns: {
|
|
||||||
type: 'Worker',
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/activeWorkersWithRole`,
|
|
||||||
verb: 'get'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.activeWorkersWithRole = async filter => {
|
|
||||||
let conn = Self.dataSource.connector;
|
let conn = Self.dataSource.connector;
|
||||||
if (filter.where && filter.where.and && Array.isArray(filter.where.and)) {
|
if (filter.where && filter.where.and && Array.isArray(filter.where.and)) {
|
||||||
let where = {};
|
let where = {};
|
||||||
|
@ -54,14 +35,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
myFilter = mergeFilters(myFilter, clientFilter);
|
myFilter = mergeFilters(myFilter, clientFilter);
|
||||||
|
|
||||||
let stmt = new ParameterizedSQL(
|
let stmt = new ParameterizedSQL(query);
|
||||||
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
|
|
||||||
FROM worker w
|
|
||||||
JOIN account.user u ON u.id = w.userFk
|
|
||||||
JOIN account.roleRole i ON i.role = u.role
|
|
||||||
JOIN account.role r ON r.id = i.inheritsFrom`
|
|
||||||
);
|
|
||||||
stmt.merge(conn.makeSuffix(myFilter));
|
stmt.merge(conn.makeSuffix(myFilter));
|
||||||
return await conn.executeStmt(stmt);
|
return conn.executeStmt(stmt);
|
||||||
};
|
};
|
||||||
};
|
};
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('activeWithInheritedRole', {
|
||||||
|
description: 'Returns active workers with a role',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'Object',
|
||||||
|
description: 'Filter defining where and paginated data',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/activeWithInheritedRole`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.activeWithInheritedRole = async filter => {
|
||||||
|
const query =
|
||||||
|
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
|
||||||
|
FROM worker w
|
||||||
|
JOIN account.user u ON u.id = w.userFk
|
||||||
|
JOIN account.roleRole i ON i.role = u.role
|
||||||
|
JOIN account.role r ON r.id = i.inheritsFrom`;
|
||||||
|
|
||||||
|
return Self.activeWorkers(query, filter);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('activeWithRole', {
|
||||||
|
description: 'Returns active workers with an inherited role',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'Object',
|
||||||
|
description: 'Filter defining where and paginated data',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/activeWithRole`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.activeWithRole = async filter => {
|
||||||
|
const query =
|
||||||
|
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
|
||||||
|
FROM worker w
|
||||||
|
JOIN account.user u ON u.id = w.id
|
||||||
|
JOIN account.role r ON r.id = u.role`;
|
||||||
|
|
||||||
|
return Self.activeWorkers(query, filter);
|
||||||
|
};
|
||||||
|
};
|
|
@ -7,4 +7,7 @@ module.exports = Self => {
|
||||||
require('../methods/worker/createAbsence')(Self);
|
require('../methods/worker/createAbsence')(Self);
|
||||||
require('../methods/worker/deleteAbsence')(Self);
|
require('../methods/worker/deleteAbsence')(Self);
|
||||||
require('../methods/worker/updateAbsence')(Self);
|
require('../methods/worker/updateAbsence')(Self);
|
||||||
|
require('../methods/worker/active')(Self);
|
||||||
|
require('../methods/worker/activeWithRole')(Self);
|
||||||
|
require('../methods/worker/activeWithInheritedRole')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
disabled="false"
|
disabled="false"
|
||||||
ng-model="$ctrl.worker.bossFk"
|
ng-model="$ctrl.worker.bossFk"
|
||||||
url="Clients/activeWorkersWithRole"
|
url="Clients/activeWorkersWithInheritRole"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{firstName: $search}"
|
||||||
where="{role: 'employee'}"
|
where="{role: 'employee'}"
|
||||||
|
|
Loading…
Reference in New Issue