Improve process ui (#9645)

This commit is contained in:
Denis Bykhov
2025-08-06 17:19:12 +07:00
committed by GitHub
parent 2021e27379
commit 29257e9fc8
43 changed files with 738 additions and 1303 deletions
@@ -0,0 +1,83 @@
<!--
// 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 { getAttributePresenterClass, getClient } from '@hcengineering/presentation'
import { parseContext, Process } from '@hcengineering/process'
import { AnyComponent, Component, Label } from '@hcengineering/ui'
import { AttributeCategory } from '@hcengineering/view'
import { findAttributePresenter } from '@hcengineering/view-resources'
import view from '@hcengineering/view-resources/src/plugin'
import { Mode, Modes, parseValue } from '../../query'
import ContextValuePresenter from '../attributeEditors/ContextValuePresenter.svelte'
import { getContext } from '../../utils'
import core from '@hcengineering/core'
export let process: Process
export let key: string
export let value: any
const client = getClient()
const hierarchy = client.getHierarchy()
$: attribute = client.getHierarchy().findAttribute(process.masterTag, key)
$: [val, selectedMode] = parseValue(Object.values(Modes), value)
$: presenterClass = attribute !== undefined ? getAttributePresenterClass(hierarchy, attribute.type) : undefined
function isArraySize (category: AttributeCategory | undefined, selectedMode: Mode): boolean {
return category === 'array' && selectedMode.id.startsWith('size')
}
function getPresenter (key: string): AnyComponent | undefined {
const isArraySizeCriteria = isArraySize(presenterClass?.category, selectedMode)
if (isArraySizeCriteria) {
return view.component.NumberPresenter
}
const res = findAttributePresenter(client, process.masterTag, key)
return res
}
$: presenter = getPresenter(key)
$: contextValue = parseContext(val)
$: context =
presenterClass !== undefined
? isArraySize(presenterClass.category, selectedMode)
? getContext(client, process, core.class.TypeNumber, 'attribute')
: getContext(client, process, presenterClass.attrClass, presenterClass.category)
: undefined
</script>
{#if attribute}
<div class="title">
<Label label={attribute.label} />
</div>
<Label label={selectedMode.label} />
{#if presenter}
{#if contextValue && context}
<ContextValuePresenter {contextValue} {context} {process} />
{:else}
<Component is={presenter} props={{ value: val, readonly: true }} />
{/if}
{/if}
{/if}
<style lang="scss">
.title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--theme-caption-color);
}
</style>
@@ -14,11 +14,12 @@
-->
<script lang="ts">
import { Card } from '@hcengineering/card'
import { IntlString } from '@hcengineering/platform'
import { AnyAttribute } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { MethodParams, Process, Step } from '@hcengineering/process'
import { Icon, IconError, Label, tooltip } from '@hcengineering/ui'
import plugin from '../../plugin'
import UpdateAttributePresenter from './UpdateAttributePresenter.svelte'
export let step: Step<Card>
export let process: Process
@@ -26,36 +27,19 @@
const client = getClient()
$: method = client.getModel().findAllSync(plugin.class.Method, { _id: step.methodId })[0]
$: attributes = getAttributes(params, process)
function getAttributes (params: Record<string, any>, process: Process): IntlString[] {
const res: IntlString[] = []
for (const key in params) {
if (params[key] !== undefined) {
const attr = client.getHierarchy().findAttribute(process.masterTag, key)
if (attr?.label !== undefined) {
res.push(attr.label)
}
}
}
return res
}
</script>
{#if attributes.length === 0}
{#if Object.keys(params).length === 0}
<div class="mr-2" use:tooltip={{ label: plugin.string.NoAttributesForUpdate }}>
<Icon icon={IconError} size="medium" />
</div>
{/if}
<div class="flex-row-center flex-gap-1">
<Label label={method.label} />
{#if attributes.length > 0}
{#if Object.keys(params).length > 0}
:
{#each attributes as attr}
<div class="title">
<Label label={attr} />
</div>
{#each Object.entries(params) as [key, value]}
<UpdateAttributePresenter {process} {key} {value} />
{/each}
{/if}
</div>