fix: refs #6938 filters & scope
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-04-15 14:44:18 +02:00
parent d7b06fe637
commit 3e1218463c
4 changed files with 25 additions and 110 deletions

View File

@ -100,13 +100,21 @@
"relation": "user", "relation": "user",
"scope": { "scope": {
"fields": ["email", "name", "nickname", "roleFk"], "fields": ["email", "name", "nickname", "roleFk"],
"include": { "include": [
{
"relation": "role", "relation": "role",
"scope": { "scope": {
"fields": ["name"] "fields": ["name"]
} }
},
{
"relation": "emailUser",
"scope": {
"fields": ["email"]
} }
} }
]
}
}, { }, {
"relation": "department", "relation": "department",
"scope": { "scope": {

View File

@ -4,37 +4,13 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard { class Controller extends ModuleCard {
reload() { reload() {
const filter = { const filter = {
include: [ where: {
{ id: this.$params.id}
relation: 'user',
scope: {
fields: ['name', 'emailVerified'],
include: {
relation: 'emailUser',
scope: {
fields: ['email']
}
}
}
}, {
relation: 'sip',
scope: {
fields: ['extension', 'secret']
}
}, {
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
}
]
}; };
return Promise.all([ return Promise.all([
this.$http.get(`Workers/${this.$params.id}`, {filter}) this.$http.get(`Workers/summary`, {filter})
.then(res => this.worker = res.data), .then(res => this.worker = res.data[0]),
this.$http.get(`Workers/${this.$params.id}/activeContract`) this.$http.get(`Workers/${this.$params.id}/activeContract`)
.then(res => this.hasWorkCenter = res.data?.workCenterFk) .then(res => this.hasWorkCenter = res.data?.workCenterFk)
]); ]);

View File

@ -37,41 +37,11 @@ class Controller extends Descriptor {
loadData() { loadData() {
const filter = { const filter = {
include: [ where: {id: this.id},
{
relation: 'user',
scope: {
fields: ['name', 'emailVerified'],
include: {
relation: 'emailUser',
scope: {
fields: ['email']
}
}
}
}, {
relation: 'client',
scope: {
fields: ['fi']
}
}, {
relation: 'sip',
scope: {
fields: ['extension']
}
}, {
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
}
]
}; };
return this.getData(`Workers/${this.id}`, {filter}) return this.getData(`Workers/summary`, {filter})
.then(res => this.entity = res.data); .then(res => this.entity = res.data[0]);
} }
getPassRequirements() { getPassRequirements() {

View File

@ -10,53 +10,14 @@ class Controller extends Summary {
this.$.worker = null; this.$.worker = null;
if (!value) return; if (!value) return;
const query = `Workers/${value.id}`;
const filter = { const filter = {
include: [ where: {
{ id: value.id
relation: 'user',
scope: {
fields: ['name', 'roleFk'],
include: [{
relation: 'role',
scope: {
fields: ['name']
} }
},
{
relation: 'emailUser',
scope: {
fields: ['email']
}
}]
}
},
{
relation: 'client',
scope: {fields: ['fi', 'phone']}
},
{
relation: 'boss',
scope: {fields: ['id', 'name']}
},
{
relation: 'sip',
scope: {fields: ['extension']}
},
{
relation: 'department',
scope: {
include: {
relation: 'department',
scope: {fields: ['id', 'code', 'name']}
}
}
}
]
}; };
this.$http.get(query, {params: {filter}}).then(res => { this.$http.get(`Workers/summary`, {filter}).then(res => {
this.$.worker = res.data; this.$.worker = res.data[0];
}); });
} }