@visns-studio/visns-components 4.3.7 → 4.3.9
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.
|
@@ -124,15 +124,27 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
124
124
|
const handleAddRowOption = (e) => {
|
|
125
125
|
e.preventDefault();
|
|
126
126
|
|
|
127
|
+
console.info(dataField);
|
|
128
|
+
|
|
129
|
+
// Initialize rows if it doesn't exist
|
|
130
|
+
if (!dataField.rows) {
|
|
131
|
+
setDataField((items) => ({
|
|
132
|
+
...items,
|
|
133
|
+
rows: [],
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
|
|
127
137
|
if (rowOption.label !== '') {
|
|
128
|
-
const isLabelUnique =
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
const isLabelUnique = dataField.rows
|
|
139
|
+
? !dataField.rows.some(
|
|
140
|
+
(option) => option.label === rowOption.label
|
|
141
|
+
)
|
|
142
|
+
: true;
|
|
131
143
|
|
|
132
144
|
if (isLabelUnique) {
|
|
133
145
|
setDataField((items) => ({
|
|
134
146
|
...items,
|
|
135
|
-
rows: [...items.rows, rowOption],
|
|
147
|
+
rows: [...(items.rows || []), rowOption],
|
|
136
148
|
}));
|
|
137
149
|
|
|
138
150
|
setRowOption(() => ({
|
|
@@ -179,6 +191,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
179
191
|
label: '',
|
|
180
192
|
type: '',
|
|
181
193
|
options: [],
|
|
194
|
+
// rows: [],
|
|
182
195
|
size: 'half',
|
|
183
196
|
required: 'no',
|
|
184
197
|
}));
|
|
@@ -321,6 +334,18 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
321
334
|
(!field.options || field.options.length === 0)
|
|
322
335
|
) {
|
|
323
336
|
errors.push('Please add options for the dropdown.');
|
|
337
|
+
} else if (
|
|
338
|
+
field.type === 'table_text' &&
|
|
339
|
+
(!field.options || field.options.length === 0)
|
|
340
|
+
) {
|
|
341
|
+
errors.push('Please add options for the table.');
|
|
342
|
+
} else if (field.type === 'table_radio') {
|
|
343
|
+
if (!field.options || field.options.length === 0) {
|
|
344
|
+
errors.push('Please add options for the table.');
|
|
345
|
+
}
|
|
346
|
+
if (!field.rows || field.rows.length === 0) {
|
|
347
|
+
errors.push('Please add rows for the table.');
|
|
348
|
+
}
|
|
324
349
|
}
|
|
325
350
|
|
|
326
351
|
if (!field.size || field.size === '') {
|
package/package.json
CHANGED