From 22af34c0cb69a6fb0a5532ad6ac5574ebd11887a Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 19 Sep 2024 09:27:05 +0200 Subject: [PATCH] feat: refs #7323 use scopes --- .../11247-chocolateChico/00-firstScript.sql | 4 ++ modules/worker/back/models/worker.json | 68 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 db/versions/11247-chocolateChico/00-firstScript.sql diff --git a/db/versions/11247-chocolateChico/00-firstScript.sql b/db/versions/11247-chocolateChico/00-firstScript.sql new file mode 100644 index 000000000..8cbfebdde --- /dev/null +++ b/db/versions/11247-chocolateChico/00-firstScript.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL SET principalId = 'employee' WHERE model = 'Worker' AND principalId = '$subordinate'; +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES ('Worker', '__get__advancedSummary', 'READ', 'ALLOW', 'ROLE', 'hr'), + ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 82cd1cc2d..6cdf77337 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -193,6 +193,74 @@ } } ] + }, + "summary": { + "include": [ + { + "relation": "user", + "scope": { + "fields": [ + "name", + "nickname", + "roleFk" + ], + "include": [ + { + "relation": "role", + "scope": { + "fields": [ + "name" + ] + } + }, + { + "relation": "emailUser", + "scope": { + "fields": [ + "email" + ] + } + } + ] + } + }, + { + "relation": "department", + "scope": { + "include": { + "relation": "department", + "scope": { + "fields": [ + "name" + ] + } + } + } + }, + { + "relation": "boss" + }, + { + "relation": "client" + }, + { + "relation": "sip" + } + ] + }, + "advancedSummary": { + "fields": [ + "id", + "fiDueDate", + "sex", + "seniority", + "fi", + "isFreelance", + "isSsDiscounted", + "hasMachineryAuthorized", + "isDisable", + "birth" + ] } } } \ No newline at end of file