From 3e1218463c03b2cda4ea390a262299b49d661fac Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 14:44:18 +0200 Subject: [PATCH] fix: refs #6938 filters & scope --- modules/worker/back/models/worker.json | 18 ++++++--- modules/worker/front/card/index.js | 32 ++-------------- modules/worker/front/descriptor/index.js | 36 ++--------------- modules/worker/front/summary/index.js | 49 +++--------------------- 4 files changed, 25 insertions(+), 110 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 10776af90..57dc80ec9 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -100,12 +100,20 @@ "relation": "user", "scope": { "fields": ["email", "name", "nickname", "roleFk"], - "include": { - "relation": "role", - "scope": { - "fields": ["name"] + "include": [ + { + "relation": "role", + "scope": { + "fields": ["name"] + } + }, + { + "relation": "emailUser", + "scope": { + "fields": ["email"] + } } - } + ] } }, { "relation": "department", diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 9a40e31c2..1aa548db9 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -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) ]); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index d7962369c..ebf3d65ed 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -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() { diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 212609f58..d1a27a6d4 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -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'] - } - }, - { - 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']} - } - } - } - ] + where: { + id: value.id + } }; - 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]; }); }