2023-03-15 14:06:03 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required bgetObjectLinkFragmentr agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
import { Doc, Hierarchy } from '@hcengineering/core'
|
2023-04-25 07:34:10 +00:00
|
|
|
import { NavLink, getClient } from '@hcengineering/presentation'
|
2023-03-20 08:45:52 +00:00
|
|
|
import { AnyComponent, getPanelURI, locationToUrl } from '@hcengineering/ui'
|
2023-03-15 14:06:03 +00:00
|
|
|
import view from '../plugin'
|
|
|
|
import { getObjectLinkFragment } from '../utils'
|
|
|
|
|
2023-06-06 10:06:32 +00:00
|
|
|
export let object: Doc | undefined
|
2023-05-04 13:20:49 +00:00
|
|
|
export let disabled = false
|
2023-03-15 14:06:03 +00:00
|
|
|
export let onClick: ((event: MouseEvent) => void) | undefined = undefined
|
2023-08-31 05:46:04 +00:00
|
|
|
export let noUnderline = disabled
|
2023-03-15 14:06:03 +00:00
|
|
|
export let inline = false
|
2023-04-23 17:37:24 +00:00
|
|
|
export let colorInherit: boolean = false
|
2023-03-15 14:06:03 +00:00
|
|
|
export let component: AnyComponent = view.component.EditDoc
|
|
|
|
export let props: Record<string, any> = {}
|
2023-05-23 05:27:55 +00:00
|
|
|
export let shrink: number = 1
|
2023-05-19 02:13:35 +00:00
|
|
|
export let accent: boolean = false
|
2023-09-06 15:52:48 +00:00
|
|
|
export let noOverflow: boolean = false
|
2023-03-15 14:06:03 +00:00
|
|
|
|
|
|
|
const client = getClient()
|
|
|
|
const hierarchy = client.getHierarchy()
|
|
|
|
|
2023-04-12 10:10:07 +00:00
|
|
|
let href: string | undefined =
|
|
|
|
object !== undefined
|
|
|
|
? '#' + getPanelURI(component, object._id, Hierarchy.mixinOrClass(object), 'content')
|
|
|
|
: undefined
|
2023-03-15 14:06:03 +00:00
|
|
|
|
|
|
|
async function getHref (object: Doc): Promise<void> {
|
2023-05-04 13:20:49 +00:00
|
|
|
if (disabled) {
|
2023-03-17 03:52:32 +00:00
|
|
|
href = undefined
|
|
|
|
return
|
|
|
|
}
|
2023-03-20 08:45:52 +00:00
|
|
|
const loc = await getObjectLinkFragment(hierarchy, object, props, component)
|
|
|
|
href = `${window.location.origin}${locationToUrl(loc)}`
|
2023-03-15 14:06:03 +00:00
|
|
|
}
|
|
|
|
|
2023-04-12 10:10:07 +00:00
|
|
|
$: if (object !== undefined) getHref(object)
|
2023-03-15 14:06:03 +00:00
|
|
|
</script>
|
|
|
|
|
2023-09-06 15:52:48 +00:00
|
|
|
<NavLink {disabled} {onClick} {noUnderline} {inline} {shrink} {href} {colorInherit} {accent} {noOverflow}
|
|
|
|
><slot /></NavLink
|
|
|
|
>
|