From ebaf509a42b80cf3fa46240ae84399e0271d74e8 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 29 Apr 2023 00:05:05 -0700 Subject: [PATCH] Retain doc changes on tab switch after refresh doc --- .../document-detail.component.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 9b23aa047..bcce59441 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -236,10 +236,21 @@ export class DocumentDetailComponent true ) this.suggestions = null - if (this.openDocumentService.getOpenDocument(this.documentId)) { - this.updateComponent( - this.openDocumentService.getOpenDocument(this.documentId) - ) + const openDocument = this.openDocumentService.getOpenDocument( + this.documentId + ) + if (openDocument) { + if (this.documentForm.dirty) { + Object.assign(openDocument, this.documentForm.value) + openDocument['owner'] = + this.documentForm.get('permissions_form').value['owner'] + openDocument['permissions'] = + this.documentForm.get('permissions_form').value[ + 'set_permissions' + ] + delete openDocument['permissions_form'] + } + this.updateComponent(openDocument) } else { this.openDocumentService.openDocument(doc) this.updateComponent(doc)