Add min and max transformation functions (#10782)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-04-19 02:29:55 +05:00
committed by GitHub
parent db97de7c63
commit b9657d53d1
25 changed files with 155 additions and 13 deletions
@@ -14,12 +14,19 @@
-->
<script lang="ts">
import { Label } from '@hcengineering/ui'
import { Context, SelectedAttribute } from '@hcengineering/process'
import { Context, Process, SelectedAttribute } from '@hcengineering/process'
import { getClient } from '@hcengineering/presentation'
export let process: Process
export let contextValue: SelectedAttribute
export let context: Context
$: attr = context.attributes.find((p) => p.name === contextValue.key)
const client = getClient()
const hierarchy = client.getHierarchy()
$: attr =
context.attributes.find((p) => p.name === contextValue.key) ??
hierarchy.findAttribute(process.masterTag, contextValue.key)
</script>
{#if attr}
@@ -32,7 +32,7 @@
<div class="container flex-row-center">
<div class="internal">
{#if contextValue.type === 'attribute'}
<AttrContextPresenter {contextValue} {context} />
<AttrContextPresenter {contextValue} {context} {process} />
{:else if contextValue.type === 'relation'}
<RelContextPresenter {contextValue} {context} />
{:else if contextValue.type === 'nested'}
@@ -13,6 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Doc, getObjectValue } from '@hcengineering/core'
import presentation, { Card, getAttrEditor, getClient } from '@hcengineering/presentation'
import { ContextId, ExecutionContext, UserResult } from '@hcengineering/process'
import { Component, tooltip } from '@hcengineering/ui'
@@ -21,6 +22,7 @@
export let results: UserResult[]
export let context: ExecutionContext
export let doc: Doc
const dispatch = createEventDispatcher()
const client = getClient()
@@ -28,10 +30,21 @@
let values: Record<ContextId, any> = {}
results.forEach((r) => {
values[r._id] = context[r._id]
function fillValues (): void {
results.forEach((r) => {
values[r._id] = getVal(r)
})
values = values
})
}
function getVal (res: UserResult): any {
if (res.key !== undefined) {
return getObjectValue(res.key, doc) ?? context[res._id]
}
return context[res._id]
}
fillValues()
export function canClose (): boolean {
return false
@@ -14,6 +14,8 @@
-->
<script lang="ts">
import core, { Type } from '@hcengineering/core'
import { translate } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { Process, UserResult } from '@hcengineering/process'
import { Button, EditBox, IconClose, Label } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
@@ -29,7 +31,9 @@
const dispatch = createEventDispatcher()
function update (): void {
const client = getClient()
async function update (): Promise<void> {
if (type == null) {
result = null
} else {
@@ -39,6 +43,13 @@
key,
type
}
if (key !== undefined) {
const attr = client.getHierarchy().findAttribute(process.masterTag, key)
if (attr?.label !== undefined) {
name = await translate(attr.label, {})
result.name = name
}
}
}
dispatch('change', result)
}
@@ -28,7 +28,9 @@
[plugin.function.Divide]: '/',
[plugin.function.Modulo]: '%',
[plugin.function.Power]: '^',
[plugin.function.Sqrt]: '√'
[plugin.function.Sqrt]: '√',
[plugin.function.Min]: 'min',
[plugin.function.Max]: 'max'
}
$: op = ops[value.func as keyof typeof ops]