aboutsummaryrefslogtreecommitdiff
path: root/src/fields/util.ts
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2020-07-20 19:21:54 +0530
committerusodhi <61431818+usodhi@users.noreply.github.com>2020-07-20 19:21:54 +0530
commit7b7d83f6f7070334fdfc4dd7cca03699b8e21078 (patch)
tree14a358942120b0d05be4e7a5f9131e25ebf2fc82 /src/fields/util.ts
parent6a52a9510d48fda1ec94717ec7089ab922bc8613 (diff)
fixed some addonly stuff + added annotations to playground fields + recursively distributes acls + some modal stuff
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r--src/fields/util.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts
index 6d2d715bd..ee01f6213 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -129,28 +129,31 @@ export function setGroups(groups: string[]) {
export function GetEffectiveAcl(target: any, in_prop?: string | symbol | number): symbol {
if (in_prop === UpdatingFromServer || target[UpdatingFromServer]) return AclEdit;
- const HierarchyMapping = new Map<symbol, number>([
- [AclPrivate, 0],
- [AclReadonly, 1],
- [AclAddonly, 2],
- [AclEdit, 3]
- ]);
-
if (!target[AclSym] && target instanceof Doc) {
fetchProto(target);
}
+
if (target[AclSym] && Object.keys(target[AclSym]).length) {
- if (target.author === Doc.CurrentUserEmail || currentUserGroups.includes("admin")) return AclEdit;
+ // console.log(target[AclSym]);
+
+ if (target.__fields?.author === Doc.CurrentUserEmail || target.author === Doc.CurrentUserEmail || currentUserGroups.includes("admin")) return AclEdit;
if (_overrideAcl || (in_prop && DocServer.PlaygroundFields?.includes(in_prop.toString()))) return AclEdit;
- if (target[AclSym].ACL) return target[AclSym].ACL;
+ // if (target[AclSym].ACL) return target[AclSym].ACL;
let effectiveAcl = AclPrivate;
let aclPresent = false;
+ const HierarchyMapping = new Map<symbol, number>([
+ [AclPrivate, 0],
+ [AclReadonly, 1],
+ [AclAddonly, 2],
+ [AclEdit, 3]
+ ]);
+
for (const [key, value] of Object.entries(target[AclSym])) {
if (currentUserGroups.includes(key.substring(4)) || Doc.CurrentUserEmail === key.substring(4).replace("_", ".")) {
if (HierarchyMapping.get(value as symbol)! >= HierarchyMapping.get(effectiveAcl)!) {