Skip to content

Commit

Permalink
Allow paragraph creator to modify
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Oct 22, 2024
1 parent 9e8ecd9 commit a14fb11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sci-log-db/src/mixins/basesnippet.repository-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function UpdateAndDeleteRepositoryMixin<
acl => basesnippet[acl as keyof typeof basesnippet],
)
)
await self['aclDefaultOnCreation'](merge);
await self['aclDefaultOnCreation'](merge, false);
return this.getChanged(merge, snippet);
}

Expand Down
17 changes: 15 additions & 2 deletions sci-log-db/src/repositories/autoadd.repository.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class AutoAddRepository<
ownerGroup?: string;
accessGroups?: string[];
},
isNewInstance = true,
) {
const parent = await this.getParent(data);
const acls = [...this.acls];
Expand All @@ -107,7 +108,13 @@ export class AutoAddRepository<
await this.addToACLIfNotEmpty(
acls,
data,
_.partial(this.defaultAllButLocationLogbookACL.bind(this), parent),
_.partial(
this.defaultAllButLocationLogbookACL.bind(this),
parent,
_,
_,
isNewInstance,
),
);
delete data.ownerGroup;
delete data.accessGroups;
Expand Down Expand Up @@ -176,12 +183,18 @@ export class AutoAddRepository<
private defaultAllButLocationLogbookACL(
parent: Basesnippet,
aclType: string,
data: {accessGroups?: string[]},
data: {
accessGroups?: string[];
createdBy?: string[];
},
isNewInstance = true,
) {
if (aclType === 'shareACL')
return arrayOfUniqueFrom(parent.shareACL, parent.readACL);
if (aclType === 'readACL')
return arrayOfUniqueFrom(parent.readACL, data.accessGroups);
if (aclType === 'updateACL' && isNewInstance)
return arrayOfUniqueFrom(parent.updateACL, data.createdBy);
return parent[aclType as keyof Basesnippet];
}

Expand Down

0 comments on commit a14fb11

Please sign in to comment.