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
12 changes: 8 additions & 4 deletions packages/ui/src/components/EditBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@
if (minValue !== undefined && maxValue !== undefined && maxValue < minValue) return
if (minValue !== undefined && val < minValue) value = minValue
if (maxValue !== undefined && val > maxValue) value = maxValue
dispatch('change')
dispatch('value', value)
}

$: setValue(value, maxValue, minValue)

$: translateCB(placeholder, placeholderParam ?? {}, $themeStore.language, (res) => {
phTranslate = res
})
Expand Down Expand Up @@ -196,11 +194,17 @@
type="number"
bind:value
placeholder={phTranslate}
min={minValue}
max={maxValue}
on:input={handleInput}
on:change
on:change={() => {
setValue(value, maxValue, minValue)
dispatch('change', value)
}}
on:keydown
on:keypress
on:blur={() => {
setValue(value, maxValue, minValue)
dispatch('blur', value)
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
{#if contextValue}
<ContextValue
{process}
{masterTag}
{contextValue}
{context}
{attribute}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
// Copyright © 2025 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { getClient } from '@hcengineering/presentation'
import type { Process, SelectedConst } from '@hcengineering/process'
import { AnyComponent, Component } from '@hcengineering/ui'
import { findAttributePresenter } from '@hcengineering/view-resources'
import { readonly } from 'svelte/store'

export let contextValue: SelectedConst
export let process: Process

const client = getClient()
let presenter: AnyComponent | undefined = undefined
$: presenter = findAttributePresenter(client, process.masterTag, contextValue.key)
</script>

{#if presenter !== undefined}
<Component is={presenter} props={{ value: contextValue.value, readonly }} disabled />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!--
// Copyright © 2025 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { AnyAttribute } from '@hcengineering/core'
import { Card, findAttributeEditor, getClient } from '@hcengineering/presentation'
import { Component } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'

export let attribute: AnyAttribute

const client = getClient()
$: editor = findAttributeEditor(client, attribute.attributeOf, attribute.name)

const dispatch = createEventDispatcher()

function save (): void {
dispatch('close', value)
}

function onChange (val: any): void {
value = val
}

let value: any | undefined = undefined
</script>

<Card width={'menu'} label={attribute.label} canSave={value != null} on:close okAction={save}>
{value}
{#if editor != null}
<Component
is={editor}
props={{
attribute,
showNavigate: false,
onChange,
label: attribute.label,
placeholder: attribute?.label,
kind: 'ghost',
size: 'large',
width: '100%',
justify: 'left',
type: attribute?.type
}}
/>
{/if}
</Card>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
RelatedContext,
SelectedContext
} from '@hcengineering/process'
import { Label, resizeObserver, Scroller, Submenu } from '@hcengineering/ui'
import { eventToHTMLElement, Label, resizeObserver, Scroller, showPopup, Submenu } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import plugin from '../../plugin'
import { generateContextId, getRelationObjectReduceFunc, getValueReduceFunc } from '../../utils'
import ExecutionContextPresenter from './ExecutionContextPresenter.svelte'
import ConstValuePopup from './ConstValuePopup.svelte'

export let process: Process
export let masterTag: Ref<MasterTag | Tag>
Expand All @@ -44,11 +45,6 @@
dispatch('close')
}

function onCustom (): void {
onSelect(null)
dispatch('close')
}

function onAttribute (val: AnyAttribute): void {
const valueFunc = getValueReduceFunc(val, attribute)
onClick({
Expand Down Expand Up @@ -108,6 +104,19 @@
})
dispatch('close')
}

function onConst (e: MouseEvent): void {
showPopup(ConstValuePopup, { attribute }, eventToHTMLElement(e), (res) => {
if (res != null) {
onSelect({
type: 'const',
key: attribute.name,
value: res
})
}
dispatch('close')
})
}
</script>

<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
Expand Down Expand Up @@ -241,13 +250,7 @@
<div class="menu-separator" />
{/if}
{#if !forbidValue}
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
<button
on:click={() => {
onCustom()
}}
class="menu-item"
>
<button on:click={onConst} class="menu-item">
<span class="overflow-label pr-1">
<Label label={plugin.string.CustomValue} />
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.
-->
<script lang="ts">
import { MasterTag, Tag } from '@hcengineering/card'
import { AnyAttribute, Class, Doc, Ref } from '@hcengineering/core'
import { Context, Process, SelectedContext } from '@hcengineering/process'
import { Button, eventToHTMLElement, showPopup } from '@hcengineering/ui'
Expand All @@ -23,7 +22,6 @@
import ContextValuePresenter from './ContextValuePresenter.svelte'

export let process: Process
export let masterTag: Ref<MasterTag | Tag>
export let contextValue: SelectedContext
export let context: Context
export let attribute: AnyAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import RelContextPresenter from './RelContextPresenter.svelte'
import FunctionContextPresenter from './FunctionContextPresenter.svelte'
import ExecutionContextPresenter from './ExecutionContextPresenter.svelte'
import ConstContextPresenter from './ConstContextPresenter.svelte'
import FunctionPresenter from './FunctionPresenter.svelte'

export let process: Process
Expand All @@ -42,6 +43,8 @@
<FunctionContextPresenter {contextValue} {context} {process} />
{:else if contextValue.type === 'context'}
<ExecutionContextPresenter {contextValue} {process} />
{:else if contextValue.type === 'const'}
<ConstContextPresenter {contextValue} {process} />
{/if}
</div>
{#if contextValue.sourceFunction}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
{#if contextValue}
<ContextValue
{process}
masterTag={process.masterTag}
{contextValue}
{context}
{attribute}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
{#if contextValue}
<ContextValue
{process}
masterTag={process.masterTag}
{contextValue}
{context}
{attribute}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
{#if firstContextValue}
<ContextValue
{process}
masterTag={process.masterTag}
contextValue={firstContextValue}
{context}
{attribute}
Expand Down Expand Up @@ -136,7 +135,6 @@
{#if secondContextValue}
<ContextValue
{process}
masterTag={process.masterTag}
contextValue={secondContextValue}
{context}
{attribute}
Expand Down
8 changes: 7 additions & 1 deletion plugins/process/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface Func {
}

interface BaseSelectedContext {
type: 'attribute' | 'relation' | 'nested' | 'userRequest' | 'function' | 'context'
type: 'attribute' | 'relation' | 'nested' | 'userRequest' | 'function' | 'context' | 'const'
// attribute key
key: string

Expand All @@ -47,6 +47,11 @@ interface BaseSelectedContext {
fallbackValue?: any
}

export interface SelectedConst extends BaseSelectedContext {
type: 'const'
value: any
}

export interface SelectedAttribute extends BaseSelectedContext {
type: 'attribute'
}
Expand Down Expand Up @@ -87,3 +92,4 @@ export type SelectedContext =
| SelectedUserRequest
| SelectedContextFunc
| SelectedExecutionContext
| SelectedConst
7 changes: 7 additions & 0 deletions server-plugins/process-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import process, {
parseContext,
ProcessError,
processError,
SelectedConst,
SelectedContext,
SelectedContextFunc,
SelectedExecutionContext,
Expand All @@ -47,6 +48,8 @@ export async function getContextValue (value: any, control: ProcessControl, exec
value = await getFunctionValue(control, execution, context)
} else if (context.type === 'context') {
value = await getExecutionContextValue(control, execution, context)
} else if (context.type === 'const') {
value = getConstValue(control, execution, context)
}
return await fillValue(value, context, control, execution)
} catch (err: any) {
Expand All @@ -73,6 +76,10 @@ function getValue (control: ProcessControl, execution: Execution, rawKey: string
return getObjectValue(key, card)
}

function getConstValue (control: ProcessControl, execution: Execution, context: SelectedConst): any {
return context.value
}

function getAttributeValue (control: ProcessControl, execution: Execution, context: SelectedContext): any {
const card = control.cache.get(execution.card)
if (card !== undefined) {
Expand Down