UBERF-5861 (#4861)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-03-03 22:46:45 +06:00 committed by GitHub
parent d5eb02c926
commit 643015a664
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 85 additions and 50 deletions

View File

@ -81,6 +81,10 @@ function defineSortAndGrouping (builder: Builder): void {
builder.mixin(tracker.class.Milestone, core.class.Class, view.mixin.AllValuesFunc, {
func: tracker.function.GetAllMilestones
})
builder.mixin(tracker.class.IssueStatus, core.class.Class, view.mixin.AllValuesFunc, {
func: tracker.function.GetAllStates
})
}
function defineNotifications (builder: Builder): void {

View File

@ -14,7 +14,6 @@
// limitations under the License.
//
import { get, writable } from 'svelte/store'
import {
toIdMap,
type Attribute,
@ -39,9 +38,9 @@ import task, {
import { getCurrentLocation, navigate, showPopup } from '@hcengineering/ui'
import { type ViewletDescriptor } from '@hcengineering/view'
import { CategoryQuery, statusStore } from '@hcengineering/view-resources'
import { get, writable } from 'svelte/store'
import AssignedTasks from './components/AssignedTasks.svelte'
import CreateStatePopup from './components/state/CreateStatePopup.svelte'
import Dashboard from './components/Dashboard.svelte'
import DueDateEditor from './components/DueDateEditor.svelte'
import KanbanTemplatePresenter from './components/KanbanTemplatePresenter.svelte'
@ -54,26 +53,27 @@ import TemplatesIcon from './components/TemplatesIcon.svelte'
import TypesView from './components/TypesView.svelte'
import KanbanView from './components/kanban/KanbanView.svelte'
import ProjectEditor from './components/projectTypes/ProjectEditor.svelte'
import ProjectTypePresenter from './components/projectTypes/ProjectTypePresenter.svelte'
import ProjectTypeSelector from './components/projectTypes/ProjectTypeSelector.svelte'
import CreateStatePopup from './components/state/CreateStatePopup.svelte'
import StateEditor from './components/state/StateEditor.svelte'
import StateIconPresenter from './components/state/StateIconPresenter.svelte'
import StatePresenter from './components/state/StatePresenter.svelte'
import StateRefPresenter from './components/state/StateRefPresenter.svelte'
import TypeStatesPopup from './components/state/TypeStatesPopup.svelte'
import TaskTypeClassPresenter from './components/taskTypes/TaskTypeClassPresenter.svelte'
import ProjectTypeClassPresenter from './components/taskTypes/ProjectTypeClassPresenter.svelte'
import TaskTypePresenter from './components/taskTypes/TaskTypePresenter.svelte'
import ProjectTypePresenter from './components/projectTypes/ProjectTypePresenter.svelte'
import StateIconPresenter from './components/state/StateIconPresenter.svelte'
import TaskKindSelector from './components/taskTypes/TaskKindSelector.svelte'
import TaskTypeClassPresenter from './components/taskTypes/TaskTypeClassPresenter.svelte'
import TaskTypePresenter from './components/taskTypes/TaskTypePresenter.svelte'
import ManageProjects from './components/projectTypes/ManageProjects.svelte'
import ManageProjectsTools from './components/projectTypes/ManageProjectsTools.svelte'
import ManageProjectsContent from './components/projectTypes/ManageProjectsContent.svelte'
import ManageProjectsTools from './components/projectTypes/ManageProjectsTools.svelte'
export { default as AssigneePresenter } from './components/AssigneePresenter.svelte'
export { default as TypeSelector } from './components/TypeSelector.svelte'
export * from './utils'
export { StatePresenter, StateRefPresenter, TypeStatesPopup, TaskKindSelector }
export { StatePresenter, StateRefPresenter, TaskKindSelector, TypeStatesPopup }
async function editStatuses (object: Project, ev: Event): Promise<void> {
const loc = getCurrentLocation()
@ -140,18 +140,17 @@ export default async (): Promise<Resources> => ({
}
})
async function getAllStates (
export async function getAllStates (
query: DocumentQuery<Doc> | undefined,
onUpdate: () => void,
queryId: Ref<Doc>,
attr: Attribute<Status>
attr: Attribute<Status>,
filterDone: boolean = true
): Promise<any[]> {
const typeId = get(selectedTypeStore)
const taskTypeId = get(selectedTaskTypeStore)
if (taskTypeId === undefined) {
return []
}
const type = typeId !== undefined ? get(typeStore).get(typeId) : undefined
const taskTypeId = get(selectedTaskTypeStore)
if (taskTypeId !== undefined) {
const taskType = get(taskTypeStore).get(taskTypeId)
if (taskType === undefined) {
return []
@ -159,9 +158,13 @@ async function getAllStates (
if (type !== undefined) {
const statusMap = get(statusStore).byId
const statuses = (taskType.statuses.map((p) => statusMap.get(p)) as Status[]) ?? []
if (filterDone) {
return statuses
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
.map((p) => p?._id)
} else {
return statuses.map((p) => p?._id)
}
}
const _space = query?.space
if (_space !== undefined) {
@ -171,9 +174,14 @@ async function getAllStates (
refresh = lq.query(task.class.Project, { _id: _space as Ref<Project> }, (res) => {
const statusMap = get(statusStore).byId
const statuses = (taskType.statuses.map((p) => statusMap.get(p)) as Status[]) ?? []
const result = statuses
let result: Array<Ref<Status>> = []
if (filterDone) {
result = statuses
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
.map((p) => p?._id)
} else {
result = statuses.map((p) => p?._id)
}
CategoryQuery.results.set(queryId, result)
resolve(result)
onUpdate()
@ -185,12 +193,25 @@ async function getAllStates (
})
return await promise
}
return get(statusStore)
.array.filter(
(p) =>
p.ofAttribute === attr._id && p.category !== task.statusCategory.Lost && p.category !== task.statusCategory.Won
)
.map((p) => p._id)
} else if (type !== undefined) {
const statusMap = get(statusStore).byId
const statuses = (type.statuses.map((p) => statusMap.get(p._id)) as Status[]) ?? []
if (filterDone) {
return statuses
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
.map((p) => p?._id)
} else {
return statuses.map((p) => p?._id)
}
}
const allStates = get(statusStore).array.filter((p) => p.ofAttribute === attr._id)
if (filterDone) {
return allStates
.filter((p) => p?.category !== task.statusCategory.Lost && p?.category !== task.statusCategory.Won)
.map((p) => p?._id)
} else {
return allStates.map((p) => p?._id)
}
}
async function statusSort (

View File

@ -15,10 +15,12 @@
import { Analytics } from '@hcengineering/analytics'
import core, {
type Attribute,
ClassifierKind,
DOMAIN_CONFIGURATION,
DOMAIN_MODEL,
getCurrentAccount,
type Space,
toIdMap,
type AttachedDoc,
type Class,
@ -29,7 +31,7 @@ import core, {
type RelatedDocument,
type TxOperations
} from '@hcengineering/core'
import { translate, type Resources } from '@hcengineering/platform'
import { type Status, translate, type Resources } from '@hcengineering/platform'
import { getClient, MessageBox, type ObjectSearchResult } from '@hcengineering/presentation'
import { type Issue, type Milestone, type Project } from '@hcengineering/tracker'
import { getCurrentLocation, navigate, showPopup, themeStore } from '@hcengineering/ui'
@ -156,6 +158,7 @@ import ProjectSpacePresenter from './components/projects/ProjectSpacePresenter.s
import { get } from 'svelte/store'
import { settingId } from '@hcengineering/setting'
import { getAllStates } from '@hcengineering/task-resources'
import EstimationValueEditor from './components/issues/timereport/EstimationValueEditor.svelte'
import TimePresenter from './components/issues/timereport/TimePresenter.svelte'
@ -527,6 +530,12 @@ export default async (): Promise<Resources> => ({
GetAllPriority: getAllPriority,
GetAllComponents: getAllComponents,
GetAllMilestones: getAllMilestones,
GetAllStates: async (
query: DocumentQuery<Doc<Space>> | undefined,
onUpdate: () => void,
queryId: Ref<Doc<Space>>,
attr: Attribute<Status>
) => await getAllStates(query, onUpdate, queryId, attr, false),
GetVisibleFilters: getVisibleFilters,
IssueChatTitleProvider: getIssueChatTitle,
IsProjectJoined: async (project: Project) => !project.private || project.members.includes(getCurrentAccount()._id),

View File

@ -390,6 +390,7 @@ export default mergeIds(trackerId, tracker, {
GetAllPriority: '' as GetAllValuesFunc,
GetAllComponents: '' as GetAllValuesFunc,
GetAllMilestones: '' as GetAllValuesFunc,
GetAllStates: '' as GetAllValuesFunc,
GetVisibleFilters: '' as Resource<(filters: KeyFilter[], space?: Ref<Space>) => Promise<KeyFilter[]>>,
IsProjectJoined: '' as Resource<(space: Space) => Promise<boolean>>,
IssueChatTitleProvider: '' as Resource<(object: Doc) => string>,