not-bulma 1.2.46 → 1.2.47

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": "not-bulma",
3
- "version": "1.2.46",
3
+ "version": "1.2.47",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -216,12 +216,7 @@ class notCRUD extends notController {
216
216
  }
217
217
 
218
218
  createDefault() {
219
- let newRecord = this.getModel({
220
- _id: null,
221
- title: say(this.getOptions("names.single")),
222
- products: [],
223
- });
224
- return newRecord;
219
+ return this.getModel({}).toDefault();
225
220
  }
226
221
 
227
222
  route(params = []) {
@@ -444,6 +444,19 @@ class notInterface extends notBase {
444
444
  getRecord() {
445
445
  this.getData();
446
446
  }
447
+
448
+ getDefaultAsPlainObject() {
449
+ if (!this.manifest || !this.manifest.fields) {
450
+ return {};
451
+ }
452
+ const result = {};
453
+ for (const fieldName of Object.keys(this.manifest.fields)) {
454
+ if (Object.hasOwn(this.manifest.fields[fieldName], "default")) {
455
+ result[fieldName] = this.manifest.fields[fieldName].default;
456
+ }
457
+ }
458
+ return result;
459
+ }
447
460
  }
448
461
 
449
462
  export default notInterface;
@@ -39,6 +39,10 @@ class notRecord extends notBase {
39
39
  return this;
40
40
  }
41
41
 
42
+ toDefault() {
43
+ return this.setData(this[META_INTERFACE].getDefaultAsPlainObject());
44
+ }
45
+
42
46
  mapToInterface() {
43
47
  let rec = this;
44
48
  for (let t of META_MAP_TO_INTERFACE) {