diff options
Diffstat (limited to 'src/client/views/DocComponent.tsx')
| -rw-r--r-- | src/client/views/DocComponent.tsx | 13 | 
1 files changed, 7 insertions, 6 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index f8aede717..876fbac54 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -9,6 +9,7 @@ import { DateField } from '../../fields/DateField';  import { ScriptField } from '../../fields/ScriptField';  import { GetEffectiveAcl, SharingPermissions, distributeAcls, denormalizeEmail } from '../../fields/util';  import { CurrentUserUtils } from '../util/CurrentUserUtils'; +import { DocUtils } from '../documents/Documents';  ///  DocComponent returns a generic React base class used by views that don't have 'fieldKey' props (e.g.,CollectionFreeFormDocumentView, DocumentView) @@ -127,16 +128,15 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T          public get annotationKey() { return this.fieldKey + "-" + this._annotationKey; }          @action.bound -        removeDocument(doc: Doc | Doc[], annotationKey?: string): boolean { +        removeDocument(doc: Doc | Doc[], annotationKey?: string, leavePushpin?: boolean): boolean {              const effectiveAcl = GetEffectiveAcl(this.dataDoc);              const indocs = doc instanceof Doc ? [doc] : doc;              const docs = indocs.filter(doc => effectiveAcl === AclEdit || effectiveAcl === AclAdmin || GetEffectiveAcl(doc) === AclAdmin);              if (docs.length) { -                const docs = doc instanceof Doc ? [doc] : doc; -                docs.map(doc => { +                setTimeout(() => docs.map(doc => { // this allows 'addDocument' to see the annotationOn field in order to create a pushin                      Doc.SetInPlace(doc, "isPushpin", undefined, true); -                    Doc.SetInPlace(doc, "annotationOn", undefined, true); -                }); +                    doc.annotationOn === this.props.Document && Doc.SetInPlace(doc, "annotationOn", undefined, true); +                }));                  const targetDataDoc = this.dataDoc;                  const value = DocListCast(targetDataDoc[annotationKey ?? this.annotationKey]);                  const toRemove = value.filter(v => docs.includes(v)); @@ -144,6 +144,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T                  if (toRemove.length !== 0) {                      const recent = Cast(Doc.UserDoc().myRecentlyClosedDocs, Doc) as Doc;                      toRemove.forEach(doc => { +                        leavePushpin && DocUtils.LeavePushpin(doc);                          Doc.RemoveDocFromList(targetDataDoc, annotationKey ?? this.annotationKey, doc);                          doc.context = undefined;                          recent && Doc.AddDocToList(recent, "data", doc, undefined, true, true); @@ -159,7 +160,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T          // otherwise, if the document can be removed from where it was, it will then be added to this document's overlay collection.           @action.bound          moveDocument(doc: Doc | Doc[], targetCollection: Doc | undefined, addDocument: (doc: Doc | Doc[]) => boolean, annotationKey?: string): boolean { -            return Doc.AreProtosEqual(this.props.Document, targetCollection) ? true : this.removeDocument(doc, annotationKey) ? addDocument(doc) : false; +            return Doc.AreProtosEqual(this.props.Document, targetCollection) ? true : this.removeDocument(doc, annotationKey, true) ? addDocument(doc) : false;          }          @action.bound          addDocument(doc: Doc | Doc[], annotationKey?: string): boolean {  | 
