@saltcorn/builder 0.8.7-beta.1 → 0.8.7-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder_bundle.js +11 -11
- package/package.json +1 -1
- package/src/components/Builder.js +2 -0
- package/src/components/Toolbox.js +28 -5
- package/src/components/elements/Columns.js +132 -5
- package/src/components/elements/Container.js +4 -4
- package/src/components/elements/Table.js +130 -0
- package/src/components/elements/View.js +1 -0
- package/src/components/elements/utils.js +43 -24
- package/src/components/storage.js +433 -382
|
@@ -12,6 +12,7 @@ import { Empty } from "./elements/Empty";
|
|
|
12
12
|
import { Columns, ntimes, sum } from "./elements/Columns";
|
|
13
13
|
import { JoinField } from "./elements/JoinField";
|
|
14
14
|
import { Tabs } from "./elements/Tabs";
|
|
15
|
+
import { Table } from "./elements/Table";
|
|
15
16
|
import { Aggregation } from "./elements/Aggregation";
|
|
16
17
|
import { LineBreak } from "./elements/LineBreak";
|
|
17
18
|
import { ViewLink } from "./elements/ViewLink";
|
|
@@ -73,6 +74,7 @@ const allElements = [
|
|
|
73
74
|
ToggleFilter,
|
|
74
75
|
DropMenu,
|
|
75
76
|
Page,
|
|
77
|
+
Table,
|
|
76
78
|
];
|
|
77
79
|
|
|
78
80
|
export /**
|
|
@@ -85,223 +87,248 @@ export /**
|
|
|
85
87
|
* @subcategory components
|
|
86
88
|
* @namespace
|
|
87
89
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
|
|
91
|
+
//console.log("layoutToNodes", JSON.stringify(layout));
|
|
92
|
+
/**
|
|
93
|
+
* @param {object} segment
|
|
94
|
+
* @param {string} ix
|
|
95
|
+
* @returns {Element|Text|View|Action|Tabs|Columns}
|
|
96
|
+
*/
|
|
97
|
+
function toTag(segment, ix) {
|
|
98
|
+
if (!segment) return <Empty key={ix} />;
|
|
97
99
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<Element key={ix} canvas {...props} is={MatchElement}>
|
|
119
|
-
{toTag(segment.contents)}
|
|
120
|
-
</Element>
|
|
121
|
-
);
|
|
122
|
-
else return <MatchElement key={ix} {...props} />;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (segment.type === "blank") {
|
|
126
|
-
return (
|
|
127
|
-
<Text
|
|
128
|
-
key={ix}
|
|
129
|
-
text={segment.contents}
|
|
130
|
-
isFormula={segment.isFormula || {}}
|
|
131
|
-
block={segment.block || false}
|
|
132
|
-
inline={segment.inline || false}
|
|
133
|
-
textStyle={segment.textStyle || ""}
|
|
134
|
-
labelFor={segment.labelFor || ""}
|
|
135
|
-
style={segment.style || {}}
|
|
136
|
-
icon={segment.icon}
|
|
137
|
-
font={segment.font || ""}
|
|
138
|
-
/>
|
|
139
|
-
);
|
|
140
|
-
} else if (segment.type === "view") {
|
|
141
|
-
return (
|
|
142
|
-
<View
|
|
143
|
-
key={ix}
|
|
144
|
-
view={segment.view}
|
|
145
|
-
relation={segment.relation}
|
|
146
|
-
view_name={segment.view_name}
|
|
147
|
-
name={segment.name}
|
|
148
|
-
state={segment.state}
|
|
149
|
-
extra_state_fml={segment.extra_state_fml}
|
|
150
|
-
configuration={segment.configuration || {}}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
else if (segment.type === "action") {
|
|
155
|
-
return (
|
|
156
|
-
<Action
|
|
157
|
-
key={ix}
|
|
158
|
-
name={segment.action_name}
|
|
159
|
-
rndid={segment.rndid || "not_assigned"}
|
|
160
|
-
action_label={segment.action_label || ""}
|
|
161
|
-
action_style={segment.action_style || "btn-primary"}
|
|
162
|
-
action_size={segment.action_size || ""}
|
|
163
|
-
action_icon={segment.action_icon || ""}
|
|
164
|
-
action_bgcol={segment.action_bgcol || ""}
|
|
165
|
-
action_bordercol={segment.action_bordercol || ""}
|
|
166
|
-
action_textcol={segment.action_textcol || ""}
|
|
167
|
-
confirm={segment.confirm}
|
|
168
|
-
configuration={segment.configuration || {}}
|
|
169
|
-
block={segment.block || false}
|
|
170
|
-
minRole={segment.minRole || 10}
|
|
171
|
-
isFormula={segment.isFormula || {}}
|
|
172
|
-
/>
|
|
173
|
-
);
|
|
174
|
-
} else if (segment.type === "container") {
|
|
100
|
+
const MatchElement = allElements.find(
|
|
101
|
+
(e) =>
|
|
102
|
+
e.craft.related &&
|
|
103
|
+
e.craft.related.fields &&
|
|
104
|
+
e.craft.related.segment_type &&
|
|
105
|
+
e.craft.related.segment_type == segment.type &&
|
|
106
|
+
(!e.craft.related.segment_match ||
|
|
107
|
+
e.craft.related.segment_match(segment))
|
|
108
|
+
);
|
|
109
|
+
if (MatchElement) {
|
|
110
|
+
const related = MatchElement.craft.related;
|
|
111
|
+
const props = {};
|
|
112
|
+
related.fields.forEach((f) => {
|
|
113
|
+
const v = segment[f.segment_name || f.name || f];
|
|
114
|
+
props[f.name || f] = typeof v === "undefined" ? f.default : v;
|
|
115
|
+
});
|
|
116
|
+
if (related.fields.some((f) => f.canBeFormula))
|
|
117
|
+
props.isFormula = segment.isFormula;
|
|
118
|
+
if (related.hasContents)
|
|
175
119
|
return (
|
|
176
|
-
<Element
|
|
177
|
-
key={ix}
|
|
178
|
-
canvas
|
|
179
|
-
gradStartColor={segment.gradStartColor}
|
|
180
|
-
gradEndColor={segment.gradEndColor}
|
|
181
|
-
gradDirection={segment.gradDirection}
|
|
182
|
-
rotate={segment.rotate || 0}
|
|
183
|
-
customClass={segment.customClass}
|
|
184
|
-
customCSS={segment.customCSS}
|
|
185
|
-
overflow={segment.overflow}
|
|
186
|
-
margin={segment.margin || [0, 0, 0, 0]}
|
|
187
|
-
padding={segment.padding || [0, 0, 0, 0]}
|
|
188
|
-
minHeight={segment.minHeight}
|
|
189
|
-
height={segment.height}
|
|
190
|
-
width={segment.width}
|
|
191
|
-
url={segment.url}
|
|
192
|
-
hoverColor={segment.hoverColor}
|
|
193
|
-
minHeightUnit={segment.minHeightUnit || "px"}
|
|
194
|
-
heightUnit={segment.heightUnit || "px"}
|
|
195
|
-
widthUnit={segment.widthUnit || "px"}
|
|
196
|
-
vAlign={segment.vAlign}
|
|
197
|
-
hAlign={segment.hAlign}
|
|
198
|
-
htmlElement={segment.htmlElement || "div"}
|
|
199
|
-
display={
|
|
200
|
-
segment.display ||
|
|
201
|
-
(segment.block === true
|
|
202
|
-
? "block"
|
|
203
|
-
: segment.block === false
|
|
204
|
-
? "inline-block"
|
|
205
|
-
: "block")
|
|
206
|
-
}
|
|
207
|
-
fullPageWidth={
|
|
208
|
-
typeof segment.fullPageWidth === "undefined"
|
|
209
|
-
? false
|
|
210
|
-
: segment.fullPageWidth
|
|
211
|
-
}
|
|
212
|
-
bgFileId={segment.bgFileId}
|
|
213
|
-
imageSize={segment.imageSize || "contain"}
|
|
214
|
-
imgResponsiveWidths={segment.imgResponsiveWidths}
|
|
215
|
-
bgType={segment.bgType || "None"}
|
|
216
|
-
style={segment.style || {}}
|
|
217
|
-
bgColor={segment.bgColor || "#ffffff"}
|
|
218
|
-
setTextColor={!!segment.setTextColor}
|
|
219
|
-
textColor={segment.textColor || "#000000"}
|
|
220
|
-
isFormula={segment.isFormula || {}}
|
|
221
|
-
showIfFormula={segment.showIfFormula || ""}
|
|
222
|
-
showForRole={segment.showForRole || []}
|
|
223
|
-
minScreenWidth={segment.minScreenWidth || ""}
|
|
224
|
-
maxScreenWidth={segment.maxScreenWidth || ""}
|
|
225
|
-
show_for_owner={!!segment.show_for_owner}
|
|
226
|
-
is={Container}
|
|
227
|
-
>
|
|
120
|
+
<Element key={ix} canvas {...props} is={MatchElement}>
|
|
228
121
|
{toTag(segment.contents)}
|
|
229
122
|
</Element>
|
|
230
123
|
);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
124
|
+
else return <MatchElement key={ix} {...props} />;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (segment.type === "blank") {
|
|
128
|
+
return (
|
|
129
|
+
<Text
|
|
130
|
+
key={ix}
|
|
131
|
+
text={segment.contents}
|
|
132
|
+
isFormula={segment.isFormula || {}}
|
|
133
|
+
block={segment.block || false}
|
|
134
|
+
inline={segment.inline || false}
|
|
135
|
+
textStyle={segment.textStyle || ""}
|
|
136
|
+
labelFor={segment.labelFor || ""}
|
|
137
|
+
style={segment.style || {}}
|
|
138
|
+
icon={segment.icon}
|
|
139
|
+
font={segment.font || ""}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
} else if (segment.type === "view") {
|
|
143
|
+
return (
|
|
144
|
+
<View
|
|
145
|
+
key={ix}
|
|
146
|
+
view={segment.view}
|
|
147
|
+
relation={segment.relation}
|
|
148
|
+
view_name={segment.view_name}
|
|
149
|
+
name={segment.name}
|
|
150
|
+
state={segment.state}
|
|
151
|
+
extra_state_fml={segment.extra_state_fml}
|
|
152
|
+
configuration={segment.configuration || {}}
|
|
153
|
+
/>
|
|
154
|
+
);
|
|
155
|
+
} else if (segment.type === "action") {
|
|
156
|
+
return (
|
|
157
|
+
<Action
|
|
158
|
+
key={ix}
|
|
159
|
+
name={segment.action_name}
|
|
160
|
+
rndid={segment.rndid || "not_assigned"}
|
|
161
|
+
action_label={segment.action_label || ""}
|
|
162
|
+
action_style={segment.action_style || "btn-primary"}
|
|
163
|
+
action_size={segment.action_size || ""}
|
|
164
|
+
action_icon={segment.action_icon || ""}
|
|
165
|
+
action_bgcol={segment.action_bgcol || ""}
|
|
166
|
+
action_bordercol={segment.action_bordercol || ""}
|
|
167
|
+
action_textcol={segment.action_textcol || ""}
|
|
168
|
+
confirm={segment.confirm}
|
|
169
|
+
configuration={segment.configuration || {}}
|
|
170
|
+
block={segment.block || false}
|
|
171
|
+
minRole={segment.minRole || 10}
|
|
172
|
+
isFormula={segment.isFormula || {}}
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
} else if (segment.type === "container") {
|
|
176
|
+
return (
|
|
177
|
+
<Element
|
|
178
|
+
key={ix}
|
|
179
|
+
canvas
|
|
180
|
+
gradStartColor={segment.gradStartColor}
|
|
181
|
+
gradEndColor={segment.gradEndColor}
|
|
182
|
+
gradDirection={segment.gradDirection}
|
|
183
|
+
rotate={segment.rotate || 0}
|
|
184
|
+
customClass={segment.customClass}
|
|
185
|
+
customCSS={segment.customCSS}
|
|
186
|
+
overflow={segment.overflow}
|
|
187
|
+
margin={segment.margin || [0, 0, 0, 0]}
|
|
188
|
+
padding={segment.padding || [0, 0, 0, 0]}
|
|
189
|
+
minHeight={segment.minHeight}
|
|
190
|
+
height={segment.height}
|
|
191
|
+
width={segment.width}
|
|
192
|
+
url={segment.url}
|
|
193
|
+
hoverColor={segment.hoverColor}
|
|
194
|
+
minHeightUnit={segment.minHeightUnit || "px"}
|
|
195
|
+
heightUnit={segment.heightUnit || "px"}
|
|
196
|
+
widthUnit={segment.widthUnit || "px"}
|
|
197
|
+
vAlign={segment.vAlign}
|
|
198
|
+
hAlign={segment.hAlign}
|
|
199
|
+
htmlElement={segment.htmlElement || "div"}
|
|
200
|
+
display={
|
|
201
|
+
segment.display ||
|
|
202
|
+
(segment.block === true
|
|
203
|
+
? "block"
|
|
204
|
+
: segment.block === false
|
|
205
|
+
? "inline-block"
|
|
206
|
+
: "block")
|
|
207
|
+
}
|
|
208
|
+
fullPageWidth={
|
|
209
|
+
typeof segment.fullPageWidth === "undefined"
|
|
210
|
+
? false
|
|
211
|
+
: segment.fullPageWidth
|
|
212
|
+
}
|
|
213
|
+
bgFileId={segment.bgFileId}
|
|
214
|
+
imageSize={segment.imageSize || "contain"}
|
|
215
|
+
imgResponsiveWidths={segment.imgResponsiveWidths}
|
|
216
|
+
bgType={segment.bgType || "None"}
|
|
217
|
+
style={segment.style || {}}
|
|
218
|
+
bgColor={segment.bgColor || "#ffffff"}
|
|
219
|
+
setTextColor={!!segment.setTextColor}
|
|
220
|
+
textColor={segment.textColor || "#000000"}
|
|
221
|
+
isFormula={segment.isFormula || {}}
|
|
222
|
+
showIfFormula={segment.showIfFormula || ""}
|
|
223
|
+
showForRole={segment.showForRole || []}
|
|
224
|
+
minScreenWidth={segment.minScreenWidth || ""}
|
|
225
|
+
maxScreenWidth={segment.maxScreenWidth || ""}
|
|
226
|
+
show_for_owner={!!segment.show_for_owner}
|
|
227
|
+
is={Container}
|
|
228
|
+
>
|
|
229
|
+
{toTag(segment.contents)}
|
|
230
|
+
</Element>
|
|
231
|
+
);
|
|
232
|
+
} else if (segment.type === "tabs") {
|
|
233
|
+
let contentsArray = segment.contents.map(toTag);
|
|
234
|
+
let contents;
|
|
235
|
+
if (segment.tabsStyle === "Value switch") {
|
|
236
|
+
contents = {};
|
|
237
|
+
segment.titles.forEach(({ label, value }, ix) => {
|
|
238
|
+
contents[value] = contentsArray[ix];
|
|
239
|
+
});
|
|
240
|
+
} else contents = contentsArray;
|
|
241
|
+
return (
|
|
242
|
+
<Tabs
|
|
243
|
+
key={ix}
|
|
244
|
+
titles={segment.titles}
|
|
245
|
+
ntabs={segment.ntabs}
|
|
246
|
+
independent={segment.independent}
|
|
247
|
+
deeplink={segment.deeplink}
|
|
248
|
+
field={segment.field}
|
|
249
|
+
tabsStyle={segment.tabsStyle}
|
|
250
|
+
contents={contents}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
} else if (segment.type === "table") {
|
|
254
|
+
return (
|
|
255
|
+
<Table
|
|
256
|
+
key={ix}
|
|
257
|
+
rows={segment.rows || 2}
|
|
258
|
+
columns={segment.columns || 2}
|
|
259
|
+
bs_style={segment.bs_style || false}
|
|
260
|
+
bs_small={segment.bs_small || false}
|
|
261
|
+
bs_striped={segment.bs_striped || false}
|
|
262
|
+
bs_bordered={segment.bs_bordered || false}
|
|
263
|
+
bs_borderless={segment.bs_borderless || false}
|
|
264
|
+
contents={(segment.contents || []).map((row) =>
|
|
265
|
+
(row || []).map(toTag)
|
|
266
|
+
)}
|
|
267
|
+
/>
|
|
268
|
+
);
|
|
269
|
+
} else if (segment.besides) {
|
|
270
|
+
return (
|
|
271
|
+
<Columns
|
|
272
|
+
key={ix}
|
|
273
|
+
breakpoints={segment.breakpoints || default_breakpoints(segment)}
|
|
274
|
+
ncols={segment.besides.length}
|
|
275
|
+
widths={getColWidths(segment)}
|
|
276
|
+
style={segment.style || {}}
|
|
277
|
+
gx={segment.gx}
|
|
278
|
+
gy={segment.gy}
|
|
279
|
+
vAligns={segment.vAligns}
|
|
280
|
+
aligns={segment.aligns}
|
|
281
|
+
setting_col_n={1}
|
|
282
|
+
contents={segment.besides.map(toTag)}
|
|
283
|
+
/>
|
|
284
|
+
);
|
|
285
|
+
} else if (segment.above) {
|
|
286
|
+
return segment.above.map((e, ix) => toTag(e, ix));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @param {object} segment
|
|
292
|
+
* @param {object} parent
|
|
293
|
+
* @returns {void}
|
|
294
|
+
*/
|
|
295
|
+
function go(segment, parent) {
|
|
296
|
+
if (!segment) return;
|
|
297
|
+
if (segment.above) {
|
|
298
|
+
segment.above.forEach((child) => {
|
|
299
|
+
if (child) go(child, parent);
|
|
300
|
+
});
|
|
301
|
+
} else if (segment.besides) {
|
|
302
|
+
const node = query
|
|
303
|
+
.parseReactElement(
|
|
254
304
|
<Columns
|
|
255
|
-
|
|
305
|
+
widths={getColWidths(segment)}
|
|
256
306
|
breakpoints={segment.breakpoints || default_breakpoints(segment)}
|
|
257
307
|
ncols={segment.besides.length}
|
|
258
|
-
widths={getColWidths(segment)}
|
|
259
308
|
style={segment.style || {}}
|
|
309
|
+
gx={segment.gx}
|
|
310
|
+
gy={segment.gy}
|
|
311
|
+
vAligns={segment.vAligns}
|
|
312
|
+
aligns={segment.aligns}
|
|
313
|
+
setting_col_n={1}
|
|
260
314
|
contents={segment.besides.map(toTag)}
|
|
261
315
|
/>
|
|
262
|
-
)
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
* @param {object} parent
|
|
271
|
-
* @returns {void}
|
|
272
|
-
*/
|
|
273
|
-
function go(segment, parent) {
|
|
274
|
-
if (!segment) return;
|
|
275
|
-
if (segment.above) {
|
|
276
|
-
segment.above.forEach((child) => {
|
|
277
|
-
if (child) go(child, parent);
|
|
278
|
-
});
|
|
279
|
-
} else if (segment.besides) {
|
|
280
|
-
const node = query
|
|
281
|
-
.parseReactElement(
|
|
282
|
-
<Columns
|
|
283
|
-
widths={getColWidths(segment)}
|
|
284
|
-
breakpoints={segment.breakpoints || default_breakpoints(segment)}
|
|
285
|
-
ncols={segment.besides.length}
|
|
286
|
-
style={segment.style || {}}
|
|
287
|
-
contents={segment.besides.map(toTag)}
|
|
288
|
-
/>
|
|
289
|
-
)
|
|
290
|
-
.toNodeTree();
|
|
316
|
+
)
|
|
317
|
+
.toNodeTree();
|
|
318
|
+
actions.addNodeTree(node, parent);
|
|
319
|
+
} else {
|
|
320
|
+
const tag = toTag(segment);
|
|
321
|
+
if (tag) {
|
|
322
|
+
const node = query.parseReactElement(tag).toNodeTree();
|
|
323
|
+
//console.log("other", node);
|
|
291
324
|
actions.addNodeTree(node, parent);
|
|
292
|
-
} else {
|
|
293
|
-
const tag = toTag(segment);
|
|
294
|
-
if (tag) {
|
|
295
|
-
const node = query.parseReactElement(tag).toNodeTree();
|
|
296
|
-
//console.log("other", node);
|
|
297
|
-
actions.addNodeTree(node, parent);
|
|
298
|
-
}
|
|
299
325
|
}
|
|
300
326
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
327
|
+
}
|
|
328
|
+
//const node1 = query.createNode(toTag(layout));
|
|
329
|
+
//actions.add(node1, );
|
|
330
|
+
go(layout, parent);
|
|
331
|
+
};
|
|
305
332
|
|
|
306
333
|
/**
|
|
307
334
|
* @returns {number}
|
|
@@ -316,196 +343,220 @@ export /**
|
|
|
316
343
|
* @subcategory components
|
|
317
344
|
* @namespace
|
|
318
345
|
*/
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
346
|
+
const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
|
|
347
|
+
//console.log(JSON.stringify(nodes, null, 2));
|
|
348
|
+
var columns = [];
|
|
322
349
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
350
|
+
/**
|
|
351
|
+
* @param {object} node
|
|
352
|
+
* @returns {void|object}
|
|
353
|
+
*/
|
|
354
|
+
const get_nodes = (node) => {
|
|
355
|
+
if (!node.nodes || node.nodes.length == 0) return;
|
|
356
|
+
else if (node.nodes.length == 1) return go(nodes[node.nodes[0]]);
|
|
357
|
+
else return { above: node.nodes.map((nm) => go(nodes[nm])) };
|
|
358
|
+
};
|
|
332
359
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
360
|
+
/**
|
|
361
|
+
* @param {object} node
|
|
362
|
+
* @returns {object}
|
|
363
|
+
*/
|
|
364
|
+
const go = (node) => {
|
|
365
|
+
if (!node) return;
|
|
366
|
+
const matchElement = allElements.find(
|
|
367
|
+
(e) =>
|
|
368
|
+
e.craft.related &&
|
|
369
|
+
node.displayName === e.craft.displayName &&
|
|
370
|
+
e.craft.related.fields &&
|
|
371
|
+
e.craft.related.segment_type
|
|
372
|
+
);
|
|
373
|
+
if (matchElement) {
|
|
374
|
+
const related = matchElement.craft.related;
|
|
375
|
+
const s = { type: related.segment_type };
|
|
376
|
+
if (related.hasContents) s.contents = get_nodes(node);
|
|
377
|
+
related.fields.forEach((f) => {
|
|
378
|
+
s[f.segment_name || f.name || f] = node.props[f.name || f];
|
|
379
|
+
});
|
|
380
|
+
if (related.fields.some((f) => f.canBeFormula))
|
|
381
|
+
s.isFormula = node.props.isFormula;
|
|
382
|
+
if (related.segment_vars) Object.assign(s, related.segment_vars);
|
|
383
|
+
if (related.column_type) {
|
|
384
|
+
const c = { type: related.column_type };
|
|
350
385
|
related.fields.forEach((f) => {
|
|
351
|
-
|
|
386
|
+
c[f.column_name || f.name || f] = node.props[f.name || f];
|
|
352
387
|
});
|
|
353
|
-
|
|
354
|
-
s.isFormula = node.props.isFormula;
|
|
355
|
-
if (related.segment_vars) Object.assign(s, related.segment_vars);
|
|
356
|
-
if (related.column_type) {
|
|
357
|
-
const c = { type: related.column_type };
|
|
358
|
-
related.fields.forEach((f) => {
|
|
359
|
-
c[f.column_name || f.name || f] = node.props[f.name || f];
|
|
360
|
-
});
|
|
361
|
-
columns.push(c);
|
|
362
|
-
}
|
|
363
|
-
return s;
|
|
364
|
-
}
|
|
365
|
-
if (node.isCanvas) {
|
|
366
|
-
if (node.displayName === Container.craft.displayName)
|
|
367
|
-
return {
|
|
368
|
-
contents: get_nodes(node),
|
|
369
|
-
type: "container",
|
|
370
|
-
customCSS: node.props.customCSS,
|
|
371
|
-
customClass: node.props.customClass,
|
|
372
|
-
minHeight: node.props.minHeight,
|
|
373
|
-
height: node.props.height,
|
|
374
|
-
width: node.props.width,
|
|
375
|
-
url: node.props.url,
|
|
376
|
-
hoverColor: node.props.hoverColor,
|
|
377
|
-
minHeightUnit: node.props.minHeightUnit,
|
|
378
|
-
heightUnit: node.props.heightUnit,
|
|
379
|
-
widthUnit: node.props.widthUnit,
|
|
380
|
-
vAlign: node.props.vAlign,
|
|
381
|
-
hAlign: node.props.hAlign,
|
|
382
|
-
htmlElement: node.props.htmlElement,
|
|
383
|
-
margin: node.props.margin,
|
|
384
|
-
padding: node.props.padding,
|
|
385
|
-
overflow: node.props.overflow,
|
|
386
|
-
display: node.props.display,
|
|
387
|
-
fullPageWidth: node.props.fullPageWidth || false,
|
|
388
|
-
bgFileId: node.props.bgFileId,
|
|
389
|
-
bgType: node.props.bgType,
|
|
390
|
-
imageSize: node.props.imageSize,
|
|
391
|
-
imgResponsiveWidths: node.props.imgResponsiveWidths,
|
|
392
|
-
bgColor: node.props.bgColor,
|
|
393
|
-
setTextColor: node.props.setTextColor,
|
|
394
|
-
textColor: node.props.textColor,
|
|
395
|
-
isFormula: node.props.isFormula,
|
|
396
|
-
showIfFormula: node.props.showIfFormula,
|
|
397
|
-
showForRole: node.props.showForRole,
|
|
398
|
-
minScreenWidth: node.props.minScreenWidth,
|
|
399
|
-
maxScreenWidth: node.props.maxScreenWidth,
|
|
400
|
-
show_for_owner: node.props.show_for_owner,
|
|
401
|
-
gradStartColor: node.props.gradStartColor,
|
|
402
|
-
gradEndColor: node.props.gradEndColor,
|
|
403
|
-
gradDirection: node.props.gradDirection,
|
|
404
|
-
rotate: node.props.rotate,
|
|
405
|
-
style: node.props.style,
|
|
406
|
-
};
|
|
407
|
-
else return get_nodes(node);
|
|
388
|
+
columns.push(c);
|
|
408
389
|
}
|
|
409
|
-
|
|
410
|
-
|
|
390
|
+
return s;
|
|
391
|
+
}
|
|
392
|
+
if (node.isCanvas) {
|
|
393
|
+
if (node.displayName === Container.craft.displayName)
|
|
411
394
|
return {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
395
|
+
contents: get_nodes(node),
|
|
396
|
+
type: "container",
|
|
397
|
+
customCSS: node.props.customCSS,
|
|
398
|
+
customClass: node.props.customClass,
|
|
399
|
+
minHeight: node.props.minHeight,
|
|
400
|
+
height: node.props.height,
|
|
401
|
+
width: node.props.width,
|
|
402
|
+
url: node.props.url,
|
|
403
|
+
hoverColor: node.props.hoverColor,
|
|
404
|
+
minHeightUnit: node.props.minHeightUnit,
|
|
405
|
+
heightUnit: node.props.heightUnit,
|
|
406
|
+
widthUnit: node.props.widthUnit,
|
|
407
|
+
vAlign: node.props.vAlign,
|
|
408
|
+
hAlign: node.props.hAlign,
|
|
409
|
+
htmlElement: node.props.htmlElement,
|
|
410
|
+
margin: node.props.margin,
|
|
411
|
+
padding: node.props.padding,
|
|
412
|
+
overflow: node.props.overflow,
|
|
413
|
+
display: node.props.display,
|
|
414
|
+
fullPageWidth: node.props.fullPageWidth || false,
|
|
415
|
+
bgFileId: node.props.bgFileId,
|
|
416
|
+
bgType: node.props.bgType,
|
|
417
|
+
imageSize: node.props.imageSize,
|
|
418
|
+
imgResponsiveWidths: node.props.imgResponsiveWidths,
|
|
419
|
+
bgColor: node.props.bgColor,
|
|
420
|
+
setTextColor: node.props.setTextColor,
|
|
421
|
+
textColor: node.props.textColor,
|
|
417
422
|
isFormula: node.props.isFormula,
|
|
418
|
-
|
|
423
|
+
showIfFormula: node.props.showIfFormula,
|
|
424
|
+
showForRole: node.props.showForRole,
|
|
425
|
+
minScreenWidth: node.props.minScreenWidth,
|
|
426
|
+
maxScreenWidth: node.props.maxScreenWidth,
|
|
427
|
+
show_for_owner: node.props.show_for_owner,
|
|
428
|
+
gradStartColor: node.props.gradStartColor,
|
|
429
|
+
gradEndColor: node.props.gradEndColor,
|
|
430
|
+
gradDirection: node.props.gradDirection,
|
|
431
|
+
rotate: node.props.rotate,
|
|
419
432
|
style: node.props.style,
|
|
420
|
-
icon: node.props.icon,
|
|
421
|
-
font: node.props.font,
|
|
422
433
|
};
|
|
423
|
-
|
|
434
|
+
else return get_nodes(node);
|
|
435
|
+
}
|
|
424
436
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return go(nodes[node.linkedNodes["Tab" + useIx]]);
|
|
440
|
-
});
|
|
441
|
-
} else
|
|
442
|
-
contents = ntimes(node.props.ntabs, (ix) =>
|
|
443
|
-
go(nodes[node.linkedNodes["Tab" + ix]])
|
|
444
|
-
);
|
|
445
|
-
return {
|
|
446
|
-
type: "tabs",
|
|
447
|
-
contents,
|
|
448
|
-
titles: node.props.titles,
|
|
449
|
-
tabsStyle: node.props.tabsStyle,
|
|
450
|
-
field: node.props.field,
|
|
451
|
-
independent: node.props.independent,
|
|
452
|
-
deeplink: node.props.deeplink,
|
|
453
|
-
ntabs: node.props.ntabs,
|
|
454
|
-
};
|
|
455
|
-
}
|
|
437
|
+
if (node.displayName === Text.craft.displayName) {
|
|
438
|
+
return {
|
|
439
|
+
type: "blank",
|
|
440
|
+
contents: node.props.text,
|
|
441
|
+
block: node.props.block,
|
|
442
|
+
inline: node.props.inline,
|
|
443
|
+
textStyle: node.props.textStyle,
|
|
444
|
+
isFormula: node.props.isFormula,
|
|
445
|
+
labelFor: node.props.labelFor,
|
|
446
|
+
style: node.props.style,
|
|
447
|
+
icon: node.props.icon,
|
|
448
|
+
font: node.props.font,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
456
451
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
452
|
+
if (node.displayName === Table.craft.displayName) {
|
|
453
|
+
const rows = node.props.rows;
|
|
454
|
+
const columns = node.props.columns;
|
|
455
|
+
|
|
456
|
+
const contents = ntimes(rows, (ri) =>
|
|
457
|
+
ntimes(columns, (ci) => go(nodes[node.linkedNodes[`cell_${ri}_${ci}`]]))
|
|
458
|
+
);
|
|
459
|
+
return {
|
|
460
|
+
type: "table",
|
|
461
|
+
rows,
|
|
462
|
+
columns,
|
|
463
|
+
contents,
|
|
464
|
+
bs_style: node.props.bs_style,
|
|
465
|
+
bs_small: node.props.bs_small,
|
|
466
|
+
bs_striped: node.props.bs_striped,
|
|
467
|
+
bs_bordered: node.props.bs_bordered,
|
|
468
|
+
bs_borderless: node.props.bs_borderless,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (node.displayName === Columns.craft.displayName) {
|
|
473
|
+
const widths = [...node.props.widths, 12 - sum(node.props.widths)];
|
|
474
|
+
return {
|
|
475
|
+
besides: widths.map((w, ix) => go(nodes[node.linkedNodes["Col" + ix]])),
|
|
476
|
+
breakpoints: node.props.breakpoints,
|
|
477
|
+
gx: +node.props.gx,
|
|
478
|
+
gy: +node.props.gy,
|
|
479
|
+
aligns: node.props.aligns,
|
|
480
|
+
vAligns: node.props.vAligns,
|
|
481
|
+
style: node.props.style,
|
|
482
|
+
widths,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
if (node.displayName === Tabs.craft.displayName) {
|
|
486
|
+
let contents;
|
|
487
|
+
if (node.props.tabsStyle === "Value switch") {
|
|
488
|
+
contents = node.props.titles.map(({ value }, ix) => {
|
|
489
|
+
const useIx = typeof value === "undefined" ? ix : value;
|
|
490
|
+
return go(nodes[node.linkedNodes["Tab" + useIx]]);
|
|
486
491
|
});
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
492
|
+
} else
|
|
493
|
+
contents = ntimes(node.props.ntabs, (ix) =>
|
|
494
|
+
go(nodes[node.linkedNodes["Tab" + ix]])
|
|
495
|
+
);
|
|
496
|
+
return {
|
|
497
|
+
type: "tabs",
|
|
498
|
+
contents,
|
|
499
|
+
titles: node.props.titles,
|
|
500
|
+
tabsStyle: node.props.tabsStyle,
|
|
501
|
+
field: node.props.field,
|
|
502
|
+
independent: node.props.independent,
|
|
503
|
+
deeplink: node.props.deeplink,
|
|
504
|
+
ntabs: node.props.ntabs,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (node.displayName === View.craft.displayName) {
|
|
509
|
+
return {
|
|
510
|
+
type: "view",
|
|
511
|
+
view: node.props.view,
|
|
512
|
+
relation: node.props.relation,
|
|
513
|
+
name:
|
|
514
|
+
node.props.name === "not_assigned" ? rand_ident() : node.props.name,
|
|
515
|
+
state: node.props.state,
|
|
516
|
+
configuration: node.props.configuration,
|
|
517
|
+
extra_state_fml: node.props.extra_state_fml,
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
if (node.displayName === Action.craft.displayName) {
|
|
521
|
+
const newid = rand_ident();
|
|
522
|
+
columns.push({
|
|
523
|
+
type: "Action",
|
|
524
|
+
action_name: node.props.name,
|
|
525
|
+
action_label: node.props.action_label,
|
|
526
|
+
action_style: node.props.action_style,
|
|
527
|
+
action_size: node.props.action_size,
|
|
528
|
+
action_icon: node.props.action_icon,
|
|
529
|
+
action_bgcol: node.props.action_bgcol,
|
|
530
|
+
action_bordercol: node.props.action_bordercol,
|
|
531
|
+
action_textcol: node.props.action_textcol,
|
|
532
|
+
minRole: node.props.minRole,
|
|
533
|
+
confirm: node.props.confirm,
|
|
534
|
+
configuration: node.props.configuration,
|
|
535
|
+
isFormula: node.props.isFormula,
|
|
536
|
+
rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
|
|
537
|
+
});
|
|
538
|
+
return {
|
|
539
|
+
type: "action",
|
|
540
|
+
block: node.props.block,
|
|
541
|
+
configuration: node.props.configuration,
|
|
542
|
+
confirm: node.props.confirm,
|
|
543
|
+
action_name: node.props.name,
|
|
544
|
+
action_label: node.props.action_label,
|
|
545
|
+
action_style: node.props.action_style,
|
|
546
|
+
action_size: node.props.action_size,
|
|
547
|
+
action_icon: node.props.action_icon,
|
|
548
|
+
action_bgcol: node.props.action_bgcol,
|
|
549
|
+
action_bordercol: node.props.action_bordercol,
|
|
550
|
+
action_textcol: node.props.action_textcol,
|
|
551
|
+
minRole: node.props.minRole,
|
|
552
|
+
isFormula: node.props.isFormula,
|
|
553
|
+
rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
const layout = go(nodes[startFrom]) || { type: "blank", contents: "" };
|
|
558
|
+
/*console.log("nodes", JSON.stringify(nodes));
|
|
508
559
|
console.log("cols", JSON.stringify(columns));
|
|
509
560
|
console.log("layout", JSON.stringify(layout));*/
|
|
510
|
-
|
|
511
|
-
|
|
561
|
+
return { columns, layout };
|
|
562
|
+
};
|