Files
huly-platform/plugins/tracker-resources/src/components/LabelsView.svelte
T
2024-11-11 12:06:30 +07:00

50 lines
1.6 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script lang="ts">
import { getClient } from '@hcengineering/presentation'
import tags, { TagElement } from '@hcengineering/tags'
import { selectedTagElements } from '@hcengineering/tags-resources'
import { Component, getCurrentResolvedLocation, navigate } from '@hcengineering/ui'
import { Filter } from '@hcengineering/view'
import { buildFilterKey, setFilters } from '@hcengineering/view-resources'
import tracker from '../plugin'
function setFilterTag (tag: TagElement) {
const client = getClient()
const hierarchy = client.getHierarchy()
const attribute = hierarchy.getAttribute(tracker.class.Issue, 'labels')
const key = buildFilterKey(hierarchy, tracker.class.Issue, '_class', attribute)
const filter = {
key,
value: [tag._id],
props: { level: 0 },
modes: [tags.filter.FilterTagsIn, tags.filter.FilterTagsNin],
mode: tags.filter.FilterTagsIn,
index: 1
} as unknown as Filter
setFilters([filter])
}
async function onTag (tag: TagElement): Promise<void> {
selectedTagElements.set([tag._id])
const loc = getCurrentResolvedLocation()
loc.path[2] = 'tracker'
loc.path[3] = 'all-issues'
loc.path.length = 4
navigate(loc)
setTimeout(() => {
setFilterTag(tag)
}, 200)
}
</script>
<Component
is={tags.component.TagsView}
props={{
targetClass: tracker.class.Issue,
title: tracker.string.Labels,
icon: tracker.icon.Labels,
item: tracker.string.Labels,
key: 'labels',
сreateItemLabel: tracker.string.AddLabel,
onTag
}}
></Component>