@saltcorn/builder 1.7.0-beta.1 → 1.7.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/builder",
3
- "version": "1.7.0-beta.1",
3
+ "version": "1.7.0-beta.2",
4
4
  "description": "Drag and drop view builder for Saltcorn, open-source no-code platform",
5
5
  "main": "index.js",
6
6
  "homepage": "https://saltcorn.com",
@@ -30,7 +30,7 @@
30
30
  "@fortawesome/free-solid-svg-icons": "5.15.2",
31
31
  "@fortawesome/react-fontawesome": "0.1.14",
32
32
  "@monaco-editor/react": "4.7.0",
33
- "@saltcorn/common-code": "1.7.0-beta.1",
33
+ "@saltcorn/common-code": "1.7.0-beta.2",
34
34
  "@tippyjs/react": "4.2.6",
35
35
  "babel-loader": "9.2.1",
36
36
  "ckeditor4-react": "2.0.0",
@@ -121,6 +121,7 @@ const Columns = ({
121
121
  colClasses,
122
122
  colStyles,
123
123
  customClass,
124
+ isFormula,
124
125
  breakpoints,
125
126
  }) => {
126
127
  const {
@@ -149,7 +150,9 @@ const Columns = ({
149
150
  }
150
151
  return (
151
152
  <div
152
- className={`row builder-columns ${customClass || ""} ${selected ? "selected-node" : ""} ${
153
+ className={`row builder-columns ${
154
+ (!isFormula?.customClass && customClass) || ""
155
+ } ${selected ? "selected-node" : ""} ${
153
156
  typeof gx !== "undefined" && gx !== null ? `gx-${gx}` : ""
154
157
  } ${typeof gy !== "undefined" && gy !== null ? `gy-${gy}` : ""}`}
155
158
  ref={(dom) => connect(drag(dom))}
@@ -204,6 +207,7 @@ const ColumnsSettings = () => {
204
207
  colClasses: node.data.props.colClasses,
205
208
  colStyles: node.data.props.colStyles,
206
209
  customClass: node.data.props.customClass,
210
+ isFormula: node.data.props.isFormula,
207
211
  currentSettingsTab: node.data.props.currentSettingsTab,
208
212
  }));
209
213
  const {
@@ -409,6 +413,8 @@ const ColumnsSettings = () => {
409
413
  name: "customClass",
410
414
  label: t("Custom class"),
411
415
  type: "String",
416
+ canBeFormula: true,
417
+ formulaInEdit: true,
412
418
  }}
413
419
  node={node}
414
420
  setProp={setProp}
@@ -434,6 +440,7 @@ Columns.craft = {
434
440
  breakpoints: ["sm", "sm"],
435
441
  setting_col_n: 0,
436
442
  customClass: "",
443
+ isFormula: {},
437
444
  },
438
445
  related: {
439
446
  settings: ColumnsSettings,
@@ -327,14 +327,23 @@ export /**
327
327
  * @param {object} props.node
328
328
  * @param {string} props.nodekey
329
329
  * @param {string} props.children
330
+ * @param {boolean} [props.allowInEdit] also offer the formula in edit views
330
331
  * @returns {Fragment}
331
332
  * @namespace
332
333
  * @category saltcorn-builder
333
334
  * @subcategory components / elements / utils
334
335
  */
335
- const OrFormula = ({ setProp, isFormula, node, nodekey, children }) => {
336
+ const OrFormula = ({
337
+ setProp,
338
+ isFormula,
339
+ node,
340
+ nodekey,
341
+ children,
342
+ allowInEdit,
343
+ }) => {
336
344
  const { mode } = React.useContext(optionsCtx);
337
- const allowFormula = mode === "show" || mode === "list";
345
+ const allowFormula =
346
+ mode === "show" || mode === "list" || (allowInEdit && mode === "edit");
338
347
  /**
339
348
  * @returns {void}
340
349
  */
@@ -1616,6 +1625,7 @@ const SettingsRow = ({
1616
1625
  <OrFormula
1617
1626
  nodekey={field.name}
1618
1627
  isFormula={node.isFormula}
1628
+ allowInEdit={field.formulaInEdit}
1619
1629
  {...{ setProp, node }}
1620
1630
  >
1621
1631
  <ConfigField
@@ -409,6 +409,7 @@ const layoutToNodes = (
409
409
  header_label={col.header_label}
410
410
  col_width={col.col_width}
411
411
  showif={col.showif}
412
+ cell_css_formula={col.cell_css_formula}
412
413
  col_width_units={col.col_width_units}
413
414
  contents={toTag(col.contents)}
414
415
  {...addProps}
@@ -427,6 +428,7 @@ const layoutToNodes = (
427
428
  gx={segment.gx}
428
429
  gy={segment.gy}
429
430
  customClass={segment.customClass}
431
+ isFormula={segment.isFormula || {}}
430
432
  vAligns={segment.vAligns}
431
433
  colClasses={segment.colClasses}
432
434
  colStyles={segment.colStyles}
@@ -469,6 +471,7 @@ const layoutToNodes = (
469
471
  gx={segment.gx}
470
472
  gy={segment.gy}
471
473
  customClass={segment.customClass}
474
+ isFormula={segment.isFormula || {}}
472
475
  vAligns={segment.vAligns}
473
476
  colClasses={segment.colClasses}
474
477
  colStyles={segment.colStyles}
@@ -635,6 +638,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
635
638
  alignment: node.props.alignment,
636
639
  header_label: node.props.header_label,
637
640
  showif: node.props.showif,
641
+ cell_css_formula: node.props.cell_css_formula,
638
642
  ...customProps,
639
643
  };
640
644
  (addFields || []).forEach((f) => {
@@ -728,6 +732,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
728
732
  besides: widths.map((w, ix) => go(nodes[node.linkedNodes["Col" + ix]])),
729
733
  breakpoints: node.props.breakpoints,
730
734
  customClass: node.props.customClass,
735
+ isFormula: node.props.isFormula,
731
736
  gx: node.props.gx != null ? +node.props.gx : undefined,
732
737
  gy: node.props.gy != null ? +node.props.gy : undefined,
733
738
  aligns: node.props.aligns,