@saltcorn/builder 1.3.1-beta.6 → 1.3.1-beta.8

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.
@@ -0,0 +1,96 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*!
8
+ Copyright (c) 2017 Jed Watson.
9
+ Licensed under the MIT License (MIT), see
10
+ http://jedwatson.github.io/classnames
11
+ */
12
+
13
+ /*!
14
+ * Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
15
+ * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
16
+ */
17
+
18
+ /*! *****************************************************************************
19
+ Copyright (c) Microsoft Corporation.
20
+
21
+ Permission to use, copy, modify, and/or distribute this software for any
22
+ purpose with or without fee is hereby granted.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
+ PERFORMANCE OF THIS SOFTWARE.
31
+ ***************************************************************************** */
32
+
33
+ /*! *****************************************************************************
34
+ Copyright (c) Microsoft Corporation. All rights reserved.
35
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
36
+ this file except in compliance with the License. You may obtain a copy of the
37
+ License at http://www.apache.org/licenses/LICENSE-2.0
38
+
39
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
41
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
42
+ MERCHANTABLITY OR NON-INFRINGEMENT.
43
+
44
+ See the Apache Version 2.0 License for specific language governing permissions
45
+ and limitations under the License.
46
+ ***************************************************************************** */
47
+
48
+ /*!*
49
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
50
+ * For licensing, see LICENSE.md.
51
+ */
52
+
53
+ /**
54
+ * @license
55
+ * Lodash <https://lodash.com/>
56
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
57
+ * Released under MIT license <https://lodash.com/license>
58
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
59
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
60
+ */
61
+
62
+ /** @license React v0.19.1
63
+ * scheduler.production.min.js
64
+ *
65
+ * Copyright (c) Facebook, Inc. and its affiliates.
66
+ *
67
+ * This source code is licensed under the MIT license found in the
68
+ * LICENSE file in the root directory of this source tree.
69
+ */
70
+
71
+ /** @license React v16.13.1
72
+ * react-dom.production.min.js
73
+ *
74
+ * Copyright (c) Facebook, Inc. and its affiliates.
75
+ *
76
+ * This source code is licensed under the MIT license found in the
77
+ * LICENSE file in the root directory of this source tree.
78
+ */
79
+
80
+ /** @license React v16.13.1
81
+ * react-is.production.min.js
82
+ *
83
+ * Copyright (c) Facebook, Inc. and its affiliates.
84
+ *
85
+ * This source code is licensed under the MIT license found in the
86
+ * LICENSE file in the root directory of this source tree.
87
+ */
88
+
89
+ /** @license React v16.13.1
90
+ * react.production.min.js
91
+ *
92
+ * Copyright (c) Facebook, Inc. and its affiliates.
93
+ *
94
+ * This source code is licensed under the MIT license found in the
95
+ * LICENSE file in the root directory of this source tree.
96
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/builder",
3
- "version": "1.3.1-beta.6",
3
+ "version": "1.3.1-beta.8",
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",
@@ -20,7 +20,7 @@
20
20
  "@babel/preset-react": "7.24.7",
21
21
  "@craftjs/core": "0.1.0-beta.20",
22
22
  "@craftjs/utils": "0.1.0-beta.20",
23
- "@saltcorn/common-code": "1.3.1-beta.6",
23
+ "@saltcorn/common-code": "1.3.1-beta.8",
24
24
  "saltcorn-craft-layers-noeye": "0.1.0-beta.22",
25
25
  "@fonticonpicker/react-fonticonpicker": "1.2.0",
26
26
  "@fortawesome/fontawesome-svg-core": "1.2.34",
@@ -5,7 +5,7 @@
5
5
  */
6
6
  /*global notifyAlert*/
7
7
 
8
- import React, { Fragment, useContext } from "react";
8
+ import React, { Fragment, useContext, useEffect } from "react";
9
9
  import { useNode } from "@craftjs/core";
10
10
  import optionsCtx from "../context";
11
11
  import {
@@ -178,6 +178,13 @@ const ActionSettings = () => {
178
178
  });
179
179
  setInitialConfig(setProp, value, getCfgFields(value));
180
180
  };
