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