mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 14:05:05 +02:00
Fix context class set (#9830)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -42,6 +42,9 @@
|
||||
props = {}
|
||||
params.props = props
|
||||
step.params = params
|
||||
if (step.context != null) {
|
||||
step.context._class = _id
|
||||
}
|
||||
dispatch('change', step)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
{#if step != null}
|
||||
<StepEditor bind:step {process} on:change={change} />
|
||||
<StepEditor {step} {process} on:change={change} />
|
||||
{/if}
|
||||
<div slot="footer" class="flex-row-center flex-gap-2 w-full">
|
||||
<ContextFooter {process} {step} />
|
||||
|
||||
@@ -39,12 +39,16 @@
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
translateCB(cardPlugin.string.Card, {}, undefined, (res) => {
|
||||
setName(res)
|
||||
})
|
||||
|
||||
function setName (name: string): void {
|
||||
if (params.title === undefined || params.title === '') {
|
||||
params.title = res
|
||||
params.title = name
|
||||
;(step.params as any) = params
|
||||
dispatch('change', step)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function change (e: CustomEvent<any>): void {
|
||||
if (e.detail !== undefined) {
|
||||
@@ -106,9 +110,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function typeChange (e: CustomEvent<Ref<Class<MasterTag>>>): void {
|
||||
if (e.detail === undefined || e.detail === _class) return
|
||||
allAttrs = getKeys(e.detail)
|
||||
function typeChange (_id: Ref<Class<MasterTag>>): void {
|
||||
if (_id === undefined) return
|
||||
allAttrs = getKeys(_id)
|
||||
const oldParams = { ...params }
|
||||
params = {}
|
||||
for (const attr of allAttrs) {
|
||||
@@ -117,7 +121,6 @@
|
||||
;(params as any)[key] = oldParams[key]
|
||||
}
|
||||
}
|
||||
_class = e.detail
|
||||
keys = Object.keys(params)
|
||||
params._class = _class
|
||||
step.params = params
|
||||
@@ -126,6 +129,8 @@
|
||||
}
|
||||
dispatch('change', step)
|
||||
}
|
||||
|
||||
$: typeChange(_class)
|
||||
</script>
|
||||
|
||||
<div class="grid">
|
||||
@@ -137,7 +142,15 @@
|
||||
>
|
||||
<Label label={cardPlugin.string.MasterTag} />
|
||||
</span>
|
||||
<TypeSelector value={_class} width={'100%'} on:change={typeChange} />
|
||||
<TypeSelector
|
||||
value={_class}
|
||||
width={'100%'}
|
||||
on:change={(e) => {
|
||||
if (e.detail !== undefined) {
|
||||
_class = e.detail
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="divider" />
|
||||
{#key _class}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
let _id: Ref<Process> = step.params._id as any
|
||||
$: context = parseContext(step.params.card)
|
||||
$: masterTag = getContextMasterTag(client, context, process.masterTag) ?? process.masterTag
|
||||
$: masterTag = getContextMasterTag(client, context, process) ?? process.masterTag
|
||||
|
||||
$: executionContext = (step.params.context ?? {}) as ExecutionContext
|
||||
|
||||
@@ -48,9 +48,7 @@
|
||||
|
||||
let thisCard: boolean = step.params.card === undefined
|
||||
|
||||
$: ancestors = hierarchy
|
||||
.getAncestors(masterTag)
|
||||
.filter((it) => !hierarchy.isMixin(it) && hierarchy.isDerived(it, card.class.Card))
|
||||
$: ancestors = hierarchy.getAncestors(masterTag).filter((it) => hierarchy.isDerived(it, card.class.Card))
|
||||
|
||||
let processes: Process[] = []
|
||||
let items: DropdownTextItem[] = []
|
||||
|
||||
@@ -75,19 +75,19 @@ export function generateContextId (): ContextId {
|
||||
export function getContextMasterTag (
|
||||
client: Client,
|
||||
context: SelectedContext | undefined,
|
||||
masterTag: Ref<MasterTag>
|
||||
process: Process
|
||||
): Ref<MasterTag> | undefined {
|
||||
if (context === undefined) return
|
||||
const h = client.getHierarchy()
|
||||
const model = client.getModel()
|
||||
if (context.type === 'attribute') {
|
||||
const attr = h.findAttribute(masterTag, context.key)
|
||||
const attr = h.findAttribute(process.masterTag, context.key)
|
||||
if (attr === undefined) return
|
||||
const parentType = attr.type._class === core.class.ArrOf ? (attr.type as ArrOf<Doc>).of : attr.type
|
||||
if (parentType._class === core.class.RefTo) return (parentType as RefTo<Doc>).to
|
||||
}
|
||||
if (context.type === 'nested') {
|
||||
const attr = h.findAttribute(masterTag, context.path)
|
||||
const attr = h.findAttribute(process.masterTag, context.path)
|
||||
if (attr === undefined) return
|
||||
const parentType = attr.type._class === core.class.ArrOf ? (attr.type as ArrOf<Doc>).of : attr.type
|
||||
const targetClass = parentType._class === core.class.RefTo ? (parentType as RefTo<Doc>).to : parentType._class
|
||||
@@ -102,6 +102,11 @@ export function getContextMasterTag (
|
||||
const nested = h.findAttribute(targetClass, context.key)
|
||||
return (nested?.type as RefTo<Doc>)?.to
|
||||
}
|
||||
if (context.type === 'context') {
|
||||
const execContext = process.context[context.id]
|
||||
if (execContext === undefined) return
|
||||
return execContext._class
|
||||
}
|
||||
}
|
||||
|
||||
export async function pickTransition (
|
||||
|
||||
Reference in New Issue
Block a user