aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocComponent.tsx
diff options
context:
space:
mode:
authorGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-08-13 08:44:13 +0800
committerGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-08-13 08:44:13 +0800
commit80269d9af07ff78aa8ecdbaa586d932ce8cc15f1 (patch)
treea73be52ee7e82fb3b9c18c4935e423c843917e4f /src/client/views/DocComponent.tsx
parent55460c79ddc12b44907979053058e04987f7e4c0 (diff)
parent575ed4504f8bd5da42d209bcc313a4fc766247e3 (diff)
Merge branch 'master' into presentation_updates
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r--src/client/views/DocComponent.tsx26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index ea854c2a3..8c8bb6fde 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -122,15 +122,23 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T
@action.bound
removeDocument(doc: Doc | Doc[]): boolean {
- const docs = doc instanceof Doc ? [doc] : doc;
- docs.map(doc => doc.isPushpin = doc.annotationOn = undefined);
- const targetDataDoc = this.dataDoc;
- const value = DocListCast(targetDataDoc[this.annotationKey]);
- const toRemove = value.filter(v => docs.includes(v));
- // can't assign new List<Doc>(result) to this because you can't assign new values in addonly
- if (toRemove.length !== 0) {
- toRemove.forEach(doc => Doc.RemoveDocFromList(targetDataDoc, this.annotationKey, doc));
- return true;
+ const effectiveAcl = GetEffectiveAcl(this.dataDoc);
+ if (effectiveAcl === AclAdmin || effectiveAcl === AclEdit) {
+ const docs = doc instanceof Doc ? [doc] : doc;
+ docs.map(doc => doc.isPushpin = doc.annotationOn = undefined);
+ const targetDataDoc = this.dataDoc;
+ const value = DocListCast(targetDataDoc[this.annotationKey]);
+ const toRemove = value.filter(v => docs.includes(v));
+
+ if (toRemove.length !== 0) {
+ const recent = Cast(Doc.UserDoc().myRecentlyClosed, Doc) as Doc;
+ toRemove.forEach(doc => {
+ Doc.RemoveDocFromList(targetDataDoc, this.props.fieldKey + "-annotations", doc);
+ recent && Doc.AddDocToList(recent, "data", doc, undefined, true, true);
+ doc.deleted = true;
+ });
+ return true;
+ }
}
return false;