forked from ukrbublik/react-awesome-query-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.js
More file actions
110 lines (101 loc) · 2.68 KB
/
Copy pathtree.js
File metadata and controls
110 lines (101 loc) · 2.68 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import Immutable from "immutable";
import {toImmutableList} from "../utils/stuff";
import * as constants from "../stores/constants";
import { defaultRuleProperties, defaultGroupProperties } from "../utils/defaultUtils";
import uuid from "../utils/uuid";
/**
* @param {object} config
* @param {Immutable.Map} tree
*/
export const setTree = (config, tree) => ({
type: constants.SET_TREE,
tree: tree,
config: config
});
/**
* @param {object} config
* @param {Immutable.List} path
* @param {Immutable.Map} properties
*/
export const addRule = (config, path, properties, ruleType = "rule", children = null) => ({
type: constants.ADD_RULE,
ruleType: ruleType,
children: children,
path: toImmutableList(path),
id: uuid(),
properties: defaultRuleProperties(config).merge(properties || {}),
config: config
});
/**
* @param {object} config
* @param {Immutable.List} path
*/
export const removeRule = (config, path) => ({
type: constants.REMOVE_RULE,
path: toImmutableList(path),
config: config
});
/**
* @param {object} config
* @param {Immutable.List} path
* @param {Immutable.Map} properties
*/
export const addDefaultCaseGroup = (config, path, properties, children = null) => ({
type: constants.ADD_CASE_GROUP,
path: toImmutableList(path),
children: children,
id: uuid(),
properties: defaultGroupProperties(config).merge(properties || {}),
config: config,
meta: {
isDefaultCase: true
}
});
/**
* @param {object} config
* @param {Immutable.List} path
* @param {Immutable.Map} properties
*/
export const addCaseGroup = (config, path, properties, children = null) => ({
type: constants.ADD_CASE_GROUP,
path: toImmutableList(path),
children: children,
id: uuid(),
properties: defaultGroupProperties(config).merge(properties || {}),
config: config
});
/**
* @param {object} config
* @param {Immutable.List} path
* @param {Immutable.Map} properties
*/
export const addGroup = (config, path, properties, children = null) => ({
type: constants.ADD_GROUP,
path: toImmutableList(path),
children: children,
id: uuid(),
properties: defaultGroupProperties(config).merge(properties || {}),
config: config
});
/**
* @param {object} config
* @param {Immutable.List} path
*/
export const removeGroup = (config, path) => ({
type: constants.REMOVE_GROUP,
path: toImmutableList(path),
config: config
});
/**
* @param {object} config
* @param {Array} fromPath
* @param {Array} toPath
* @param {String} placement, see constants PLACEMENT_*
*/
export const moveItem = (config, fromPath, toPath, placement) => ({
type: constants.MOVE_ITEM,
fromPath: toImmutableList(fromPath),
toPath: toImmutableList(toPath),
placement: placement,
config: config,
});