mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +03:00
TSK-124 fix (#2092)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
c6f759e1f9
commit
dfdbe15576
@ -279,8 +279,8 @@ export function createModel (builder: Builder): void {
|
||||
descriptor: tracker.viewlet.List,
|
||||
config: [
|
||||
{ key: '', presenter: tracker.component.PriorityEditor },
|
||||
{ key: '', presenter: tracker.component.IssuePresenter },
|
||||
{ key: '', presenter: tracker.component.StatusEditor },
|
||||
'@currentTeam',
|
||||
'@statuses',
|
||||
{ key: '', presenter: tracker.component.TitlePresenter, props: { shouldUseMargin: true } },
|
||||
{ key: '', presenter: tracker.component.DueDatePresenter },
|
||||
{
|
||||
|
@ -1,14 +1,56 @@
|
||||
<script lang="ts">
|
||||
import type { DocumentQuery, Ref, WithLookup } from '@anticrm/core'
|
||||
import { DocumentQuery, Ref, SortingOrder, WithLookup } from '@anticrm/core'
|
||||
import { Component } from '@anticrm/ui'
|
||||
import { BuildModelKey, Viewlet } from '@anticrm/view'
|
||||
import { Issue, Team, ViewOptions } from '@anticrm/tracker'
|
||||
import { BuildModelKey, Viewlet, ViewletPreference } from '@anticrm/view'
|
||||
import { Issue, IssueStatus, Team, ViewOptions } from '@anticrm/tracker'
|
||||
import tracker from '../../plugin'
|
||||
import { createQuery } from '@anticrm/presentation'
|
||||
|
||||
export let currentSpace: Ref<Team>
|
||||
export let viewlet: WithLookup<Viewlet> | undefined
|
||||
export let config: (string | BuildModelKey)[] | undefined = undefined
|
||||
export let viewlet: WithLookup<Viewlet>
|
||||
export let query: DocumentQuery<Issue> = {}
|
||||
export let viewOptions: ViewOptions
|
||||
|
||||
const statusesQuery = createQuery()
|
||||
const spaceQuery = createQuery()
|
||||
let currentTeam: Team | undefined
|
||||
let statusesById: ReadonlyMap<Ref<IssueStatus>, WithLookup<IssueStatus>> = new Map()
|
||||
|
||||
$: statusesQuery.query(
|
||||
tracker.class.IssueStatus,
|
||||
{ attachedTo: currentSpace },
|
||||
(issueStatuses) => {
|
||||
statusesById = new Map(issueStatuses.map((status) => [status._id, status]))
|
||||
},
|
||||
{
|
||||
lookup: { category: tracker.class.IssueStatusCategory },
|
||||
sort: { rank: SortingOrder.Ascending }
|
||||
}
|
||||
)
|
||||
|
||||
$: spaceQuery.query(tracker.class.Team, { _id: currentSpace }, (res) => {
|
||||
currentTeam = res.shift()
|
||||
})
|
||||
|
||||
$: statuses = [...statusesById.values()]
|
||||
|
||||
const replacedKeys: Map<string, BuildModelKey> = new Map<string, BuildModelKey>([
|
||||
['@currentTeam', { key: '', presenter: tracker.component.IssuePresenter, props: { currentTeam } }],
|
||||
['@statuses', { key: '', presenter: tracker.component.StatusEditor, props: { statuses } }]
|
||||
])
|
||||
|
||||
function createConfig (descr: Viewlet, preference: ViewletPreference | undefined): (string | BuildModelKey)[] {
|
||||
const base = preference?.config ?? descr.config
|
||||
const result: (string | BuildModelKey)[] = []
|
||||
for (const key of base) {
|
||||
if (typeof key === 'string') {
|
||||
result.push(replacedKeys.get(key) ?? key)
|
||||
} else {
|
||||
result.push(replacedKeys.get(key.key) ?? key)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if viewlet?.$lookup?.descriptor?.component}
|
||||
@ -16,7 +58,7 @@
|
||||
is={viewlet.$lookup?.descriptor?.component}
|
||||
props={{
|
||||
currentSpace,
|
||||
config: config ?? viewlet.config,
|
||||
config: createConfig(viewlet, undefined),
|
||||
options: viewlet.options,
|
||||
viewlet,
|
||||
query,
|
||||
|
@ -16,7 +16,7 @@
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { AttachedData, Ref, SortingOrder, WithLookup } from '@anticrm/core'
|
||||
import { Issue, IssueStatus } from '@anticrm/tracker'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import { createQuery, getClient } from '@anticrm/presentation'
|
||||
import { tooltip, TooltipAlignment } from '@anticrm/ui'
|
||||
import type { ButtonKind, ButtonSize } from '@anticrm/ui'
|
||||
import tracker from '../../plugin'
|
||||
@ -34,6 +34,7 @@
|
||||
export let width: string | undefined = '100%'
|
||||
|
||||
const client = getClient()
|
||||
const statusesQuery = createQuery()
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
const handleStatusChanged = async (newStatus: Ref<IssueStatus> | undefined) => {
|
||||
@ -49,14 +50,17 @@
|
||||
}
|
||||
$: if (!statuses) {
|
||||
const query = '_id' in value ? { attachedTo: value.space } : {}
|
||||
client
|
||||
.findAll(tracker.class.IssueStatus, query, {
|
||||
statusesQuery.query(
|
||||
tracker.class.IssueStatus,
|
||||
query,
|
||||
(result) => {
|
||||
statuses = result
|
||||
},
|
||||
{
|
||||
lookup: { category: tracker.class.IssueStatusCategory },
|
||||
sort: { rank: SortingOrder.Ascending }
|
||||
})
|
||||
.then((result) => {
|
||||
statuses = result
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user