mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-23 20:13:20 +00:00
Do not show statuses of not joined projects in all issues and filter (#6128)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
90a34beb3e
commit
27c626857a
@ -16,7 +16,7 @@
|
||||
import core, { Doc, FindResult, IdMap, Ref, RefTo, Space, Status, toIdMap } from '@hcengineering/core'
|
||||
import { translate } from '@hcengineering/platform'
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import { ProjectType, TaskType } from '@hcengineering/task'
|
||||
import { ProjectStatus, ProjectType, TaskType } from '@hcengineering/task'
|
||||
import ui, {
|
||||
EditWithIcon,
|
||||
Icon,
|
||||
@ -39,7 +39,7 @@
|
||||
import view from '@hcengineering/view-resources/src/plugin'
|
||||
import { buildConfigLookup, getPresenter } from '@hcengineering/view-resources/src/utils'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { selectedTaskTypeStore, selectedTypeStore, taskTypeStore, typeStore } from '..'
|
||||
import { typesOfJoinedProjectsStore, selectedTaskTypeStore, selectedTypeStore, taskTypeStore, typeStore } from '..'
|
||||
|
||||
export let filter: Filter
|
||||
export let space: Ref<Space> | undefined = undefined
|
||||
@ -69,7 +69,8 @@
|
||||
typeStore: IdMap<TaskType>,
|
||||
statusStore: IdMap<Status>,
|
||||
selectedProjectType: Ref<ProjectType> | undefined,
|
||||
projectTypeStore: IdMap<ProjectType>
|
||||
projectTypeStore: IdMap<ProjectType>,
|
||||
joinedSpacesTypes: Ref<ProjectType>[]
|
||||
): Promise<void> {
|
||||
await objectsPromise
|
||||
targets.clear()
|
||||
@ -88,9 +89,14 @@
|
||||
}
|
||||
} else {
|
||||
let statuses: Status[] = []
|
||||
const projectTypesNeeded = joinedSpacesTypes
|
||||
.flatMap((s) => projectTypeStore.get(s)?.statuses)
|
||||
.filter((it, index, arr) => it !== undefined && arr.indexOf(it) === index) as ProjectStatus[]
|
||||
const prjStatuses = new Map(
|
||||
(
|
||||
(selectedProjectType !== undefined ? projectTypeStore.get(selectedProjectType) : undefined)?.statuses ?? []
|
||||
(selectedProjectType !== undefined ? projectTypeStore.get(selectedProjectType) : undefined)?.statuses ??
|
||||
projectTypesNeeded ??
|
||||
[]
|
||||
).map((p) => [p._id, p])
|
||||
)
|
||||
for (const status of statusStore.values()) {
|
||||
@ -182,7 +188,15 @@
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
$: if (targetClass != null) {
|
||||
void getValues(search, $selectedTaskTypeStore, $taskTypeStore, $statusStore.byId, $selectedTypeStore, $typeStore)
|
||||
void getValues(
|
||||
search,
|
||||
$selectedTaskTypeStore,
|
||||
$taskTypeStore,
|
||||
$statusStore.byId,
|
||||
$selectedTypeStore,
|
||||
$typeStore,
|
||||
$typesOfJoinedProjectsStore
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
import core, {
|
||||
getCurrentAccount,
|
||||
toIdMap,
|
||||
type Attribute,
|
||||
type Class,
|
||||
@ -284,7 +285,11 @@ export async function getAllStates (
|
||||
return statuses.map((p) => p?._id)
|
||||
}
|
||||
}
|
||||
const allStates = get(statusStore).array.filter((p) => p.ofAttribute === attr._id)
|
||||
const joinedProjectsTypes = get(typesOfJoinedProjectsStore) ?? []
|
||||
const includedStatuses = Array.from(get(taskTypeStore).values())
|
||||
.filter((taskType) => joinedProjectsTypes.includes(taskType.parent))
|
||||
.flatMap((taskType) => taskType.statuses)
|
||||
const allStates = get(statusStore).array.filter((p) => p.ofAttribute === attr._id && includedStatuses.includes(p._id))
|
||||
if (filterDone) {
|
||||
return allStates
|
||||
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
|
||||
@ -356,6 +361,8 @@ async function statusSort (
|
||||
|
||||
export const typeStore = writable<IdMap<ProjectType>>(new Map())
|
||||
export const taskTypeStore = writable<IdMap<TaskType>>(new Map())
|
||||
export const typesOfJoinedProjectsStore = writable<Array<Ref<ProjectType>>>()
|
||||
export const joinedProjectsStore = writable<Project[]>()
|
||||
|
||||
function fillStores (): void {
|
||||
const client = getClient()
|
||||
@ -370,6 +377,12 @@ function fillStores (): void {
|
||||
taskQuery.query(task.class.TaskType, {}, (res) => {
|
||||
taskTypeStore.set(toIdMap(res))
|
||||
})
|
||||
|
||||
const projectQuery = createQuery(true)
|
||||
projectQuery.query(task.class.Project, { members: getCurrentAccount()._id }, (res) => {
|
||||
typesOfJoinedProjectsStore.set(res.map((r) => r.type).filter((it, idx, arr) => arr.indexOf(it) === idx))
|
||||
joinedProjectsStore.set(res)
|
||||
})
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
fillStores()
|
||||
|
Loading…
Reference in New Issue
Block a user