mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 00:10:37 +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 core, { Doc, FindResult, IdMap, Ref, RefTo, Space, Status, toIdMap } from '@hcengineering/core'
|
||||||
import { translate } from '@hcengineering/platform'
|
import { translate } from '@hcengineering/platform'
|
||||||
import presentation, { getClient } from '@hcengineering/presentation'
|
import presentation, { getClient } from '@hcengineering/presentation'
|
||||||
import { ProjectType, TaskType } from '@hcengineering/task'
|
import { ProjectStatus, ProjectType, TaskType } from '@hcengineering/task'
|
||||||
import ui, {
|
import ui, {
|
||||||
EditWithIcon,
|
EditWithIcon,
|
||||||
Icon,
|
Icon,
|
||||||
@ -39,7 +39,7 @@
|
|||||||
import view from '@hcengineering/view-resources/src/plugin'
|
import view from '@hcengineering/view-resources/src/plugin'
|
||||||
import { buildConfigLookup, getPresenter } from '@hcengineering/view-resources/src/utils'
|
import { buildConfigLookup, getPresenter } from '@hcengineering/view-resources/src/utils'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import { selectedTaskTypeStore, selectedTypeStore, taskTypeStore, typeStore } from '..'
|
import { typesOfJoinedProjectsStore, selectedTaskTypeStore, selectedTypeStore, taskTypeStore, typeStore } from '..'
|
||||||
|
|
||||||
export let filter: Filter
|
export let filter: Filter
|
||||||
export let space: Ref<Space> | undefined = undefined
|
export let space: Ref<Space> | undefined = undefined
|
||||||
@ -69,7 +69,8 @@
|
|||||||
typeStore: IdMap<TaskType>,
|
typeStore: IdMap<TaskType>,
|
||||||
statusStore: IdMap<Status>,
|
statusStore: IdMap<Status>,
|
||||||
selectedProjectType: Ref<ProjectType> | undefined,
|
selectedProjectType: Ref<ProjectType> | undefined,
|
||||||
projectTypeStore: IdMap<ProjectType>
|
projectTypeStore: IdMap<ProjectType>,
|
||||||
|
joinedSpacesTypes: Ref<ProjectType>[]
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await objectsPromise
|
await objectsPromise
|
||||||
targets.clear()
|
targets.clear()
|
||||||
@ -88,9 +89,14 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let statuses: Status[] = []
|
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(
|
const prjStatuses = new Map(
|
||||||
(
|
(
|
||||||
(selectedProjectType !== undefined ? projectTypeStore.get(selectedProjectType) : undefined)?.statuses ?? []
|
(selectedProjectType !== undefined ? projectTypeStore.get(selectedProjectType) : undefined)?.statuses ??
|
||||||
|
projectTypesNeeded ??
|
||||||
|
[]
|
||||||
).map((p) => [p._id, p])
|
).map((p) => [p._id, p])
|
||||||
)
|
)
|
||||||
for (const status of statusStore.values()) {
|
for (const status of statusStore.values()) {
|
||||||
@ -182,7 +188,15 @@
|
|||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
$: if (targetClass != null) {
|
$: if (targetClass != null) {
|
||||||
void getValues(search, $selectedTaskTypeStore, $taskTypeStore, $statusStore.byId, $selectedTypeStore, $typeStore)
|
void getValues(
|
||||||
|
search,
|
||||||
|
$selectedTaskTypeStore,
|
||||||
|
$taskTypeStore,
|
||||||
|
$statusStore.byId,
|
||||||
|
$selectedTypeStore,
|
||||||
|
$typeStore,
|
||||||
|
$typesOfJoinedProjectsStore
|
||||||
|
)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import core, {
|
import core, {
|
||||||
|
getCurrentAccount,
|
||||||
toIdMap,
|
toIdMap,
|
||||||
type Attribute,
|
type Attribute,
|
||||||
type Class,
|
type Class,
|
||||||
@ -284,7 +285,11 @@ export async function getAllStates (
|
|||||||
return statuses.map((p) => p?._id)
|
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) {
|
if (filterDone) {
|
||||||
return allStates
|
return allStates
|
||||||
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
|
.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 typeStore = writable<IdMap<ProjectType>>(new Map())
|
||||||
export const taskTypeStore = writable<IdMap<TaskType>>(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 {
|
function fillStores (): void {
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
@ -370,6 +377,12 @@ function fillStores (): void {
|
|||||||
taskQuery.query(task.class.TaskType, {}, (res) => {
|
taskQuery.query(task.class.TaskType, {}, (res) => {
|
||||||
taskTypeStore.set(toIdMap(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 {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
fillStores()
|
fillStores()
|
||||||
|
Loading…
Reference in New Issue
Block a user