forked from ukrbublik/react-awesome-query-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuleGroup.jsx
More file actions
96 lines (82 loc) · 2.34 KB
/
Copy pathRuleGroup.jsx
File metadata and controls
96 lines (82 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React from "react";
import PropTypes from "prop-types";
import GroupContainer from "../containers/GroupContainer";
import Draggable from "../containers/Draggable";
import {BasicGroup} from "./Group";
import {RuleGroupActions} from "./RuleGroupActions";
import FieldWrapper from "../rule/FieldWrapper";
import {useOnPropsChanged} from "../../utils/reactUtils";
import {WithConfirmFn} from "../utils";
class RuleGroup extends BasicGroup {
static propTypes = {
...BasicGroup.propTypes,
selectedField: PropTypes.string,
parentField: PropTypes.string,
setField: PropTypes.func,
};
constructor(props) {
super(props);
useOnPropsChanged(this);
this.onPropsChanged(props);
}
onPropsChanged(nextProps) {
}
childrenClassName = () => "rule_group--children";
renderHeaderWrapper = () => null;
renderFooterWrapper = () => null;
renderConjs = () => null;
canAddGroup = () => false;
canAddRule = () => true;
canDeleteGroup = () => false;
reordableNodesCntForItem(_item) {
if (this.props.isLocked)
return 0;
const {children1} = this.props;
return children1?.size || 0;
}
renderChildrenWrapper() {
return (
<>
{this.renderDrag()}
{this.renderField()}
{this.renderActions()}
{super.renderChildrenWrapper()}
</>
);
}
renderField() {
const { config, selectedField, setField, parentField, id, groupId, isLocked } = this.props;
const { immutableFieldsMode } = config.settings;
return <FieldWrapper
key="field"
classname={"group--field"}
config={config}
selectedField={selectedField}
setField={setField}
parentField={parentField}
readonly={immutableFieldsMode || isLocked}
id={id}
groupId={groupId}
/>;
}
renderActions() {
const {config, addRule, isLocked, isTrueLocked, id} = this.props;
return <RuleGroupActions
config={config}
addRule={addRule}
canAddRule={this.canAddRule()}
canDeleteGroup={this.canDeleteGroup()}
removeSelf={this.removeSelf}
setLock={this.setLock}
isLocked={isLocked}
isTrueLocked={isTrueLocked}
id={id}
/>;
}
extraPropsForItem(_item) {
return {
parentField: this.props.selectedField
};
}
}
export default GroupContainer(Draggable("group rule_group")(WithConfirmFn(RuleGroup)));