mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-09 09:20:54 +00:00
Fix everyone/here mentions (#9109)
This commit is contained in:
parent
458ba6886a
commit
868bb7a5d5
@ -14,7 +14,7 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { Component, Icon, showPopup } from '@hcengineering/ui'
|
||||
import { Component, Icon, Label, showPopup } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
import contact from '@hcengineering/contact'
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
}
|
||||
|
||||
function onBrokenLinkClick (event: MouseEvent): void {
|
||||
if (withoutDoc) return
|
||||
showPopup(MessageBox, {
|
||||
label: presentation.string.UnableToFollowMention,
|
||||
message: presentation.string.AccessDenied,
|
||||
@ -57,8 +58,13 @@
|
||||
</script>
|
||||
|
||||
{#if !doc && title}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<span class="antiMention" class:transparent class:broken on:click={onBrokenLinkClick}>
|
||||
{#if icon}<Icon {icon} size="small" />{' '}{:else}@{/if}{title}
|
||||
{#if icon}<Icon {icon} size="small" />{' '}{:else}@{/if}{#if _id === contact.mention.Here}<span class="lower"
|
||||
><Label label={contact.string.Here} /></span
|
||||
>{:else if _id === contact.mention.Everyone}<span class="lower"><Label label={contact.string.Everyone} /></span
|
||||
>{:else}{title}{/if}
|
||||
</span>
|
||||
{:else if doc}
|
||||
<Component
|
||||
|
@ -22,7 +22,7 @@ import { ReferenceNode, type ReferenceNodeProps, type ReferenceOptions } from '@
|
||||
import Suggestion, { type SuggestionKeyDownProps, type SuggestionOptions, type SuggestionProps } from './suggestion'
|
||||
|
||||
import { type Class, type Doc, type Ref } from '@hcengineering/core'
|
||||
import { getMetadata, getResource } from '@hcengineering/platform'
|
||||
import { getMetadata, getResource, translate } from '@hcengineering/platform'
|
||||
import presentation, { createQuery, getClient, MessageBox } from '@hcengineering/presentation'
|
||||
import view from '@hcengineering/view'
|
||||
|
||||
@ -131,9 +131,20 @@ export const ReferenceExtension = ReferenceNode.extend<ReferenceExtensionOptions
|
||||
|
||||
let broken = false
|
||||
|
||||
const renderLabel = (props: ReferenceNodeProps): void => {
|
||||
const renderLabel = async (props: ReferenceNodeProps): Promise<void> => {
|
||||
root.setAttribute('data-label', props.label)
|
||||
titleSpan.innerText = `${iconUrl !== '' ? '' : options.suggestion.char}${props.label ?? props.id}`
|
||||
|
||||
if (props.id === contact.mention.Here) {
|
||||
const trans = await translate(contact.string.Here, {})
|
||||
titleSpan.innerText = `${iconUrl !== '' ? '' : options.suggestion.char}${trans}`
|
||||
root.classList.add('lower')
|
||||
} else if (props.id === contact.mention.Everyone) {
|
||||
const trans = await translate(contact.string.Everyone, {})
|
||||
titleSpan.innerText = `${iconUrl !== '' ? '' : options.suggestion.char}${trans}`
|
||||
root.classList.add('lower')
|
||||
} else {
|
||||
titleSpan.innerText = `${iconUrl !== '' ? '' : options.suggestion.char}${props.label ?? props.id}`
|
||||
}
|
||||
if (broken) {
|
||||
root.classList.add('broken')
|
||||
} else {
|
||||
@ -166,14 +177,14 @@ export const ReferenceExtension = ReferenceNode.extend<ReferenceExtensionOptions
|
||||
}
|
||||
|
||||
const titleSpan = root.appendChild(document.createElement('span'))
|
||||
renderLabel({ id, objectclass, label: node.attrs.label })
|
||||
void renderLabel({ id, objectclass, label: node.attrs.label })
|
||||
|
||||
if (id !== undefined && objectclass !== undefined && !withoutDoc) {
|
||||
query.query(objectclass, { _id: id }, async (result) => {
|
||||
const obj = result[0]
|
||||
broken = obj === undefined
|
||||
if (broken) {
|
||||
renderLabel({ id, objectclass, label: node.attrs.label })
|
||||
void renderLabel({ id, objectclass, label: node.attrs.label })
|
||||
resetTooltipHandle(undefined)
|
||||
} else {
|
||||
const label = await getReferenceLabel(objectclass, id, obj)
|
||||
@ -184,7 +195,7 @@ export const ReferenceExtension = ReferenceNode.extend<ReferenceExtensionOptions
|
||||
tooltipOptions = undefined
|
||||
}
|
||||
resetTooltipHandle(tooltip(root, tooltipOptions))
|
||||
renderLabel({ id, objectclass, label })
|
||||
void renderLabel({ id, objectclass, label })
|
||||
}
|
||||
})
|
||||
} else if (withoutDoc) {
|
||||
@ -194,7 +205,7 @@ export const ReferenceExtension = ReferenceNode.extend<ReferenceExtensionOptions
|
||||
return {
|
||||
dom: root,
|
||||
update (node, decorations) {
|
||||
renderLabel({ id, objectclass, label: node.attrs.label })
|
||||
void renderLabel({ id, objectclass, label: node.attrs.label })
|
||||
return true
|
||||
},
|
||||
destroy () {
|
||||
|
Loading…
Reference in New Issue
Block a user