From c82550c955dcb45d4e2f3f53f200937a2d3efe80 Mon Sep 17 00:00:00 2001 From: Victor Ilyushchenko Date: Wed, 5 Feb 2025 18:33:41 +0300 Subject: [PATCH 1/4] Fixes for document hierarchy presentation in QMS Signed-off-by: Victor Ilyushchenko --- .../info/DocumentFlatHierarchy.svelte | 182 +++---------- .../info/DocumentFlatTreeElement.svelte | 19 +- .../hierarchy/DocHierarchyLevel.svelte | 137 ++-------- .../hierarchy/DocumentParentSelector.svelte | 45 ++-- .../hierarchy/DocumentSpacePresenter.svelte | 107 +++----- .../src/utils.ts | 57 +++- plugins/controlled-documents/src/utils.ts | 244 ++++++++++++++---- 7 files changed, 370 insertions(+), 421 deletions(-) diff --git a/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatHierarchy.svelte b/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatHierarchy.svelte index 5f1dceaf0c3..b0013197666 100644 --- a/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatHierarchy.svelte +++ b/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatHierarchy.svelte @@ -14,184 +14,70 @@ --> {#if levels.length > 0} {@const [firstDocs, firstHltd] = levels[0]}
- {#each firstDocs as doc} - + {#each firstDocs as bundle} + {/each} {#if levels.length > 1} {@const [secondDocs, secondHltd] = levels[1]}
- {#each secondDocs as doc} - + {#each secondDocs as bundle} + {/each} {#if levels.length > 2} {@const [thirdDocs, thirdHltd] = levels[2]}
- {#each thirdDocs as doc} - + {#each thirdDocs as bundle} + {/each}
{/if} diff --git a/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatTreeElement.svelte b/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatTreeElement.svelte index d7e274b9c09..85bf78e8ad0 100644 --- a/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatTreeElement.svelte +++ b/plugins/controlled-documents-resources/src/components/document/right-panel/info/DocumentFlatTreeElement.svelte @@ -14,17 +14,25 @@ --> @@ -32,7 +40,8 @@
{ - const loc = getProjectDocumentLink(doc, project) + if (!document) return + const loc = getProjectDocumentLink(document, project) navigate(loc) }} > @@ -48,7 +57,7 @@
{/if} - {getDocumentName(doc)} + {document ? getDocumentName(document) : meta.title}
diff --git a/plugins/controlled-documents-resources/src/components/hierarchy/DocHierarchyLevel.svelte b/plugins/controlled-documents-resources/src/components/hierarchy/DocHierarchyLevel.svelte index 3be626ba9cf..58e2665ea8e 100644 --- a/plugins/controlled-documents-resources/src/components/hierarchy/DocHierarchyLevel.svelte +++ b/plugins/controlled-documents-resources/src/components/hierarchy/DocHierarchyLevel.svelte @@ -13,23 +13,20 @@ // limitations under the License. --> -{#each docs as prjdoc} - {@const pjmeta = projectMetaById.get(prjdoc.attachedTo)} - {@const doc = prjdoc.$lookup?.document} - {@const metaid = pjmeta?.meta} - {@const meta = metaid ? docsMetaById.get(metaid) : undefined} +{#each documentIds as metaid} + {@const bundle = tree.bundleOf(metaid)} + {@const prjdoc = bundle?.ProjectDocument[0]} + {@const doc = bundle?.ControlledDocument[0]} + {@const meta = bundle?.DocumentMeta[0]} {@const title = doc ? getDocumentName(doc) : meta?.title ?? ''} - {@const docid = doc?._id ?? prjdoc._id} - {@const isFolder = prjdoc.document === documents.ids.Folder} - {@const isObsolete = doc ? doc.state === DocumentState.Obsolete : false} - {@const children = metaid ? childrenByParent[metaid] ?? [] : []} + {@const docid = doc?._id ?? prjdoc?._id} + {@const isFolder = prjdoc?.document === documents.ids.Folder} + {@const children = tree.childrenOf(metaid)} + {@const isRemoved = doc && removeStates.includes(doc.state)} - {#if metaid && (!isObsolete || children.length > 0)} + {#if prjdoc && metaid} {@const isDraggedOver = draggedOver === metaid}
{#if isDraggedOver} @@ -161,7 +72,7 @@ _id={docid} icon={isFolder ? documents.icon.Folder : documents.icon.Document} iconProps={{ - fill: isObsolete ? 'var(--dangerous-bg-color)' : 'currentColor' + fill: isRemoved ? 'var(--dangerous-bg-color)' : 'currentColor' }} {title} selected={selected === docid || selected === prjdoc._id} @@ -191,8 +102,8 @@ {#if children.length} { dispatch('selected', space) }} > - + diff --git a/plugins/controlled-documents-resources/src/components/hierarchy/DocumentSpacePresenter.svelte b/plugins/controlled-documents-resources/src/components/hierarchy/DocumentSpacePresenter.svelte index 14db33b85b8..585623a41dc 100644 --- a/plugins/controlled-documents-resources/src/components/hierarchy/DocumentSpacePresenter.svelte +++ b/plugins/controlled-documents-resources/src/components/hierarchy/DocumentSpacePresenter.svelte @@ -13,20 +13,6 @@ // limitations under the License. -->