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
|
||||
disabled="false"
|
||||
ng-model="$ctrl.claim.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'salesPerson'}"
|
||||
label="Attended by">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
ng-model="claimDevelopment.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
|
|
|
@ -25,20 +25,20 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'salesPerson'}"
|
||||
label="Salesperson">
|
||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.attenderFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'salesPerson'}"
|
||||
label="Attended by">
|
||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -8,7 +8,6 @@ const LoopBackContext = require('loopback-context');
|
|||
|
||||
module.exports = Self => {
|
||||
// Methods
|
||||
require('../methods/client/activeWorkersWithRole')(Self);
|
||||
require('../methods/client/getCard')(Self);
|
||||
require('../methods/client/createWithUser')(Self);
|
||||
require('../methods/client/listWorkers')(Self);
|
||||
|
|
|
@ -54,11 +54,11 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.client.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'salesPerson'}"
|
||||
label="Salesperson"
|
||||
vn-acl="salesAssistant">
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.buyerId"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'buyer'}"
|
||||
label="Buyer">
|
||||
<tpl-item>{{nickname}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
<vn-autocomplete
|
||||
label="Salesperson"
|
||||
ng-model="$ctrl.client.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
search-function="{firstName: $search}"
|
||||
show-field="firstName"
|
||||
where="{role: 'employee'}">
|
||||
where="{role: 'salesPerson'}">
|
||||
<tpl-item>{{firstName}} {{lastName}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
search-function="{firstName: $search}"
|
||||
show-field="firstName"
|
||||
value-field="id"
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
<vn-autocomplete
|
||||
disabled="false"
|
||||
ng-model="filter.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'buyer'}"
|
||||
label="Buyer">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.buyerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRolee"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.attenderFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'buyer'}"
|
||||
label="Atender">
|
||||
<tpl-item>{{nickname}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -42,11 +42,11 @@
|
|||
vn-one
|
||||
disabled="false"
|
||||
ng-model="filter.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'buyer'}"
|
||||
label="Buyer">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
search-function="{firstName: $search}"
|
||||
show-field="nickname"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'salesPerson'}"
|
||||
label="Sales person">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.route.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<vn-autocomplete
|
||||
label="Worker"
|
||||
ng-model="$ctrl.route.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
where="{role: 'employee'}">
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.supplier.workerFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
search-function="{firstName: $search}"
|
||||
show-field="nickname"
|
||||
value-field="id"
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.buyerId"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
where="{role: 'buyer'}"
|
||||
label="Buyer">
|
||||
<tpl-item>{{nickname}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<vn-autocomplete
|
||||
label="Buyer"
|
||||
ng-model="$ctrl.ticketRequest.attenderFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithRole"
|
||||
show-field="nickname"
|
||||
where="{role: 'buyer'}"
|
||||
search-function="{firstName: $search}">
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.salesPersonFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
search-function="{firstName: $search}"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
ng-if="$ctrl.isPickerDesignedState"
|
||||
ng-model="$ctrl.workerFk"
|
||||
show-field="nickname"
|
||||
|
|
|
@ -3,26 +3,7 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
|||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('activeWorkersWithRole', {
|
||||
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 => {
|
||||
Self.activeWorkers = async(query, filter) => {
|
||||
let conn = Self.dataSource.connector;
|
||||
if (filter.where && filter.where.and && Array.isArray(filter.where.and)) {
|
||||
let where = {};
|
||||
|
@ -54,14 +35,8 @@ module.exports = Self => {
|
|||
|
||||
myFilter = mergeFilters(myFilter, clientFilter);
|
||||
|
||||
let stmt = new ParameterizedSQL(
|
||||
`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`
|
||||
);
|
||||
let stmt = new ParameterizedSQL(query);
|
||||
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/deleteAbsence')(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
|
||||
disabled="false"
|
||||
ng-model="$ctrl.worker.bossFk"
|
||||
url="Clients/activeWorkersWithRole"
|
||||
url="Clients/activeWorkersWithInheritRole"
|
||||
show-field="nickname"
|
||||
search-function="{firstName: $search}"
|
||||
where="{role: 'employee'}"
|
||||
|
|
Loading…
Reference in New Issue