Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { MasterTag, Tag } from '@hcengineering/card'
import { AnyAttribute, Class, Doc, Ref } from '@hcengineering/core'
import { Context, createDSLContext, parseContext, Process, SelectedContext } from '@hcengineering/process'
import { Context, createContext, parseContext, Process, SelectedContext } from '@hcengineering/process'
import {
AnySvelteComponent,
Button,
Expand Down Expand Up @@ -72,11 +72,7 @@
if (res === null) {
value = undefined
} else {
try {
value = createDSLContext(res)
} catch {
value = '$' + JSON.stringify(res)
}
value = createContext(res)
}
dispatch('change', value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { getClient } from '@hcengineering/presentation'
import {
ContextId,
createContext,
MethodParams,
parseContext,
Process,
Expand Down Expand Up @@ -115,15 +116,13 @@
eventToHTMLElement(ev),
(result) => {
if (result !== undefined) {
dispatch(
'change',
'$' +
JSON.stringify({
type: 'context',
id: result as ContextId,
key: ''
})
)
const ctx: SelectedExecutionContext = {
type: 'context',
id: result as ContextId,
key: ''
}
const res = createContext(ctx)
dispatch('change', res)
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script lang="ts">
import core, { AnyAttribute } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { parseContext, Process, SelectedContext } from '@hcengineering/process'
import { createContext, parseContext, Process, SelectedContext } from '@hcengineering/process'
import { Button, Component, eventToHTMLElement, IconAdd, IconClose, showPopup } from '@hcengineering/ui'
import view from '@hcengineering/view-resources/src/plugin'
import { createEventDispatcher } from 'svelte'
Expand Down Expand Up @@ -51,7 +51,7 @@
}

function onSelect (res: SelectedContext | null): void {
val = res === null ? undefined : '$' + JSON.stringify(res)
val = res === null ? undefined : createContext(res)
dispatch('change', val)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script lang="ts">
import { AnyAttribute } from '@hcengineering/core'
import { findAttributeEditor, getAttributePresenterClass, getClient } from '@hcengineering/presentation'
import { Context, parseContext, Process, SelectedContext } from '@hcengineering/process'
import { Context, createContext, parseContext, Process, SelectedContext } from '@hcengineering/process'
import { Button, Component, eventToHTMLElement, IconAdd, IconClose, showPopup } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import ContextSelectorPopup from '../attributeEditors/ContextSelectorPopup.svelte'
Expand Down Expand Up @@ -47,7 +47,7 @@
}

function onSelect (res: SelectedContext | null): void {
val = res === null ? undefined : '$' + JSON.stringify(res)
val = res === null ? undefined : createContext(res)
dispatch('change', val)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script lang="ts">
import { AnyAttribute } from '@hcengineering/core'
import { findAttributeEditor, getAttributePresenterClass, getClient } from '@hcengineering/presentation'
import { Context, parseContext, Process, SelectedContext } from '@hcengineering/process'
import { Context, createContext, parseContext, Process, SelectedContext } from '@hcengineering/process'
import { Button, Component, eventToHTMLElement, IconAdd, IconClose, showPopup } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import ContextSelectorPopup from '../attributeEditors/ContextSelectorPopup.svelte'
Expand Down Expand Up @@ -52,7 +52,7 @@
}

function onSelect (res: SelectedContext | null, index: number): void {
val[index] = res === null ? undefined : '$' + JSON.stringify(res)
val[index] = res === null ? undefined : createContext(res)
dispatch('change', val)
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/process-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { getClient } from '@hcengineering/presentation'
import {
type Context,
type ContextId,
createContext,
type Execution,
type ExecutionContext,
ExecutionStatus,
Expand Down Expand Up @@ -564,7 +565,7 @@ export function getToDoEndAction (prevState: State): Step<Doc> {
params: {
state: prevState._id,
title: prevState.title,
user: '$' + JSON.stringify(context)
user: createContext(context)
}
}
return endAction
Expand Down
8 changes: 8 additions & 0 deletions plugins/process/src/dslContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import {
SelectedUserRequest
} from './types'

export function createContext (context: SelectedContext): string {
try {
return createDSLContext(context)
} catch {
return '$' + JSON.stringify(context)
}
}

export function createDSLContext (context: SelectedContext): string {
let expression = ''
switch (context.type) {
Expand Down
Loading