mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 01:39:53 +00:00
UBERF-5335 (#4655)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
e8dd69dcef
commit
9b0e67b0ee
models/tracker/src
plugins
tracker-resources/src/components
tracker/src
server-plugins/tracker-resources/src
@ -185,6 +185,21 @@ async function fixTrackerTaskTypes (client: MigrationClient): Promise<void> {
|
||||
})
|
||||
}
|
||||
|
||||
async function passIdentifierToParentInfo (client: MigrationClient): Promise<void> {
|
||||
const issues = await client.find<Issue>(DOMAIN_TASK, { _class: tracker.class.Issue, 'parents.0': { $exists: true } })
|
||||
for (const issue of issues) {
|
||||
const parents = toIdMap(
|
||||
await client.find<Issue>(DOMAIN_TASK, { _id: { $in: issue.parents.map((p) => p.parentId) } })
|
||||
)
|
||||
for (const parent of issue.parents) {
|
||||
const p = parents.get(parent.parentId)
|
||||
if (p === undefined) continue
|
||||
parent.identifier = p.identifier
|
||||
}
|
||||
await client.update(DOMAIN_TASK, { _id: issue._id }, { $set: { parents: issue.parents } })
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCreateStatus (client: MigrationClient): Promise<Ref<Status>> {
|
||||
const exists = await client.find<Status>(DOMAIN_STATUS, {
|
||||
_class: tracker.class.IssueStatus,
|
||||
@ -484,6 +499,10 @@ export const trackerOperation: MigrateOperation = {
|
||||
{
|
||||
state: 'identifier',
|
||||
func: migrateIdentifiers
|
||||
},
|
||||
{
|
||||
state: 'passIdentifierToParentInfo',
|
||||
func: passIdentifierToParentInfo
|
||||
}
|
||||
])
|
||||
},
|
||||
|
@ -50,6 +50,7 @@
|
||||
Component as ComponentType,
|
||||
Issue,
|
||||
IssueDraft,
|
||||
IssueParentInfo,
|
||||
IssuePriority,
|
||||
IssueStatus,
|
||||
IssueTemplate,
|
||||
@ -422,6 +423,8 @@
|
||||
|
||||
const number = (incResult as any).object.sequence
|
||||
|
||||
const identifier = `${currentProject?.identifier}-${number}`
|
||||
|
||||
const value: DocData<Issue> = {
|
||||
title: getTitle(object.title),
|
||||
description: object.description,
|
||||
@ -438,7 +441,7 @@
|
||||
parents:
|
||||
parentIssue != null
|
||||
? [
|
||||
{ parentId: parentIssue._id, parentTitle: parentIssue.title, space: parentIssue.space },
|
||||
{ parentId: parentIssue._id, parentTitle: parentIssue.title, space: parentIssue.space, identifier },
|
||||
...parentIssue.parents
|
||||
]
|
||||
: [],
|
||||
@ -449,7 +452,7 @@
|
||||
relations: relatedTo !== undefined ? [{ _id: relatedTo._id, _class: relatedTo._class }] : [],
|
||||
childInfo: [],
|
||||
kind,
|
||||
identifier: `${currentProject?.identifier}-${number}`
|
||||
identifier
|
||||
}
|
||||
|
||||
await docCreateManager.commit(operations, _id, _space, value)
|
||||
@ -486,13 +489,13 @@
|
||||
await operations.commit()
|
||||
await descriptionBox.createAttachments(_id)
|
||||
|
||||
const parents = parentIssue
|
||||
const parents: IssueParentInfo[] = parentIssue
|
||||
? [
|
||||
{ parentId: _id, parentTitle: value.title, space: parentIssue.space },
|
||||
{ parentId: parentIssue._id, parentTitle: parentIssue.title, space: parentIssue.space },
|
||||
{ parentId: _id, parentTitle: value.title, space: parentIssue.space, identifier },
|
||||
{ parentId: parentIssue._id, parentTitle: parentIssue.title, space: parentIssue.space, identifier },
|
||||
...parentIssue.parents
|
||||
]
|
||||
: [{ parentId: _id, parentTitle: value.title, space: _space }]
|
||||
: [{ parentId: _id, parentTitle: value.title, space: _space, identifier }]
|
||||
await subIssuesComponent.save(parents, _id)
|
||||
addNotification(
|
||||
await translate(tracker.string.IssueCreated, {}, $themeStore.language),
|
||||
|
@ -13,17 +13,20 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Issue, IssueParentInfo } from '@hcengineering/tracker'
|
||||
import { showPanel } from '@hcengineering/ui'
|
||||
import tracker from '../../plugin'
|
||||
import { NavLink } from '@hcengineering/presentation'
|
||||
import { trackerId, type Issue, type IssueParentInfo } from '@hcengineering/tracker'
|
||||
import { getCurrentLocation, locationToUrl } from '@hcengineering/ui'
|
||||
|
||||
export let value: Issue | undefined
|
||||
|
||||
export let maxWidth = ''
|
||||
|
||||
function handleIssueEditorOpened (parent: IssueParentInfo) {
|
||||
if (value === undefined) return
|
||||
showPanel(tracker.component.EditIssue, parent.parentId, value._class, 'content')
|
||||
function getHref (parentInfo: IssueParentInfo) {
|
||||
const loc = getCurrentLocation()
|
||||
loc.path[2] = trackerId
|
||||
loc.path[3] = parentInfo.identifier
|
||||
loc.path.length = 4
|
||||
return `${window.location.origin}${locationToUrl(loc)}`
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -33,15 +36,11 @@
|
||||
{#each value.parents as parentInfo}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<span
|
||||
class="parent-label overflow-label cursor-pointer"
|
||||
title={parentInfo.parentTitle}
|
||||
on:click={() => {
|
||||
handleIssueEditorOpened(parentInfo)
|
||||
}}
|
||||
>
|
||||
{parentInfo.parentTitle}
|
||||
</span>
|
||||
<NavLink href={getHref(parentInfo)}>
|
||||
<span class="parent-label overflow-label cursor-pointer" title={parentInfo.parentTitle}>
|
||||
{parentInfo.parentTitle}
|
||||
</span>
|
||||
</NavLink>
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
@ -61,6 +60,7 @@
|
||||
|
||||
.parent-label {
|
||||
flex-shrink: 5;
|
||||
color: var(--theme-dark-color);
|
||||
|
||||
&:hover {
|
||||
color: var(--theme-caption-color);
|
||||
|
@ -301,6 +301,7 @@ export interface TimeSpendReport extends AttachedDoc {
|
||||
*/
|
||||
export interface IssueParentInfo {
|
||||
parentId: Ref<Issue>
|
||||
identifier: string
|
||||
parentTitle: string
|
||||
space: Ref<Space>
|
||||
}
|
||||
|
@ -225,6 +225,7 @@ export async function OnIssueUpdate (tx: Tx, control: TriggerControl): Promise<T
|
||||
const parents: IssueParentInfo[] = parentIssue.map((it) => ({
|
||||
parentId: it._id,
|
||||
parentTitle: it.title,
|
||||
identifier: it.identifier,
|
||||
space: it.space
|
||||
}))
|
||||
updateIssueParentEstimations(
|
||||
@ -358,9 +359,17 @@ async function doIssueUpdate (
|
||||
{ limit: 1 }
|
||||
)
|
||||
|
||||
const updatedParents =
|
||||
const updatedParents: IssueParentInfo[] =
|
||||
newParent !== undefined
|
||||
? [{ parentId: newParent._id, parentTitle: newParent.title, space: newParent.space }, ...newParent.parents]
|
||||
? [
|
||||
{
|
||||
parentId: newParent._id,
|
||||
parentTitle: newParent.title,
|
||||
space: newParent.space,
|
||||
identifier: newParent.identifier
|
||||
},
|
||||
...newParent.parents
|
||||
]
|
||||
: []
|
||||
|
||||
function update (issue: Issue): DocumentUpdate<Issue> {
|
||||
|
Loading…
Reference in New Issue
Block a user