Skip to content

Commit 8fc2555

Browse files
authored
为 ConditionBuilder 增加节点级的禁用(disabled)能力 (baidu#16489)
1 parent 12d7b18 commit 8fc2555

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

packages/amis-core/src/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ export interface AMISConditionRule {
236236
op?: AMISOperatorType;
237237
right?: AMISExpressionComplex | Array<AMISExpressionComplex>;
238238
if?: string;
239+
disabled?: boolean;
239240
}
240241

241242
export interface AMISConditionGroupValue {
@@ -244,6 +245,7 @@ export interface AMISConditionGroupValue {
244245
not?: boolean;
245246
children?: Array<AMISConditionRule | AMISConditionGroupValue>;
246247
if?: string;
248+
disabled?: boolean;
247249
}
248250

249251
export interface AMISConditionValue extends AMISConditionGroupValue {}

packages/amis-ui/src/components/condition-builder/Group.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ export class ConditionGroup extends React.Component<
193193
onDragStart,
194194
showNot,
195195
showANDOR = false,
196-
disabled,
197196
searchable,
198197
translate: __,
199198
formula,
@@ -209,6 +208,7 @@ export class ConditionGroup extends React.Component<
209208
testIdBuilder
210209
} = this.props;
211210
const {isCollapsed} = this.state;
211+
const disabled = value?.disabled ?? this.props.disabled;
212212

213213
const body =
214214
Array.isArray(value?.children) && value!.children.length
@@ -294,7 +294,7 @@ export class ConditionGroup extends React.Component<
294294
funcs={funcs}
295295
onRemove={this.handleItemRemove}
296296
data={data}
297-
disabled={disabled}
297+
disabled={item.disabled ?? disabled}
298298
searchable={searchable}
299299
builderMode={builderMode}
300300
formula={formula}

packages/amis-ui/src/components/condition-builder/GroupOrItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ export class CBGroupOrItem extends React.Component<CBGroupOrItemProps> {
9898
funcs,
9999
draggable,
100100
data,
101-
disabled,
102101
searchable,
103102
onDragStart,
104103
formula,
@@ -115,6 +114,8 @@ export class CBGroupOrItem extends React.Component<CBGroupOrItemProps> {
115114
mobileUI
116115
} = this.props;
117116

117+
const disabled = value?.disabled ?? this.props.disabled;
118+
118119
return (
119120
<div
120121
className={cx(

packages/amis-ui/src/components/condition-builder/Value.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface ValueProps extends ThemeProps, LocaleProps {
3434
export class Value extends React.Component<ValueProps> {
3535
@autobind
3636
renderCustomValue(props: any) {
37-
const {renderEtrValue, data, classnames: cx} = this.props;
37+
const {renderEtrValue, data, classnames: cx, disabled} = this.props;
3838
const field = props.inputSettings;
3939

4040
return renderEtrValue
@@ -43,6 +43,7 @@ export class Value extends React.Component<ValueProps> {
4343

4444
{
4545
data,
46+
disabled,
4647
onChange: props.onChange,
4748
value: props.value,
4849
inputClassName: cx(field.className, props.className)

packages/amis-ui/src/components/condition-builder/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ export class QueryBuilder extends React.Component<
265265
showNot,
266266
showANDOR,
267267
data,
268-
disabled,
269268
draggable = true,
270269
searchable,
271270
builderMode,
@@ -280,6 +279,8 @@ export class QueryBuilder extends React.Component<
280279
testIdBuilder
281280
} = this.props;
282281

282+
const disabled = value?.disabled ?? this.props.disabled;
283+
283284
const normalizedValue = Array.isArray(value?.children)
284285
? {
285286
...value,
@@ -359,12 +360,13 @@ export class QueryBuilder extends React.Component<
359360
onChange: onFinalChange,
360361
value,
361362
title,
362-
disabled,
363363
popOverContainer,
364364
testIdBuilder,
365365
mobileUI
366366
} = this.props;
367367

368+
const disabled = value?.disabled ?? this.props.disabled;
369+
368370
if (embed) {
369371
return this.renderBody(onFinalChange, value, popOverContainer);
370372
}

0 commit comments

Comments
 (0)