mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-01 04:35:46 +00:00
Fix status order (#8067)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
f137df66eb
commit
a604a1cc94
@ -152,11 +152,16 @@ export async function getAllStates (
|
|||||||
attr: Attribute<Status>,
|
attr: Attribute<Status>,
|
||||||
filterDone: boolean = true
|
filterDone: boolean = true
|
||||||
): Promise<any[]> {
|
): Promise<any[]> {
|
||||||
const typeId = get(selectedTypeStore)
|
const joinedProjectsTypes = get(typesOfJoinedProjectsStore) ?? []
|
||||||
|
const typeId = get(selectedTypeStore) ?? (joinedProjectsTypes.length === 1 ? joinedProjectsTypes[0] : undefined)
|
||||||
const type = typeId !== undefined ? get(typeStore).get(typeId) : undefined
|
const type = typeId !== undefined ? get(typeStore).get(typeId) : undefined
|
||||||
const taskTypeId = get(selectedTaskTypeStore)
|
const $taskType = get(taskTypeStore)
|
||||||
|
const joinedTaskTypes = Array.from($taskType.values()).filter((taskType) =>
|
||||||
|
joinedProjectsTypes.includes(taskType.parent)
|
||||||
|
)
|
||||||
|
const taskTypeId = get(selectedTaskTypeStore) ?? (joinedTaskTypes.length === 1 ? joinedTaskTypes[0]?._id : undefined)
|
||||||
if (taskTypeId !== undefined) {
|
if (taskTypeId !== undefined) {
|
||||||
const taskType = get(taskTypeStore).get(taskTypeId)
|
const taskType = $taskType.get(taskTypeId)
|
||||||
if (taskType === undefined) {
|
if (taskType === undefined) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@ -209,17 +214,16 @@ export async function getAllStates (
|
|||||||
return statuses.map((p) => p?._id)
|
return statuses.map((p) => p?._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const joinedProjectsTypes = get(typesOfJoinedProjectsStore) ?? []
|
const includedStatuses = new Set(joinedTaskTypes.flatMap((taskType) => taskType.statuses))
|
||||||
const includedStatuses = Array.from(get(taskTypeStore).values())
|
const $statusStore = get(statusStore)
|
||||||
.filter((taskType) => joinedProjectsTypes.includes(taskType.parent))
|
const allStates = [...includedStatuses].map((p) => $statusStore.byId.get(p))
|
||||||
.flatMap((taskType) => taskType.statuses)
|
const states = allStates.filter((p) => p !== undefined && p.ofAttribute === attr._id)
|
||||||
const allStates = get(statusStore).array.filter((p) => p.ofAttribute === attr._id && includedStatuses.includes(p._id))
|
|
||||||
if (filterDone) {
|
if (filterDone) {
|
||||||
return allStates
|
return states
|
||||||
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
|
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
|
||||||
.map((p) => p?._id)
|
.map((p) => p?._id)
|
||||||
} else {
|
} else {
|
||||||
return allStates.map((p) => p?._id)
|
return states.map((p) => p?._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,12 @@ import core, {
|
|||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import { type IntlString } from '@hcengineering/platform'
|
import { type IntlString } from '@hcengineering/platform'
|
||||||
import { createQuery, getClient, onClient } from '@hcengineering/presentation'
|
import { createQuery, getClient, onClient } from '@hcengineering/presentation'
|
||||||
import task, { getStatusIndex, makeRank, type ProjectType } from '@hcengineering/task'
|
import task, { getStatusIndex, makeRank, type TaskType, type ProjectType } from '@hcengineering/task'
|
||||||
import { activeProjects as taskActiveProjects, taskTypeStore } from '@hcengineering/task-resources'
|
import {
|
||||||
|
activeProjects as taskActiveProjects,
|
||||||
|
taskTypeStore,
|
||||||
|
typesOfJoinedProjectsStore
|
||||||
|
} from '@hcengineering/task-resources'
|
||||||
import {
|
import {
|
||||||
IssuePriority,
|
IssuePriority,
|
||||||
MilestoneStatus,
|
MilestoneStatus,
|
||||||
@ -49,7 +53,7 @@ import {
|
|||||||
type Milestone,
|
type Milestone,
|
||||||
type Project
|
type Project
|
||||||
} from '@hcengineering/tracker'
|
} from '@hcengineering/tracker'
|
||||||
import { PaletteColorIndexes, areDatesEqual, isWeekend } from '@hcengineering/ui'
|
import { areDatesEqual, isWeekend, PaletteColorIndexes } from '@hcengineering/ui'
|
||||||
import { type KeyFilter, type ViewletDescriptor } from '@hcengineering/view'
|
import { type KeyFilter, type ViewletDescriptor } from '@hcengineering/view'
|
||||||
import { CategoryQuery, ListSelectionProvider, statusStore, type SelectDirection } from '@hcengineering/view-resources'
|
import { CategoryQuery, ListSelectionProvider, statusStore, type SelectDirection } from '@hcengineering/view-resources'
|
||||||
import { derived, get, writable } from 'svelte/store'
|
import { derived, get, writable } from 'svelte/store'
|
||||||
@ -124,6 +128,16 @@ export const listIssueKanbanStatusOrder = [
|
|||||||
task.statusCategory.Lost
|
task.statusCategory.Lost
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
function getTaskTypesStatusIndex (joinedTaskTypes: TaskType[], status: Ref<Status>): number {
|
||||||
|
for (const taskType of joinedTaskTypes) {
|
||||||
|
const indexx = taskType.statuses.indexOf(status)
|
||||||
|
if (indexx >= 0) {
|
||||||
|
return indexx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
export async function issueStatusSort (
|
export async function issueStatusSort (
|
||||||
client: TxOperations,
|
client: TxOperations,
|
||||||
value: Array<Ref<IssueStatus>>,
|
value: Array<Ref<IssueStatus>>,
|
||||||
@ -143,7 +157,12 @@ export async function issueStatusSort (
|
|||||||
)
|
)
|
||||||
type = _space?.$lookup?.type
|
type = _space?.$lookup?.type
|
||||||
}
|
}
|
||||||
|
const joinedProjectsTypes = get(typesOfJoinedProjectsStore) ?? []
|
||||||
const taskTypes = get(taskTypeStore)
|
const taskTypes = get(taskTypeStore)
|
||||||
|
const joinedTaskTypes = Array.from(taskTypes.values()).filter(
|
||||||
|
(taskType) => joinedProjectsTypes.includes(taskType.parent) && taskType.ofClass === tracker.class.Issue
|
||||||
|
)
|
||||||
|
|
||||||
const statuses = get(statusStore).byId
|
const statuses = get(statusStore).byId
|
||||||
// TODO: How we track category updates.
|
// TODO: How we track category updates.
|
||||||
|
|
||||||
@ -159,9 +178,10 @@ export async function issueStatusSort (
|
|||||||
const aIndex = getStatusIndex(type, taskTypes, a)
|
const aIndex = getStatusIndex(type, taskTypes, a)
|
||||||
const bIndex = getStatusIndex(type, taskTypes, b)
|
const bIndex = getStatusIndex(type, taskTypes, b)
|
||||||
return aIndex - bIndex
|
return aIndex - bIndex
|
||||||
} else {
|
|
||||||
return (aVal?.name ?? '').localeCompare(bVal?.name ?? '')
|
|
||||||
}
|
}
|
||||||
|
const aIndex = getTaskTypesStatusIndex(joinedTaskTypes, a)
|
||||||
|
const bIndex = getTaskTypesStatusIndex(joinedTaskTypes, b)
|
||||||
|
return aIndex - bIndex
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
@ -177,9 +197,10 @@ export async function issueStatusSort (
|
|||||||
const aIndex = getStatusIndex(type, taskTypes, a)
|
const aIndex = getStatusIndex(type, taskTypes, a)
|
||||||
const bIndex = getStatusIndex(type, taskTypes, b)
|
const bIndex = getStatusIndex(type, taskTypes, b)
|
||||||
return aIndex - bIndex
|
return aIndex - bIndex
|
||||||
} else if (aVal != null && bVal != null) {
|
|
||||||
return aVal.name.localeCompare(bVal.name)
|
|
||||||
}
|
}
|
||||||
|
const aIndex = getTaskTypesStatusIndex(joinedTaskTypes, a)
|
||||||
|
const bIndex = getTaskTypesStatusIndex(joinedTaskTypes, b)
|
||||||
|
return aIndex - bIndex
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user