UBERF-9264: Fix set/unset parent issue (#7799)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-01-27 15:14:54 +05:00
committed by GitHub
parent 83a912d716
commit 331aa7f78f
20 changed files with 133 additions and 51 deletions
@@ -66,24 +66,13 @@
$: selected = !Array.isArray(value) ? ('attachedTo' in value ? value.attachedTo : undefined) : undefined
$: ignoreObjects = !Array.isArray(value) ? ('_id' in value ? [value._id] : []) : undefined
$: docQuery = {
'parents.parentId': {
$nin: [
...new Set(
(Array.isArray(value) ? value : [value])
.map((issue) => ('_id' in issue ? issue._id : null))
.filter((x): x is Ref<Issue> => x !== null)
)
]
}
}
</script>
<ObjectPopup
_class={tracker.class.Issue}
{options}
{docQuery}
{selected}
category={tracker.completion.IssueCategory}
multiSelect={false}
allowDeselect={true}
placeholder={tracker.string.SetParent}
@@ -91,7 +80,7 @@
{ignoreObjects}
shadows={true}
{width}
searchMode={'fulltext'}
searchMode={'spotlight'}
on:update
on:close={onClose}
>
@@ -175,6 +175,13 @@
$: taskType = issue?.kind !== undefined ? $taskTypeStore.get(issue?.kind) : undefined
$: projectType = taskType?.parent !== undefined ? $typeStore.get(taskType.parent) : undefined
async function unsetParentIssue (): Promise<void> {
if (issue === undefined || readonly) return
await client.update(issue, { attachedTo: tracker.ids.NoParent })
Analytics.handleEvent(TrackerEvents.IssueParentUnset, { issue: issue.identifier ?? issue._id })
}
</script>
{#if !embedded}
@@ -276,8 +283,22 @@
</svelte:fragment>
{#if hasParentIssue}
<div class="mb-6">
<div class="mb-6 flex-row-center">
<SubIssueSelector {issue} />
{#if !readonly}
<div class="ml-2">
<Button
icon={tracker.icon.UnsetParent}
iconProps={{ size: 'medium' }}
kind={'regular'}
showTooltip={{ label: tracker.string.UnsetParentIssue }}
dataId={'btnUnsetParent'}
on:click={() => {
void unsetParentIssue()
}}
/>
</div>
{/if}
</div>
{/if}
<EditBox
+5
View File
@@ -15,6 +15,7 @@
import { type StatusCategory, type Client, type Doc, type Ref, type Space } from '@hcengineering/core'
import type { Asset, IntlString, Metadata, Resource } from '@hcengineering/platform'
import { mergeIds } from '@hcengineering/platform'
import type { ObjectSearchCategory, ObjectSearchFactory } from '@hcengineering/presentation'
import { type ProjectType } from '@hcengineering/task'
import tracker, { trackerId, type IssueDraft, type Issue } from '@hcengineering/tracker'
import { type AnyComponent, type Location } from '@hcengineering/ui'
@@ -37,6 +38,10 @@ export default mergeIds(trackerId, tracker, {
MilestoneIssuesList: '' as Ref<Viewlet>,
ComponentIssuesList: '' as Ref<Viewlet>
},
completion: {
IssueQuery: '' as Resource<ObjectSearchFactory>,
IssueCategory: '' as Ref<ObjectSearchCategory>
},
string: {
More: '' as IntlString,
Delete: '' as IntlString,