@sealcode/sealgen 0.19.34 → 0.19.35

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.
@@ -18,14 +18,18 @@ class Table extends FormControl {
18
18
  const get_row_fctx = (row, row_index) => {
19
19
  return typeof row_index == "number" ? {
20
20
  data: {
21
- raw_values: Object.fromEntries(
22
- Object.entries(
23
- row
24
- ).map(([key, value]) => [
25
- this.table_field.columns[key].name,
26
- value
27
- ])
28
- ) || {},
21
+ raw_values: {
22
+ [this.table_field.name]: {
23
+ [TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER]: Object.fromEntries(
24
+ Object.entries(
25
+ row
26
+ ).map(([key, value]) => [
27
+ this.table_field.columns[key].name.split("][").at(-1).replace("]", ""),
28
+ value
29
+ ])
30
+ ) || {}
31
+ }
32
+ },
29
33
  messages: [],
30
34
  field_messages: {}
31
35
  }
@@ -103,6 +107,13 @@ class Table extends FormControl {
103
107
  data-table-placeholder="${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}"
104
108
  >
105
109
  <table data-sealgen-table-target="table">
110
+ <thead>
111
+ <tr>
112
+ ${Object.keys(this.table_field?.columns).map(
113
+ (c) => `<th>${c}</th>`
114
+ )}
115
+ </tr>
116
+ </thead>
106
117
  <tbody>
107
118
  ${rows?.map((row, index) => make_row(row, index))}
108
119
  </tbody>
@@ -29,7 +29,7 @@ class FormField {
29
29
  return this;
30
30
  }
31
31
  getValuePath() {
32
- return (this.value_path || this.name).replaceAll("][", ".").replaceAll("[", ".");
32
+ return (this.value_path || this.name).replaceAll("][", ".").replaceAll("[", ".").replaceAll("]", "");
33
33
  }
34
34
  setValuePath(path) {
35
35
  this.value_path = path;
@@ -18,6 +18,7 @@ class Table extends FormField {
18
18
  field.setName(
19
19
  `${this.name}[${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}][${column_name}]`
20
20
  );
21
+ field.setLabel(" ");
21
22
  }
22
23
  return this;
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.34",
3
+ "version": "0.19.35",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -66,15 +66,23 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
66
66
  return typeof row_index == "number" ?
67
67
  {
68
68
  data: {
69
- raw_values:
70
- (Object.fromEntries(
71
- Object.entries(
72
- row as Record<string, unknown>
73
- ).map(([key, value]) => [
74
- this.table_field.columns[key]!.name,
75
- value,
76
- ])
77
- ) as any) || {},
69
+ raw_values: {
70
+ [this.table_field.name]: {
71
+ [TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER]:
72
+ (Object.fromEntries(
73
+ Object.entries(
74
+ row as Record<string, unknown>
75
+ ).map(([key, value]) => [
76
+ this.table_field.columns[
77
+ key
78
+ ]!.name.split("][")
79
+ .at(-1)!
80
+ .replace("]", ""),
81
+ value,
82
+ ])
83
+ ) as any) || {},
84
+ },
85
+ },
78
86
  messages: [],
79
87
  field_messages: {},
80
88
  },
@@ -176,6 +184,13 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
176
184
  data-table-placeholder="${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}"
177
185
  >
178
186
  <table data-sealgen-table-target="table">
187
+ <thead>
188
+ <tr>
189
+ ${Object.keys(this.table_field?.columns).map(
190
+ (c) => `<th>${c}</th>`
191
+ )}
192
+ </tr>
193
+ </thead>
179
194
  <tbody>
180
195
  ${rows?.map((row, index) => make_row(row, index))}
181
196
  </tbody>
@@ -94,7 +94,8 @@ export abstract class FormField<
94
94
  public getValuePath() {
95
95
  return (this.value_path || this.name)
96
96
  .replaceAll("][", ".")
97
- .replaceAll("[", ".");
97
+ .replaceAll("[", ".")
98
+ .replaceAll("]", "");
98
99
  }
99
100
 
100
101
  public setValuePath(path: string) {
@@ -35,6 +35,7 @@ export class Table<F extends Record<string, FormField>> extends FormField<
35
35
  field.setName(
36
36
  `${this.name}[${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}][${column_name}]`
37
37
  );
38
+ field.setLabel(" ");
38
39
  }
39
40
  return this;
40
41
  }