mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-24 20:40:59 +00:00
Update sub-issue rank when attaching to another issue (#2055)
This commit is contained in:
parent
059bc3fdf8
commit
dd804a079c
@ -154,7 +154,7 @@
|
||||
action: async () =>
|
||||
showPopup(
|
||||
SetDueDateActionPopup,
|
||||
{ value: object, shouldSaveOnChange: false },
|
||||
{ value: object },
|
||||
'top',
|
||||
undefined,
|
||||
(newDueDate) => newDueDate !== undefined && (object.dueDate = newDueDate)
|
||||
@ -167,7 +167,7 @@
|
||||
action: async () =>
|
||||
showPopup(
|
||||
SetParentIssueActionPopup,
|
||||
{ value: { ...object, space, attachedTo: parentIssue?._id }, shouldSaveOnChange: false },
|
||||
{ value: { ...object, space, attachedTo: parentIssue?._id } },
|
||||
'top',
|
||||
(selectedIssue) => selectedIssue !== undefined && (parentIssue = selectedIssue)
|
||||
)
|
||||
|
@ -13,15 +13,15 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { AttachedData } from '@anticrm/core'
|
||||
import { DatePopup } from '@anticrm/ui'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import { Issue } from '@anticrm/tracker'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
export let value: Issue
|
||||
export let value: Issue | AttachedData<Issue>
|
||||
export let mondayStart = true
|
||||
export let withTime = false
|
||||
export let shouldSaveOnChange = true
|
||||
|
||||
const client = getClient()
|
||||
const dispatch = createEventDispatcher()
|
||||
@ -29,16 +29,8 @@
|
||||
async function onUpdate ({ detail }: CustomEvent<Date | null | undefined>) {
|
||||
const newDueDate = detail && detail?.getTime()
|
||||
|
||||
if (shouldSaveOnChange && newDueDate !== undefined && newDueDate !== value.dueDate) {
|
||||
await client.updateCollection(
|
||||
value._class,
|
||||
value.space,
|
||||
value._id,
|
||||
value.attachedTo,
|
||||
value.attachedToClass,
|
||||
value.collection,
|
||||
{ dueDate: newDueDate }
|
||||
)
|
||||
if ('_id' in value && newDueDate !== undefined && newDueDate !== value.dueDate) {
|
||||
await client.update(value, { dueDate: newDueDate })
|
||||
}
|
||||
|
||||
dispatch('update', newDueDate)
|
||||
|
@ -13,8 +13,8 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { FindOptions, SortingOrder } from '@anticrm/core'
|
||||
import { Issue, IssueStatusCategory, Team } from '@anticrm/tracker'
|
||||
import { AttachedData, FindOptions, SortingOrder } from '@anticrm/core'
|
||||
import { Issue, IssueStatusCategory, Team, calcRank } from '@anticrm/tracker'
|
||||
import { createQuery, getClient } from '@anticrm/presentation'
|
||||
import { Icon } from '@anticrm/ui'
|
||||
import ObjectPopup from '@anticrm/presentation/src/components/ObjectPopup.svelte'
|
||||
@ -22,8 +22,7 @@
|
||||
import tracker from '../plugin'
|
||||
import { getIssueId } from '../utils'
|
||||
|
||||
export let value: Issue
|
||||
export let shouldSaveOnChange = true
|
||||
export let value: Issue | AttachedData<Issue>
|
||||
|
||||
const client = getClient()
|
||||
const spaceQuery = createQuery()
|
||||
@ -43,32 +42,38 @@
|
||||
}
|
||||
|
||||
async function onClose ({ detail: parentIssue }: CustomEvent<Issue | undefined | null>) {
|
||||
if (shouldSaveOnChange && parentIssue !== undefined && parentIssue?._id !== value.attachedTo) {
|
||||
await client.updateCollection(
|
||||
value._class,
|
||||
value.space,
|
||||
value._id,
|
||||
value.attachedTo,
|
||||
value.attachedToClass,
|
||||
'subIssues',
|
||||
{ attachedTo: parentIssue === null ? tracker.ids.NoParent : parentIssue._id }
|
||||
)
|
||||
if ('_id' in value && parentIssue !== undefined && parentIssue?._id !== value.attachedTo) {
|
||||
let rank: string | null = null
|
||||
|
||||
if (parentIssue) {
|
||||
const lastAttachedIssue = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ attachedTo: parentIssue._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
|
||||
rank = calcRank(lastAttachedIssue, undefined)
|
||||
}
|
||||
|
||||
await client.update(value, {
|
||||
attachedTo: parentIssue === null ? tracker.ids.NoParent : parentIssue._id,
|
||||
...(rank ? { rank } : {})
|
||||
})
|
||||
}
|
||||
|
||||
dispatch('close', parentIssue)
|
||||
}
|
||||
|
||||
$: ignoreObjects = value._id ? [value._id] : []
|
||||
$: selected = 'attachedTo' in value ? value.attachedTo : undefined
|
||||
$: ignoreObjects = '_id' in value ? [value._id] : []
|
||||
$: updateIssueStatusCategories()
|
||||
$: if (value.space) {
|
||||
spaceQuery.query(tracker.class.Team, { _id: value.space }, (res) => ([team] = res))
|
||||
}
|
||||
$: 'space' in value && spaceQuery.query(tracker.class.Team, { _id: value.space }, (res) => ([team] = res))
|
||||
</script>
|
||||
|
||||
<ObjectPopup
|
||||
_class={tracker.class.Issue}
|
||||
{options}
|
||||
selected={value.attachedTo}
|
||||
{selected}
|
||||
multiSelect={false}
|
||||
allowDeselect={true}
|
||||
placeholder={tracker.string.SetParent}
|
||||
|
@ -69,7 +69,11 @@
|
||||
}
|
||||
|
||||
const space = currentTeam._id
|
||||
const lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const lastOne = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ space },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
|
Loading…
Reference in New Issue
Block a user