mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
UBERF-4815 (#4299)
* UBERF-4815 Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix formatting Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> --------- Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b43231b78e
commit
e43783da94
@ -32,11 +32,13 @@ export class ConfigurationManager {
|
||||
return this.configuration.get(plugin)?.enabled !== false
|
||||
}
|
||||
|
||||
hasResource<T>(resource?: Resource<T> | null): boolean {
|
||||
hasResource<T>(resource?: Resource<T> | null): boolean | undefined {
|
||||
if (resource == null) {
|
||||
return false
|
||||
}
|
||||
return this.has(getResourcePlugin(resource))
|
||||
try {
|
||||
return this.has(getResourcePlugin(resource))
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
// Issue status live query
|
||||
@ -51,7 +53,7 @@ let workspaceId: string = ''
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function hasResource<T> (resource?: Resource<T>): boolean {
|
||||
export function hasResource<T> (resource?: Resource<T>): boolean | undefined {
|
||||
return configuration.hasResource(resource)
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Ref, generateId } from '@hcengineering/core'
|
||||
import { Card, getClient } from '@hcengineering/presentation'
|
||||
import { Card, getClient, hasResource } from '@hcengineering/presentation'
|
||||
import { ProjectTypeDescriptor, createProjectType } from '@hcengineering/task'
|
||||
import { DropdownLabelsIntl, EditBox, ToggleWithLabel } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import task from '../../plugin'
|
||||
import { Resource } from '@hcengineering/platform'
|
||||
|
||||
const client = getClient()
|
||||
|
||||
@ -49,7 +50,10 @@
|
||||
dispatch('close')
|
||||
}
|
||||
|
||||
const descriptors = client.getModel().findAllSync(task.class.ProjectTypeDescriptor, {})
|
||||
const descriptors = client
|
||||
.getModel()
|
||||
.findAllSync(task.class.ProjectTypeDescriptor, {})
|
||||
.filter((p) => hasResource(p._id as any as Resource<any>))
|
||||
const items = descriptors.map((it) => ({
|
||||
label: it.name,
|
||||
id: it._id
|
||||
|
@ -18,9 +18,10 @@
|
||||
import task, { ProjectType } from '@hcengineering/task'
|
||||
import { Location, getCurrentResolvedLocation, navigate, resolvedLocationStore } from '@hcengineering/ui'
|
||||
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { createQuery, hasResource } from '@hcengineering/presentation'
|
||||
import { onDestroy } from 'svelte'
|
||||
import Types from './Types.svelte'
|
||||
import { Resource } from '@hcengineering/platform'
|
||||
|
||||
export let kind: 'navigation' | 'tools' | undefined
|
||||
export let categoryName: string
|
||||
@ -50,7 +51,7 @@
|
||||
task.class.ProjectType,
|
||||
{ archived: false },
|
||||
(result) => {
|
||||
types = result
|
||||
types = result.filter((p) => hasResource(p.descriptor as any as Resource<any>))
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
|
@ -14,8 +14,8 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import core, { Class, ClassifierKind, Data, Ref, RefTo, Status, generateId, toIdMap } from '@hcengineering/core'
|
||||
import { getEmbeddedLabel } from '@hcengineering/platform'
|
||||
import presentation, { Card, getClient } from '@hcengineering/presentation'
|
||||
import { Resource, getEmbeddedLabel } from '@hcengineering/platform'
|
||||
import presentation, { Card, getClient, hasResource } from '@hcengineering/presentation'
|
||||
import {
|
||||
ProjectType,
|
||||
ProjectTypeDescriptor,
|
||||
@ -57,7 +57,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
const taskTypeDescriptors = client.getModel().findAllSync(task.class.TaskTypeDescriptor, { allowCreate: true })
|
||||
const taskTypeDescriptors = client
|
||||
.getModel()
|
||||
.findAllSync(task.class.TaskTypeDescriptor, { allowCreate: true })
|
||||
.filter((p) => hasResource(p._id as any as Resource<any>))
|
||||
|
||||
let { kind, name, targetClass, statusCategories, statuses, allowedAsChildOf } =
|
||||
taskType !== undefined ? { ...taskType } : { ...defaultTaskType(type) }
|
||||
|
@ -219,8 +219,10 @@
|
||||
}
|
||||
|
||||
async function getHeaderEditor (_class: Ref<Class<Doc>>): Promise<AnyComponent | undefined> {
|
||||
const editorMixin = hierarchy.classHierarchyMixin(_class, view.mixin.ObjectEditorHeader, (m) =>
|
||||
hasResource(m.editor)
|
||||
const editorMixin = hierarchy.classHierarchyMixin(
|
||||
_class,
|
||||
view.mixin.ObjectEditorHeader,
|
||||
(m) => hasResource(m.editor) ?? false
|
||||
)
|
||||
return editorMixin?.editor
|
||||
}
|
||||
|
@ -176,7 +176,11 @@
|
||||
: category === 'collection'
|
||||
? view.mixin.CollectionPresenter
|
||||
: view.mixin.AttributePresenter
|
||||
const presenter = hierarchy.classHierarchyMixin(attrClass, mixin, (m) => hasResource(m.presenter))?.presenter
|
||||
const presenter = hierarchy.classHierarchyMixin(
|
||||
attrClass,
|
||||
mixin,
|
||||
(m) => hasResource(m.presenter) ?? false
|
||||
)?.presenter
|
||||
if (presenter === undefined) return
|
||||
const clazz = hierarchy.getClass(attribute.attributeOf)
|
||||
const extraProps = viewlet.configOptions?.extraProps
|
||||
|
@ -103,7 +103,11 @@ export async function getObjectPresenter (
|
||||
const mixin = isCollectionAttr ? view.mixin.CollectionPresenter : view.mixin.ObjectPresenter
|
||||
const clazz = hierarchy.getClass(_class)
|
||||
|
||||
const presenterMixin = hierarchy.classHierarchyMixin(_class, mixin, (m) => !checkResource || hasResource(m.presenter))
|
||||
const presenterMixin = hierarchy.classHierarchyMixin(
|
||||
_class,
|
||||
mixin,
|
||||
(m) => !checkResource || hasResource(m.presenter) === true
|
||||
)
|
||||
if (presenterMixin?.presenter === undefined) {
|
||||
console.error(
|
||||
`object presenter not found for class=${_class}, mixin=${mixin}, preserve key ${JSON.stringify(preserveKey)}`
|
||||
@ -895,8 +899,10 @@ export async function getObjectLinkFragment (
|
||||
props: Record<string, any> = {},
|
||||
component: AnyComponent = view.component.EditDoc
|
||||
): Promise<Location> {
|
||||
const provider = hierarchy.classHierarchyMixin(Hierarchy.mixinOrClass(object), view.mixin.LinkProvider, (m) =>
|
||||
hasResource(m.encode)
|
||||
const provider = hierarchy.classHierarchyMixin(
|
||||
Hierarchy.mixinOrClass(object),
|
||||
view.mixin.LinkProvider,
|
||||
(m) => hasResource(m.encode) ?? false
|
||||
)
|
||||
if (provider?.encode !== undefined) {
|
||||
const f = await getResource(provider.encode)
|
||||
@ -906,7 +912,7 @@ export async function getObjectLinkFragment (
|
||||
}
|
||||
}
|
||||
const loc = getCurrentResolvedLocation()
|
||||
if (hasResource(component)) {
|
||||
if (hasResource(component) === true) {
|
||||
loc.fragment = getPanelURI(component, object._id, Hierarchy.mixinOrClass(object), 'content')
|
||||
}
|
||||
return loc
|
||||
|
Loading…
Reference in New Issue
Block a user