forked from ukrbublik/react-awesome-query-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitchGroupActions.jsx
More file actions
52 lines (45 loc) · 1.86 KB
/
Copy pathSwitchGroupActions.jsx
File metadata and controls
52 lines (45 loc) · 1.86 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
import React, { PureComponent } from "react";
const groupActionsPositionList = {
topLeft: "group--actions--tl",
topCenter: "group--actions--tc",
topRight: "group--actions--tr",
bottomLeft: "group--actions--bl",
bottomCenter: "group--actions--bc",
bottomRight: "group--actions--br"
};
const defaultPosition = "topRight";
export class SwitchGroupActions extends PureComponent {
render() {
const {
config,
addCaseGroup, addDefaultCaseGroup, setLock, isLocked, isTrueLocked, id, canAddGroup, canAddDefault
} = this.props;
const {
immutableGroupsMode, addCaseLabel, addDefaultCaseLabel, groupActionsPosition,
renderButton, renderSwitch, renderButtonGroup,
lockLabel, lockedLabel, showLock,
} = config.settings;
const Btn = (pr) => renderButton(pr, config.ctx);
const Switch = (pr) => renderSwitch(pr, config.ctx);
const BtnGrp = (pr) => renderButtonGroup(pr, config.ctx);
const position = groupActionsPositionList[groupActionsPosition || defaultPosition];
const setLockSwitch = showLock && !(isLocked && !isTrueLocked) && <Switch
type="lock" id={id} value={isLocked} setValue={setLock} label={lockLabel} checkedLabel={lockedLabel} config={config}
/>;
const addCaseGroupBtn = !immutableGroupsMode && canAddGroup && !isLocked && <Btn
type="addCaseGroup" onClick={addCaseGroup} label={addCaseLabel} readonly={isLocked} config={config}
/>;
const addDefaultCaseGroupBtn = !immutableGroupsMode && canAddDefault && !isLocked && <Btn
type="addDefaultCaseGroup" onClick={addDefaultCaseGroup} label={addDefaultCaseLabel} readonly={isLocked} config={config}
/>;
return (
<div className={`group--actions ${position}`}>
<BtnGrp config={config}>
{setLockSwitch}
{addCaseGroupBtn}
{addDefaultCaseGroupBtn}
</BtnGrp>
</div>
);
}
}