EQMS-1617 Fix document and category links (#9672)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-08-13 11:43:23 +07:00
committed by GitHub
parent 0218c5d1ab
commit d40eb99774
5 changed files with 48 additions and 45 deletions
@@ -17,7 +17,8 @@
import { Document } from '@hcengineering/controlled-documents'
import { WithLookup } from '@hcengineering/core'
import { getEmbeddedLabel } from '@hcengineering/platform'
import { getPanelURI, tooltip } from '@hcengineering/ui'
import { tooltip } from '@hcengineering/ui'
import { DocNavLink } from '@hcengineering/view-resources'
import DocumentIcon from '../../icons/DocumentIcon.svelte'
import documents from '../../../plugin'
@@ -29,16 +30,17 @@
export let withIcon = false
export let withTitle = false
export let disableLink = false
export let editable = false
export let canEdit = false
$: documentCode = value !== undefined ? value.code : ''
$: noUnderline = disableLink && !editable
$: noUnderline = disableLink && !canEdit
$: disabled = disableLink && !canEdit
$: title = withTitle ? `${documentCode} ${value?.title}` : documentCode
const dispatch = createEventDispatcher()
function handleClick (event: MouseEvent): void {
if (!editable) {
if (!canEdit) {
return
}
@@ -47,23 +49,26 @@
</script>
{#if value}
<a
class="flex-presenter"
href={!disableLink ? `#${getPanelURI(documents.component.EditDoc, value._id, value._class, 'content')}` : undefined}
class:inline-presenter={inline}
class:noBold={isRegular}
class:no-underline={noUnderline}
class:cursor-inherit={noUnderline}
use:tooltip={{ label: getEmbeddedLabel(title) }}
on:click={handleClick}
<DocNavLink
object={value}
component={documents.component.EditDoc}
onClick={canEdit ? handleClick : undefined}
accent={!isRegular}
{disabled}
{noUnderline}
{inline}
>
{#if withIcon}
<div class="icon">
<DocumentIcon size="small" />
</div>
{/if}
<span class="label nowrap" class:no-underline={noUnderline} class:label-gray={isGray}>{title}</span>
</a>
<div class="flex-presenter" use:tooltip={{ label: getEmbeddedLabel(title) }}>
{#if withIcon}
<div class="icon">
<DocumentIcon size="small" />
</div>
{/if}
<span class="label nowrap" class:fs-bold={!isRegular} class:no-underline={noUnderline} class:label-gray={isGray}
>{title}</span
>
</div>
</DocNavLink>
{/if}
<style lang="scss">
@@ -15,19 +15,18 @@
<script lang="ts">
import { Document } from '@hcengineering/controlled-documents'
import { WithLookup } from '@hcengineering/core'
import { getPanelURI } from '@hcengineering/ui'
import documents from '../../../plugin'
import { tooltip } from '@hcengineering/ui'
import { DocNavLink } from '@hcengineering/view-resources'
import { getEmbeddedLabel } from '@hcengineering/platform'
export let value: WithLookup<Document>
export let inline = false
</script>
{#if value}
<a
class="flex-presenter"
href="#{getPanelURI(documents.component.EditDoc, value._id, value._class, 'content')}"
class:inline-presenter={inline}
>
<span class="label nowrap">{value.title}</span>
</a>
<DocNavLink object={value} {inline}>
<div class="flex-presenter" class:inline-presenter={inline} use:tooltip={{ label: getEmbeddedLabel(value.title) }}>
<span class="label fs-bold nowrap">{value.title}</span>
</div>
</DocNavLink>
{/if}
@@ -96,7 +96,7 @@
value={$controlledDocument}
isRegular
disableLink
editable={isInitialEditableDraft}
canEdit={isInitialEditableDraft}
on:edit={(e) => {
handleCodeEdit(e.detail)
}}