181
+ const setMultistepAction = (value0) => {
182
+ const value = value0.value || value0;
183
+ setProp((prop) => {
184
+ if (!prop.step_action_names) prop.step_action_names = [];
185
+ prop.step_action_names[use_setting_action_n] = value;
186
+ });
187
+ };
181
188
  const actionOptions = options.actions.filter(Boolean).map((f, ix) =>
182
189
  f.optgroup && !f.options.length
183
190
  ? null
@@ -189,6 +196,37 @@ const ActionSettings = () => {
189
196
  : { label: f, value: f }
190
197
  );
191
198
  const selectedAction = { label: name, value: name };
199
+ const multiStepActionOptions = options.actions
200
+ .filter((f) => f && !(options.builtInActions || []).includes(f))
201
+ .map((f, ix) =>
202
+ f.optgroup && !f.options.length
203
+ ? null
204
+ : f.optgroup
205
+ ? {
206
+ label: f.label,
207
+ options: f.options
208
+ .filter(
209
+ (f) =>
210
+ ![
211
+ "Multi-step action",
212
+ ...(options.builtInActions || []),
213
+ ].includes(f)
214
+ )
215
+ .map((a, jx) => ({ label: a, value: a })),
216
+ }
217
+ : { label: f, value: f }
218
+ );
219
+ const selectedMultiStepAction = {
220
+ label: step_action_names?.[use_setting_action_n] || "",
221
+ value: step_action_names?.[use_setting_action_n] || "",
222
+ };
223
+ useEffect(() => {
224
+ apply_showif();
225
+ }, [
226
+ name,
227
+ step_action_names?.[use_setting_action_n] || "",
228
+ JSON.stringify(configuration?.steps?.[use_setting_action_n]),
229
+ ]);
192
230
 
193
231
  return (
194
232
  <div>
@@ -198,7 +236,7 @@ const ActionSettings = () => {
198
236
  <td>
199
237
  <label>Action</label>
200
238
  </td>
201
- <td>
239
+ <td>
202
240
  {options.inJestTestingMode ? null : (
203
241
  <Select
204
242
  options={actionOptions}
@@ -343,47 +381,19 @@ const ActionSettings = () => {
343
381
  ></ArrayManager>
344
382
 
345
383
  <label>Action</label>
346
- <select
347
- value={step_action_names?.[use_setting_action_n] || ""}
348
- className="form-control form-select"
349
- onChange={(e) => {
350
- if (!e.target) return;
351
- const value = e.target.value;
352
- setProp((prop) => {
353
- if (!prop.step_action_names) prop.step_action_names = [];
354
- prop.step_action_names[use_setting_action_n] = value;
355
- });
356
- }}
357
- >
358
- <option value="" disabled>
359
- Select action...
360
- </option>
361
- {options.actions
362
- .filter((f) => !(options.builtInActions || []).includes(f))
363
- .map((f, ix) =>
364
- f.optgroup ? (
365
- <optgroup key={ix} label={f.label}>
366
- {f.options
367
- .filter(
368
- (f) =>
369
- ![
370
- "Multi-step action",
371
- ...(options.builtInActions || []),
372
- ].includes(f)
373
- )
374
- .map((a, jx) => (
375
- <option key={jx} value={a}>
376
- {a}
377
- </option>
378
- ))}
379
- </optgroup>
380
- ) : (
381
- <option key={ix} value={f}>
382
- {f}
383
- </option>
384
- )
385
- )}
386
- </select>
384
+ {options.inJestTestingMode ? null : (
385
+ <Select
386
+ options={multiStepActionOptions}
387
+ className="react-select multistep-action-selector"
388
+ value={selectedMultiStepAction}
389
+ defaultValue={selectedMultiStepAction}
390
+ onChange={setMultistepAction}
391
+ menuPortalTarget={document.body}
392
+ styles={{
393
+ menuPortal: (base) => ({ ...base, zIndex: 19999 }),
394
+ }}
395
+ ></Select>
396
+ )}
387
397
  {options.mode !== "page" ? (
388
398
  <Fragment>
389
399
  <label>Only if... (formula)</label>
@@ -132,15 +132,19 @@ export const FormulaTooltip = () => {
132
132
  ))}
133
133
  </Fragment>
134
134
  ) : null}
135
-
135
+
136
136
  <div>
137
- In view formulae, you can use aggregation formulae. The syntax for this is
138
- <code>[inbound_table]$[inboundkey_field]$[target_field]$[aggrgation]</code>
139
- The aggregation (which should be lower case) can be ommitted and defaults to
140
- <code>array_agg</code>. Examples: <code>patients$favbook$id$count</code> or
141
- <code>patients$favbook$id</code>.
142
- This is useful if you want a count in a view link label
143
- without creating a stored calculated field.
137
+ In view formulae, you can use aggregation formulae. The syntax for this
138
+ is
139
+ <code>
140
+ [inbound_table]$[inboundkey_field]$[target_field]$[aggrgation]
141
+ </code>
142
+ The aggregation (which should be lower case) can be ommitted and
143
+ defaults to
144
+ <code>array_agg</code>. Examples: <code>patients$favbook$id$count</code>{" "}
145
+ or
146
+ <code>patients$favbook$id</code>. This is useful if you want a count in
147
+ a view link label without creating a stored calculated field.
144
148
  </div>
145
149
  <a
146
150
  className="d-block"
@@ -786,7 +790,7 @@ const ConfigForm = ({
786
790
  tableName,
787
791
  fieldName,
788
792
  }) => (
789
- <div>
793
+ <div className="form-namespace">
790
794
  {fields.map((f, ix) => {
791
795
  if (f.showIf && configuration) {
792
796
  let noshow = false;
@@ -948,6 +952,7 @@ const ConfigField = ({
948
952
  return (
949
953
  <select
950
954
  className={`field-${field?.name} form-control form-select`}
955
+ name={field?.name}
951
956
  value={value || ""}
952
957
  onChange={(e) => e.target && myOnChange(e.target.value)}
953
958
  onBlur={(e) => e.target && myOnChange(e.target.value)}
@@ -966,6 +971,7 @@ const ConfigField = ({
966
971
  return (
967
972
  <input
968
973
  type="text"
974
+ name={field?.name}
969
975
  className={`field-${field?.name} form-control`}
970
976
  value={value || ""}
971
977
  spellCheck={false}
@@ -977,6 +983,7 @@ const ConfigField = ({
977
983
  <select
978
984
  className="fontselect form-control form-select"
979
985
  value={value || ""}
986
+ name={field?.name}
980
987
  onChange={(e) => e.target && myOnChange(e.target.value)}
981
988
  onBlur={(e) => e.target && myOnChange(e.target.value)}
982
989
  >
@@ -997,6 +1004,7 @@ const ConfigField = ({
997
1004
  step={field.step || 1}
998
1005
  min={field.min}
999
1006
  max={field.max}
1007
+ name={field?.name}
1000
1008
  value={value || ""}
1001
1009
  onChange={(e) => e.target && myOnChange(e.target.value)}
1002
1010
  />
@@ -1007,6 +1015,7 @@ const ConfigField = ({
1007
1015
  className={`field-${field?.name} form-control`}
1008
1016
  value={value || ""}
1009
1017
  step={0.01}
1018
+ name={field?.name}
1010
1019
  max={or_if_undef(field?.attributes?.max, undefined)}
1011
1020
  min={or_if_undef(field?.attributes?.min, undefined)}
1012
1021
  onChange={(e) => e.target && myOnChange(e.target.value)}
@@ -1019,6 +1028,7 @@ const ConfigField = ({
1019
1028
  type="checkbox"
1020
1029
  className={`field-${field?.name} form-check-input`}
1021
1030
  checked={value}
1031
+ name={field?.name}
1022
1032
  onChange={(e) => e.target && myOnChange(e.target.checked)}
1023
1033
  />
1024
1034
  <label className="form-check-label">{field.label}</label>
@@ -1030,6 +1040,7 @@ const ConfigField = ({
1030
1040
  type="text"
1031
1041
  className={`field-${field?.name} form-control`}
1032
1042
  value={value}
1043
+ name={field?.name}
1033
1044
  spellCheck={false}
1034
1045
  onChange={(e) => e.target && myOnChange(e.target.value)}
1035
1046
  />
@@ -1040,6 +1051,7 @@ const ConfigField = ({
1040
1051
  type="text"
1041
1052
  className={`field-${field?.name} form-control`}
1042
1053
  value={value}
1054
+ name={field?.name}
1043
1055
  onChange={(e) => e.target && myOnChange(e.target.value)}
1044
1056
  spellCheck={false}
1045
1057
  />
@@ -1063,6 +1075,7 @@ const ConfigField = ({
1063
1075
  (e.value && myOnChange(e.value)) ||
1064
1076
  (typeof e === "string" && myOnChange(e))
1065
1077
  }
1078
+ name={field?.name}
1066
1079
  onBlur={(e) =>
1067
1080
  (e.name && myOnChange(e.name)) ||
1068
1081
  (e.value && myOnChange(e.value)) ||
@@ -1077,6 +1090,7 @@ const ConfigField = ({
1077
1090
  <select
1078
1091
  className={`field-${field?.name} form-control form-select`}
1079
1092
  value={value || ""}
1093
+ name={field?.name}
1080
1094
  onChange={(e) => e.target && myOnChange(e.target.value)}
1081
1095
  onBlur={(e) => e.target && myOnChange(e.target.value)}
1082
1096
  >
@@ -1791,8 +1805,7 @@ export const buildLayers = (relations, tableName, tableNameCache) => {
1791
1805
  fkeys: [],
1792
1806
  relPath: relation.relationString,
1793
1807
  });
1794
- }
1795
- else {
1808
+ } else {
1796
1809
  let currentTbl = relation.sourceTblName;
1797
1810
  for (const pathElement of relation.path) {
1798
1811
  if (pathElement.inboundKey) {