@raketa-cloud/admin 0.0.33 → 0.0.34
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 +1 -1
- package/src/helpers/FormBuilder.js +23 -13
package/package.json
CHANGED
|
@@ -215,18 +215,30 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
checkbox(name, opts = {}) {
|
|
218
|
-
const { value: desiredValue } = opts;
|
|
218
|
+
const { value: desiredValue, default_value: defaultValue } = opts;
|
|
219
219
|
|
|
220
220
|
const value = this.__getValue(name);
|
|
221
221
|
const selected = value === desiredValue ? { checked: "checked" } : {};
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
const checkboxItem = this.tag("input", null, {
|
|
224
224
|
type: "checkbox",
|
|
225
|
-
name,
|
|
226
225
|
value,
|
|
227
226
|
...opts,
|
|
228
227
|
...selected,
|
|
229
228
|
});
|
|
229
|
+
|
|
230
|
+
if (defaultValue === undefined) {
|
|
231
|
+
return checkboxItem;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Make sure to submit the negative value if unchecked
|
|
235
|
+
const hiddenComplementaryItem = this.tag("input", null, {
|
|
236
|
+
type: "hidden",
|
|
237
|
+
name: toFormName(name),
|
|
238
|
+
value: defaultValue,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return [hiddenComplementaryItem, checkboxItem].join("");
|
|
230
242
|
}
|
|
231
243
|
|
|
232
244
|
label(name, children, opts = {}) {
|
|
@@ -261,12 +273,11 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
261
273
|
label: innerOpts.label,
|
|
262
274
|
class: "no-margin",
|
|
263
275
|
});
|
|
264
|
-
} else {
|
|
265
|
-
return this.field(`${name}.${key}`, {
|
|
266
|
-
label: innerOpts.label,
|
|
267
|
-
class: "no-margin",
|
|
268
|
-
});
|
|
269
276
|
}
|
|
277
|
+
return this.field(`${name}.${key}`, {
|
|
278
|
+
label: innerOpts.label,
|
|
279
|
+
class: "no-margin",
|
|
280
|
+
});
|
|
270
281
|
});
|
|
271
282
|
|
|
272
283
|
return this.tag(
|
|
@@ -291,12 +302,11 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
291
302
|
label: innerOpts.label,
|
|
292
303
|
class: "no-margin",
|
|
293
304
|
});
|
|
294
|
-
} else {
|
|
295
|
-
return this.field(`${name}.${key}`, {
|
|
296
|
-
label: innerOpts.label,
|
|
297
|
-
class: "no-margin",
|
|
298
|
-
});
|
|
299
305
|
}
|
|
306
|
+
return this.field(`${name}.${key}`, {
|
|
307
|
+
label: innerOpts.label,
|
|
308
|
+
class: "no-margin",
|
|
309
|
+
});
|
|
300
310
|
});
|
|
301
311
|
|
|
302
312
|
return this.tag(
|