@saltcorn/builder 0.7.2-beta.9 → 0.7.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": "0.7.2-beta.9",
3
+ "version": "0.7.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",
@@ -591,6 +591,7 @@ const ToolboxFilter = () => {
591
591
  </div>
592
592
  <div className="toolbar-row">
593
593
  <HTMLElem connectors={connectors} />
594
+ <LinkElem connectors={connectors} />
594
595
  </div>
595
596
  </Fragment>
596
597
  );
@@ -95,6 +95,7 @@ const LinkSettings = () => {
95
95
  link_bgcol: node.data.props.link_bgcol,
96
96
  link_bordercol: node.data.props.link_bordercol,
97
97
  link_textcol: node.data.props.link_textcol,
98
+ transfer_state: node.data.props.transfer_state,
98
99
  }));
99
100
  const {
100
101
  actions: { setProp },
@@ -107,6 +108,7 @@ const LinkSettings = () => {
107
108
  target_blank,
108
109
  link_src,
109
110
  in_modal,
111
+ transfer_state,
110
112
  } = node;
111
113
  const options = useContext(optionsCtx);
112
114
  const setAProp = (key) => (e) => {
@@ -154,7 +156,9 @@ const LinkSettings = () => {
154
156
  <option>URL</option>
155
157
  {(options.pages || []).length > 0 && <option>Page</option>}
156
158
  {(options.views || []).length > 0 &&
157
- options.mode === "page" && <option>View</option>}
159
+ ["page", "filter"].includes(options.mode) && (
160
+ <option>View</option>
161
+ )}
158
162
  </select>
159
163
  </td>
160
164
  </tr>
@@ -187,8 +191,10 @@ const LinkSettings = () => {
187
191
  onChange={setAProp("url")}
188
192
  >
189
193
  <option></option>
190
- {(options.pages || []).map((p) => (
191
- <option value={`/page/${p.name}`}>{p.name}</option>
194
+ {(options.pages || []).map((p, ix) => (
195
+ <option key={ix} value={`/page/${p.name}`}>
196
+ {p.name}
197
+ </option>
192
198
  ))}
193
199
  </select>
194
200
  </td>
@@ -206,8 +212,8 @@ const LinkSettings = () => {
206
212
  onChange={setAProp("url")}
207
213
  >
208
214
  <option></option>
209
- {(options.views || []).map((p) => (
210
- <option value={`/view/${p.name}`}>
215
+ {(options.views || []).map((p, ix) => (
216
+ <option key={ix} value={`/view/${p.name}`}>
211
217
  {p.name} [{p.viewtemplate}]
212
218
  </option>
213
219
  ))}
@@ -261,6 +267,22 @@ const LinkSettings = () => {
261
267
  />
262
268
  <label className="form-check-label">Open in popup modal?</label>
263
269
  </div>
270
+
271
+ {["filter", "page"].includes(options.mode) && (
272
+ <div className="form-check">
273
+ <input
274
+ className="form-check-input"
275
+ name="block"
276
+ type="checkbox"
277
+ checked={transfer_state}
278
+ onChange={(e) =>
279
+ setProp((prop) => (prop.transfer_state = e.target.checked))
280
+ }
281
+ />
282
+ <label className="form-check-label">Transfer state</label>
283
+ </div>
284
+ )}
285
+
264
286
  <BlockSetting block={block} setProp={setProp} />
265
287
  <TextStyleSetting textStyle={textStyle} setProp={setProp} />
266
288
  </div>
@@ -300,6 +322,7 @@ Link.craft = {
300
322
  "link_bordercol",
301
323
  "link_textcol",
302
324
  "in_modal",
325
+ "transfer_state",
303
326
  ],
304
327
  },
305
328
  };
@@ -105,6 +105,12 @@ const ViewSettings = () => {
105
105
  setProp((prop) => (prop[key] = target_value));
106
106
  }
107
107
  };
108
+ let errorString = false;
109
+ try {
110
+ Function("return " + extra_state_fml);
111
+ } catch (error) {
112
+ errorString = error.message;
113
+ }
108
114
  return (
109
115
  <div>
110
116
  <div>
@@ -163,6 +169,11 @@ const ViewSettings = () => {
163
169
  setProp((prop) => (prop.extra_state_fml = e.target.value))
164
170
  }
165
171
  />
172
+ {errorString ? (
173
+ <small className="text-danger font-monospace d-block">
174
+ {errorString}
175
+ </small>
176
+ ) : null}
166
177
  </Fragment>
167
178
  )}
168
179
  {view ? (
@@ -113,6 +113,12 @@ const ViewLinkSettings = () => {
113
113
  extra_state_fml,
114
114
  } = node;
115
115
  const options = useContext(optionsCtx);
116
+ let errorString = false;
117
+ try {
118
+ Function("return " + extra_state_fml);
119
+ } catch (error) {
120
+ errorString = error.message;
121
+ }
116
122
  return (
117
123
  <div>
118
124
  <table className="w-100">
@@ -161,6 +167,11 @@ const ViewLinkSettings = () => {
161
167
  setProp((prop) => (prop.extra_state_fml = e.target.value))
162
168
  }
163
169
  />
170
+ {errorString ? (
171
+ <small className="text-danger font-monospace d-block">
172
+ {errorString}
173
+ </small>
174
+ ) : null}
164
175
  </td>
165
176
  </tr>
166
177
 
@@ -110,6 +110,14 @@ const OrFormula = ({ setProp, isFormula, node, nodekey, children }) => {
110
110
  }
111
111
  });
112
112
  };
113
+ let errorString = false;
114
+ if (isFormula[nodekey]) {
115
+ try {
116
+ Function("return " + node[nodekey]);
117
+ } catch (error) {
118
+ errorString = error.message;
119
+ }
120
+ }
113
121
  return mode !== "show" ? (
114
122
  children
115
123
  ) : (
@@ -119,7 +127,7 @@ const OrFormula = ({ setProp, isFormula, node, nodekey, children }) => {
119
127
  <input
120
128
  type="text"
121
129
  className="form-control text-to-display"
122
- value={node[nodekey]}
130
+ value={node[nodekey] || ""}
123
131
  onChange={(e) => {
124
132
  if (e.target) {
125
133
  const target_value = e.target.value;
@@ -145,6 +153,11 @@ const OrFormula = ({ setProp, isFormula, node, nodekey, children }) => {
145
153
  {isFormula[nodekey] && (
146
154
  <div style={{ marginTop: "-5px" }}>
147
155
  <small className="text-muted font-monospace">FORMULA</small>
156
+ {errorString ? (
157
+ <small className="text-danger font-monospace d-block">
158
+ {errorString}
159
+ </small>
160
+ ) : null}
148
161
  </div>
149
162
  )}
150
163
  </Fragment>