mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
update show empty groups (#2897)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
972e82eb32
commit
5130eb8862
@ -63,9 +63,9 @@ import type {
|
||||
ViewOptionsModel,
|
||||
ViewOptions,
|
||||
AllValuesFunc,
|
||||
GetAllValuesFunc,
|
||||
LinkProvider,
|
||||
ObjectPanel,
|
||||
AllValuesFuncGetter
|
||||
ObjectPanel
|
||||
} from '@hcengineering/view'
|
||||
import view from './plugin'
|
||||
|
||||
@ -221,7 +221,7 @@ export class TSortFuncs extends TClass implements ClassSortFuncs {
|
||||
|
||||
@Mixin(view.mixin.AllValuesFunc, core.class.Class)
|
||||
export class TAllValuesFunc extends TClass implements AllValuesFunc {
|
||||
func!: Resource<AllValuesFuncGetter>
|
||||
func!: GetAllValuesFunc
|
||||
}
|
||||
|
||||
@Model(view.class.ViewletPreference, preference.class.Preference)
|
||||
|
@ -17,7 +17,7 @@ import type { IntlString, Metadata, Resource } from '@hcengineering/platform'
|
||||
import { mergeIds } from '@hcengineering/platform'
|
||||
import { IssueDraft } from '@hcengineering/tracker'
|
||||
import { AnyComponent, Location } from '@hcengineering/ui'
|
||||
import { AllValuesFuncGetter, SortFunc, Viewlet, ViewletDescriptor, ViewQueryAction } from '@hcengineering/view'
|
||||
import { GetAllValuesFunc, SortFunc, Viewlet, ViewletDescriptor, ViewQueryAction } from '@hcengineering/view'
|
||||
import tracker, { trackerId } from '../../tracker/lib'
|
||||
|
||||
export default mergeIds(trackerId, tracker, {
|
||||
@ -389,8 +389,8 @@ export default mergeIds(trackerId, tracker, {
|
||||
IssuePrioritySort: '' as SortFunc,
|
||||
SprintSort: '' as SortFunc,
|
||||
SubIssueQuery: '' as ViewQueryAction,
|
||||
GetAllPriority: '' as Resource<AllValuesFuncGetter>,
|
||||
GetAllComponents: '' as Resource<AllValuesFuncGetter>,
|
||||
GetAllSprints: '' as Resource<AllValuesFuncGetter>
|
||||
GetAllPriority: '' as GetAllValuesFunc,
|
||||
GetAllComponents: '' as GetAllValuesFunc,
|
||||
GetAllSprints: '' as GetAllValuesFunc
|
||||
}
|
||||
})
|
||||
|
@ -24,7 +24,6 @@ import core, {
|
||||
DocumentUpdate,
|
||||
Ref,
|
||||
SortingOrder,
|
||||
Space,
|
||||
StatusCategory,
|
||||
StatusValue,
|
||||
toIdMap,
|
||||
@ -464,25 +463,19 @@ export function subIssueQuery (value: boolean, query: DocumentQuery<Issue>): Doc
|
||||
|
||||
async function getAllSomething (
|
||||
_class: Ref<Class<Doc>>,
|
||||
space: Ref<Space> | undefined,
|
||||
query: DocumentQuery<Doc> | undefined,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>
|
||||
): Promise<any[] | undefined> {
|
||||
const promise = new Promise<Array<Ref<Doc>>>((resolve, reject) => {
|
||||
let refresh: boolean = false
|
||||
const lq = CategoryQuery.getLiveQuery(queryId)
|
||||
refresh = lq.query(
|
||||
_class,
|
||||
{
|
||||
space
|
||||
},
|
||||
(res) => {
|
||||
const result = res.map((p) => p._id)
|
||||
CategoryQuery.results.set(queryId, result)
|
||||
resolve(result)
|
||||
onUpdate()
|
||||
}
|
||||
)
|
||||
refresh = lq.query(_class, query ?? {}, (res) => {
|
||||
const result = res.map((p) => p._id)
|
||||
CategoryQuery.results.set(queryId, result)
|
||||
resolve(result)
|
||||
onUpdate()
|
||||
})
|
||||
|
||||
if (!refresh) {
|
||||
resolve(CategoryQuery.results.get(queryId) ?? [])
|
||||
@ -492,7 +485,7 @@ async function getAllSomething (
|
||||
}
|
||||
|
||||
export async function getAllPriority (
|
||||
space: Ref<Space> | undefined,
|
||||
query: DocumentQuery<Doc> | undefined,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>
|
||||
): Promise<any[] | undefined> {
|
||||
@ -500,19 +493,19 @@ export async function getAllPriority (
|
||||
}
|
||||
|
||||
export async function getAllComponents (
|
||||
space: Ref<Project> | undefined,
|
||||
query: DocumentQuery<Doc> | undefined,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>
|
||||
): Promise<any[] | undefined> {
|
||||
return await getAllSomething(tracker.class.Component, space, onUpdate, queryId)
|
||||
return await getAllSomething(tracker.class.Component, query, onUpdate, queryId)
|
||||
}
|
||||
|
||||
export async function getAllSprints (
|
||||
space: Ref<Project> | undefined,
|
||||
query: DocumentQuery<Doc> | undefined,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>
|
||||
): Promise<any[] | undefined> {
|
||||
return await getAllSomething(tracker.class.Sprint, space, onUpdate, queryId)
|
||||
return await getAllSomething(tracker.class.Sprint, query, onUpdate, queryId)
|
||||
}
|
||||
|
||||
export function subIssueListProvider (subIssues: Issue[], target: Ref<Issue>): void {
|
||||
|
@ -147,6 +147,7 @@
|
||||
{docs}
|
||||
{_class}
|
||||
{space}
|
||||
query={resultQuery}
|
||||
{lookup}
|
||||
loadingPropsLength={getLoadingElementsLength(loadingProps, options)}
|
||||
{baseMenuClass}
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { CategoryType, Class, Doc, generateId, Lookup, Ref, Space } from '@hcengineering/core'
|
||||
import { CategoryType, Class, Doc, DocumentQuery, generateId, Lookup, Ref, Space } from '@hcengineering/core'
|
||||
import { getResource, IntlString } from '@hcengineering/platform'
|
||||
import { getClient, statusStore } from '@hcengineering/presentation'
|
||||
import { AnyComponent } from '@hcengineering/ui'
|
||||
@ -28,6 +28,7 @@
|
||||
export let docs: Doc[]
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let space: Ref<Space> | undefined
|
||||
export let query: DocumentQuery<Doc> | undefined
|
||||
export let lookup: Lookup<Doc>
|
||||
export let loadingPropsLength: number | undefined
|
||||
export let baseMenuClass: Ref<Class<Doc>> | undefined
|
||||
@ -82,7 +83,7 @@
|
||||
const categoryFunc = viewOption as CategoryOption
|
||||
if (viewOptions[viewOption.key] ?? viewOption.defaultValue) {
|
||||
const f = await getResource(categoryFunc.action)
|
||||
const res = hierarchy.clone(await f(_class, space, groupByKey, update, queryId, $statusStore))
|
||||
const res = hierarchy.clone(await f(_class, query, groupByKey, update, queryId, $statusStore))
|
||||
if (res !== undefined) {
|
||||
categories = res
|
||||
return
|
||||
|
@ -1,4 +1,4 @@
|
||||
import core, { Class, Doc, Ref, SortingOrder, Space, StatusManager } from '@hcengineering/core'
|
||||
import core, { Class, Doc, DocumentQuery, Ref, SortingOrder, StatusManager } from '@hcengineering/core'
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import { createQuery, getAttributePresenterClass, getClient, LiveQuery } from '@hcengineering/presentation'
|
||||
import { getCurrentLocation, locationToUrl } from '@hcengineering/ui'
|
||||
@ -104,7 +104,7 @@ export function migrateViewOpttions (): void {
|
||||
|
||||
export async function showEmptyGroups (
|
||||
_class: Ref<Class<Doc>>,
|
||||
space: Ref<Space> | undefined,
|
||||
query: DocumentQuery<Doc> | undefined,
|
||||
key: string,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>,
|
||||
@ -128,7 +128,7 @@ export async function showEmptyGroups (
|
||||
const mixin = hierarchy.as(attributeClass, view.mixin.AllValuesFunc)
|
||||
if (mixin.func !== undefined) {
|
||||
const f = await getResource(mixin.func)
|
||||
const res = await f(space, onUpdate, queryId)
|
||||
const res = await f(query, onUpdate, queryId)
|
||||
if (res !== undefined) {
|
||||
return await groupByCategory(client, _class, key, res, mgr, viewletDescriptorId)
|
||||
}
|
||||
|
@ -254,17 +254,15 @@ export interface ClassSortFuncs extends Class<Doc> {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type AllValuesFuncGetter = (
|
||||
space: Ref<Space> | undefined,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>
|
||||
) => Promise<any[] | undefined>
|
||||
export type GetAllValuesFunc = Resource<
|
||||
(query: DocumentQuery<Doc> | undefined, onUpdate: () => void, queryId: Ref<Doc>) => Promise<any[] | undefined>
|
||||
>
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface AllValuesFunc extends Class<Doc> {
|
||||
func: Resource<AllValuesFuncGetter>
|
||||
func: GetAllValuesFunc
|
||||
}
|
||||
|
||||
/**
|
||||
@ -506,7 +504,7 @@ export interface ViewOption {
|
||||
*/
|
||||
export type ViewCategoryActionFunc = (
|
||||
_class: Ref<Class<Doc>>,
|
||||
space: Ref<Space> | undefined,
|
||||
query: DocumentQuery<Doc> | undefined,
|
||||
key: string,
|
||||
onUpdate: () => void,
|
||||
queryId: Ref<Doc>,
|
||||
|
Loading…
Reference in New Issue
Block a user