mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-30 05:25:00 +02:00
processes UI (#8349)
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user