Minor tracker fixes (#2582)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-02-03 10:06:59 +06:00 committed by GitHub
parent 8b12b64340
commit 7f05cbe497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 10 deletions

View File

@ -553,8 +553,7 @@
} }
} }
} }
addNotification(await translate(tracker.string.IssueCreated, {}), getTitle(object.title), IssueNotification, {
addNotification(tracker.string.IssueCreated, getTitle(object.title), IssueNotification, {
issueId: objectId, issueId: objectId,
subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase(), subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase(),
issueUrl: currentTeam && generateIssueShortLink(getIssueId(currentTeam, value as Issue)) issueUrl: currentTeam && generateIssueShortLink(getIssueId(currentTeam, value as Issue))
@ -707,6 +706,9 @@
<ObjectBox <ObjectBox
_class={tracker.class.IssueTemplate} _class={tracker.class.IssueTemplate}
value={templateId} value={templateId}
docQuery={{
space: _space
}}
on:change={handleTemplateChange} on:change={handleTemplateChange}
size={'small'} size={'small'}
label={tracker.string.NoIssueTemplate} label={tracker.string.NoIssueTemplate}

View File

@ -135,7 +135,7 @@
}) })
} }
addNotification(tracker.string.IssueCreated, getTitle(newIssue.title), IssueNotification, { addNotification(await translate(tracker.string.IssueCreated, {}), getTitle(newIssue.title), IssueNotification, {
issueId: objectId, issueId: objectId,
subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase() subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase()
}) })

View File

@ -25,8 +25,8 @@
ToggleWithLabel ToggleWithLabel
} from '@hcengineering/ui' } from '@hcengineering/ui'
import presentation, { Card, getClient } from '@hcengineering/presentation' import presentation, { Card, getClient } from '@hcengineering/presentation'
import core, { getCurrentAccount, Ref } from '@hcengineering/core' import core, { generateId, getCurrentAccount, Ref, SortingOrder } from '@hcengineering/core'
import { IssueStatus, Team, TimeReportDayType, WorkDayLength } from '@hcengineering/tracker' import { genRanks, IssueStatus, Team, TimeReportDayType, WorkDayLength } from '@hcengineering/tracker'
import { StyledTextBox } from '@hcengineering/text-editor' import { StyledTextBox } from '@hcengineering/text-editor'
import { Asset } from '@hcengineering/platform' import { Asset } from '@hcengineering/platform'
import tracker from '../../plugin' import tracker from '../../plugin'
@ -62,6 +62,8 @@
isNew ? createTeam() : updateTeam() isNew ? createTeam() : updateTeam()
} }
const defaultStatusId: Ref<IssueStatus> = generateId()
function getTeamData () { function getTeamData () {
return { return {
name, name,
@ -72,7 +74,7 @@
identifier: name.toUpperCase().replaceAll(' ', '_'), identifier: name.toUpperCase().replaceAll(' ', '_'),
sequence: 0, sequence: 0,
issueStatuses: 0, issueStatuses: 0,
defaultIssueStatus: '' as Ref<IssueStatus>, defaultIssueStatus: defaultStatusId,
icon, icon,
defaultTimeReportDay: selectedWorkDayType ?? TimeReportDayType.PreviousWorkDay, defaultTimeReportDay: selectedWorkDayType ?? TimeReportDayType.PreviousWorkDay,
workDayLength: selectedWorkDayLength ?? WorkDayLength.EIGHT_HOURS workDayLength: selectedWorkDayLength ?? WorkDayLength.EIGHT_HOURS
@ -97,7 +99,36 @@
} }
async function createTeam () { async function createTeam () {
await client.createDoc(tracker.class.Team, core.space.Space, getTeamData()) const id = await client.createDoc(tracker.class.Team, core.space.Space, getTeamData())
await createTeamIssueStatuses(id, defaultStatusId)
}
async function createTeamIssueStatuses (
teamId: Ref<Team>,
defaultStatusId: Ref<IssueStatus>,
defaultCategoryId = tracker.issueStatusCategory.Backlog
): Promise<void> {
const categories = await client.findAll(
tracker.class.IssueStatusCategory,
{},
{ sort: { order: SortingOrder.Ascending } }
)
const issueStatusRanks = [...genRanks(categories.length)]
for (const [i, statusCategory] of categories.entries()) {
const { _id: category, defaultStatusName } = statusCategory
const rank = issueStatusRanks[i]
await client.addCollection(
tracker.class.IssueStatus,
teamId,
teamId,
tracker.class.Team,
'issueStatuses',
{ name: defaultStatusName, category, rank },
category === defaultCategoryId ? defaultStatusId : undefined
)
}
} }
function chooseIcon (ev: MouseEvent) { function chooseIcon (ev: MouseEvent) {

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { DocumentQuery, WithLookup } from '@hcengineering/core' import { DocumentQuery, Ref, Space, WithLookup } from '@hcengineering/core'
import { IssueTemplate } from '@hcengineering/tracker' import { IssueTemplate } from '@hcengineering/tracker'
import { Component } from '@hcengineering/ui' import { Component } from '@hcengineering/ui'
import { Viewlet, ViewOptions } from '@hcengineering/view' import { Viewlet, ViewOptions } from '@hcengineering/view'
@ -9,6 +9,7 @@
export let viewlet: WithLookup<Viewlet> export let viewlet: WithLookup<Viewlet>
export let viewOptions: ViewOptions export let viewOptions: ViewOptions
export let query: DocumentQuery<IssueTemplate> = {} export let query: DocumentQuery<IssueTemplate> = {}
export let space: Ref<Space> | undefined
const createItemDialog = CreateIssueTemplate const createItemDialog = CreateIssueTemplate
const createItemLabel = tracker.string.IssueTemplate const createItemLabel = tracker.string.IssueTemplate
@ -26,6 +27,7 @@
viewOptions, viewOptions,
viewOptionsConfig: viewlet.viewOptions?.other, viewOptionsConfig: viewlet.viewOptions?.other,
viewlet, viewlet,
space,
query query
}} }}
/> />

View File

@ -68,7 +68,7 @@
$: if (docWidth > 900 && docSize) docSize = false $: if (docWidth > 900 && docSize) docSize = false
const showCreateDialog = async () => { const showCreateDialog = async () => {
showPopup(CreateIssueTemplate, { targetElement: null }, 'top') showPopup(CreateIssueTemplate, { targetElement: null, space }, 'top')
} }
$: viewOptions = getViewOptions(viewlet) $: viewOptions = getViewOptions(viewlet)
@ -114,7 +114,7 @@
/> />
<div class="flex w-full h-full clear-mins"> <div class="flex w-full h-full clear-mins">
{#if viewlet && viewOptions} {#if viewlet && viewOptions}
<IssueTemplatesContent {viewOptions} {viewlet} query={resultQuery} /> <IssueTemplatesContent {viewOptions} {viewlet} {space} query={resultQuery} />
{/if} {/if}
{#if $$slots.aside !== undefined && asideShown} {#if $$slots.aside !== undefined && asideShown}
<div class="popupPanel-body__aside flex" class:float={asideFloat} class:shown={asideShown}> <div class="popupPanel-body__aside flex" class:float={asideFloat} class:shown={asideShown}>