processes UI (#8349)

This commit is contained in:
Denis Bykhov
2025-03-26 17:13:09 +07:00
committed by GitHub
parent e08b0392fa
commit 0641da8a15
32 changed files with 628 additions and 140 deletions
@@ -286,6 +286,7 @@
if (attr === undefined) return
if (attribute.collectionAttr) return
if (attribute.isLookup) return
if (attribute?.attribute?.readonly === true) return
const key = attribute.castRequest ? attribute.key.substring(attribute.castRequest.length + 1) : attribute.key
return (value: any) => {
onChange(value, doc, key, attr)
@@ -61,24 +61,12 @@
if (attr === undefined) return
if (attribute.collectionAttr) return
if (attribute.isLookup) return
if (attribute?.attribute?.readonly === true) return
return (value: any) => {
onChange(value, docObject, attribute.key, attr)
}
}
function getProps (props: Record<string, any>, readonly: boolean): Record<string, any> {
if (readonly) {
return {
...props,
readonly: true,
disabled: true,
editable: false,
isEditable: false
}
}
return props
}
$: mobile = $deviceInfo.isMobile
$: needCompact =
model.filter((m) => m.displayProps?.optional || m.displayProps?.compression || m.displayProps?.suffix).length > 0
@@ -145,7 +133,7 @@
<ListPresenter
{docObject}
attributeModel={attrModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
{compactMode}
value={getObjectValue(attrModel.key, docObject)}
onChange={getOnChange(docObject, attrModel)}
@@ -159,7 +147,7 @@
<ListPresenter
{docObject}
attributeModel={attrModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
value={getObjectValue(attrModel.key, docObject)}
onChange={getOnChange(docObject, attrModel)}
on:resize={(e) => {
@@ -174,7 +162,7 @@
<ListPresenter
{docObject}
attributeModel={attrModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
value={getObjectValue(attrModel.key, docObject)}
onChange={getOnChange(docObject, attrModel)}
/>
@@ -184,7 +172,7 @@
<ListPresenter
{docObject}
{attributeModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
value={getObjectValue(attributeModel.key, docObject)}
onChange={getOnChange(docObject, attributeModel)}
hideDivider={i === 0}
@@ -213,7 +201,7 @@
<ListPresenter
{docObject}
attributeModel={attrModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
{compactMode}
value={getObjectValue(attrModel.key, docObject)}
onChange={getOnChange(docObject, attrModel)}
@@ -228,7 +216,7 @@
<ListPresenter
{docObject}
{attributeModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
value={getObjectValue(attributeModel.key, docObject)}
onChange={getOnChange(docObject, attributeModel)}
hideDivider={j === 0}
@@ -246,7 +234,7 @@
<ListPresenter
{docObject}
{attributeModel}
props={getProps(props, $restrictionStore.readonly)}
{props}
value={getObjectValue(attributeModel.key, docObject)}
onChange={getOnChange(docObject, attributeModel)}
/>
@@ -16,7 +16,7 @@
import { createEventDispatcher } from 'svelte'
import core, { Doc } from '@hcengineering/core'
import { AttributeModel } from '@hcengineering/view'
import { FixedColumn } from '../..'
import { FixedColumn, restrictionStore } from '../..'
import DividerPresenter from './DividerPresenter.svelte'
export let docObject: Doc
@@ -31,12 +31,21 @@
$: dp = attributeModel?.displayProps
function joinProps (attribute: AttributeModel, object: Doc, props: Record<string, any>) {
function joinProps (attribute: AttributeModel, object: Doc, props: Record<string, any>, readonly: boolean) {
const readonlyParams =
readonly || (attribute?.attribute?.readonly ?? false)
? {
readonly: true,
disabled: true,
editable: false,
isEditable: false
}
: {}
const clearAttributeProps = attribute.props
if (attribute.attribute?.type._class === core.class.EnumOf) {
return { ...clearAttributeProps, type: attribute.attribute.type, ...props }
return { ...clearAttributeProps, type: attribute.attribute.type, ...props, ...readonlyParams }
}
return { object, ...clearAttributeProps, space: object.space, ...props }
return { object, ...clearAttributeProps, space: object.space, ...props, ...readonlyParams }
}
const translateSize = (e: CustomEvent): void => {
if (e.detail === undefined) return
@@ -56,7 +65,7 @@
kind={'list'}
{compactMode}
label={attributeModel.label}
{...joinProps(attributeModel, docObject, props)}
{...joinProps(attributeModel, docObject, props, $restrictionStore.readonly)}
on:resize={translateSize}
/>
</FixedColumn>
@@ -68,7 +77,7 @@
kind={'list'}
label={attributeModel.label}
{compactMode}
{...joinProps(attributeModel, docObject, props)}
{...joinProps(attributeModel, docObject, props, $restrictionStore.readonly)}
on:resize={translateSize}
/>
{/if}