mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-28 12:35:02 +02:00
Allow to use realted object as value in processes (#9439)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
+48
-12
@@ -16,11 +16,19 @@
|
||||
import { MasterTag, Tag } from '@hcengineering/card'
|
||||
import { AnyAttribute, Ref } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { Context, ContextId, Process, ProcessContext, ProcessFunction, SelectedContext } from '@hcengineering/process'
|
||||
import {
|
||||
Context,
|
||||
ContextId,
|
||||
Process,
|
||||
ProcessContext,
|
||||
ProcessFunction,
|
||||
RelatedContext,
|
||||
SelectedContext
|
||||
} from '@hcengineering/process'
|
||||
import { Label, resizeObserver, Scroller, Submenu } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import plugin from '../../plugin'
|
||||
import { generateContextId, getValueReduceFunc, isTypeEqual } from '../../utils'
|
||||
import { generateContextId, getRelationObjectReduceFunc, getValueReduceFunc, isTypeEqual } from '../../utils'
|
||||
import ExecutionContextPresenter from './ExecutionContextPresenter.svelte'
|
||||
|
||||
export let process: Process
|
||||
@@ -96,6 +104,21 @@
|
||||
const f = client.getModel().getObject(func)
|
||||
return f
|
||||
}
|
||||
|
||||
function onRelation (val: RelatedContext): void {
|
||||
const client = getClient()
|
||||
const reduceFunc = getRelationObjectReduceFunc(client, val.association, val.direction, attribute)
|
||||
onSelect({
|
||||
type: 'relation',
|
||||
key: '',
|
||||
association: val.association,
|
||||
direction: val.direction,
|
||||
name: val.name,
|
||||
functions: [],
|
||||
sourceFunction: reduceFunc
|
||||
})
|
||||
dispatch('close')
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
|
||||
@@ -187,16 +210,29 @@
|
||||
{/if}
|
||||
{#if relations.length > 0}
|
||||
{#each relations as object}
|
||||
<Submenu
|
||||
text={object[0]}
|
||||
props={{
|
||||
context: object[1],
|
||||
onSelect: onClick,
|
||||
target: attribute
|
||||
}}
|
||||
options={{ component: plugin.component.RelatedContextSelector }}
|
||||
withHover
|
||||
/>
|
||||
{#if object[1].attributes.length === 0}
|
||||
<button
|
||||
on:click={() => {
|
||||
onRelation(object[1])
|
||||
}}
|
||||
class="menu-item"
|
||||
>
|
||||
<span class="overflow-label pr-1">
|
||||
{object[1].name}
|
||||
</span>
|
||||
</button>
|
||||
{:else}
|
||||
<Submenu
|
||||
text={object[1].name}
|
||||
props={{
|
||||
context: object[1],
|
||||
onSelect: onClick,
|
||||
target: attribute
|
||||
}}
|
||||
options={{ component: plugin.component.RelatedContextSelector }}
|
||||
withHover
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
<div class="menu-separator" />
|
||||
{/if}
|
||||
|
||||
+4
-2
@@ -20,9 +20,11 @@
|
||||
export let context: Context
|
||||
|
||||
$: relation = context.relations[contextValue.name]
|
||||
$: attr = relation?.attributes?.find((p) => p.name === contextValue.key)
|
||||
$: attr = contextValue.key !== '' && relation?.attributes?.find((p) => p.name === contextValue.key)
|
||||
</script>
|
||||
|
||||
{#if relation !== undefined && attr}
|
||||
{#if contextValue.key === ''}
|
||||
{relation.name}
|
||||
{:else if relation !== undefined && attr}
|
||||
{relation.name} > <Label label={attr.label} />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user