@nauticana/sail 0.9.4 → 0.9.5

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": "@nauticana/sail",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Metadata-driven Angular component library for CRUD admin frontends backed by the keel Go backend. Tables, forms, navigation, OTP/2FA/social auth, billing, payout onboarding.",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -63,15 +63,18 @@ export class TableEdit extends BaseForm implements OnInit {
63
63
  if (rec) Object.assign(this.editableRecord, rec);
64
64
  }
65
65
 
66
+ /**
67
+ * Tabs are the table's child relations (rest_api_child metadata), not just
68
+ * whatever array fields the backend happened to embed. Seed an empty array
69
+ * for any child the response omitted so its grid renders (and accepts new rows).
70
+ */
66
71
  private buildTabs() {
67
- this.tabCount = 0;
68
- this.tabFields = [];
69
- for (const field of Object.keys(this.editableRecord)) {
70
- if (this.isArray(this.editableRecord[field])) {
71
- this.tabCount++;
72
- this.tabFields.push(field);
73
- }
72
+ const tableDef = this.cacheService.getTableDefinition(this.tableName());
73
+ this.tabFields = (tableDef?.Children ?? []).map((child) => child.PascalName);
74
+ for (const field of this.tabFields) {
75
+ if (!this.isArray(this.editableRecord[field])) this.editableRecord[field] = [];
74
76
  }
77
+ this.tabCount = this.tabFields.length;
75
78
  }
76
79
 
77
80
  /** Re-fetch the row from the backend after a server-side mutation (TableAction success, etc.). */