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",
"scope": {
"fields": ["email", "name", "nickname", "roleFk"],
"include": {
"include": [
{
"relation": "role",
"scope": {
"fields": ["name"]
}
},
{
"relation": "emailUser",
"scope": {
"fields": ["email"]
}
}
]
}
}, {
"relation": "department",
"scope": {

View File

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

View File

@ -37,41 +37,11 @@ class Controller extends Descriptor {
loadData() {
const filter = {
include: [
{
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'
}
}
}
]
where: {id: this.id},
};
return this.getData(`Workers/${this.id}`, {filter})
.then(res => this.entity = res.data);
return this.getData(`Workers/summary`, {filter})
.then(res => this.entity = res.data[0]);
}
getPassRequirements() {

View File

@ -10,53 +10,14 @@ class Controller extends Summary {
this.$.worker = null;
if (!value) return;
const query = `Workers/${value.id}`;
const filter = {
include: [
{
relation: 'user',
scope: {
fields: ['name', 'roleFk'],
include: [{
relation: 'role',
scope: {
fields: ['name']
where: {
id: value.id
}
},
{
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.$.worker = res.data;
this.$http.get(`Workers/summary`, {filter}).then(res => {
this.$.worker = res.data[0];
});
}