@sealcode/sealgen 0.17.24 → 0.17.26

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.
@@ -0,0 +1 @@
1
+ npm run lint
@@ -8,6 +8,9 @@ declare const defaults: {
8
8
  render: string;
9
9
  get_initial_values: string;
10
10
  other_methods: string;
11
+ success_message: string;
11
12
  };
12
- export declare function formTemplate(action_name: string, newfilefullpath: string, _params?: Partial<typeof defaults>): Promise<string>;
13
+ export declare function formTemplate(action_name: string, newfilefullpath: string, _params?: Partial<typeof defaults> & {
14
+ success_message: string;
15
+ }): Promise<string>;
13
16
  export {};
@@ -34,7 +34,8 @@ describe("single-reference.test", () => {
34
34
  postimport: `import {Comments} from "../collections/collections.js"; import {Fields} from "@sealcode/sealgen";`,
35
35
  fields: `article: new Fields.CollectionField(true, Comments.fields.article),`,
36
36
  controls: `new Controls.SingleReferenceDropdown(fields.article, {getLabel: item=>item.get("title")}),`,
37
- validate_method: ""
37
+ validate_method: "",
38
+ success_message: "Submit OK"
38
39
  })
39
40
  );
40
41
  await test_app.start();
@@ -35,10 +35,11 @@ const defaults = {
35
35
  return { canAccess: true, message: "" };
36
36
  }`,
37
37
  render: `async render(ctx: Context, data: FormData, show_field_errors: boolean) {
38
- return html({ctx, title: "Form", description: "", body: await super.render(ctx, data, show_field_errors)});
38
+ return html({ctx, title: "Form", description: "", css_clumps: ["admin-forms"], body: await super.render(ctx, data, show_field_errors)});
39
39
  }`,
40
40
  get_initial_values: "",
41
- other_methods: ""
41
+ other_methods: "",
42
+ success_message: "Success!"
42
43
  };
43
44
  async function formTemplate(action_name, newfilefullpath, _params = defaults) {
44
45
  const params = { ...defaults, ..._params };
@@ -15,6 +15,7 @@ async function createItemFormTemplate(create_action_name, newfilefullpath, colle
15
15
  );
16
16
  const post_create_actions = field_handler_results.map(({ post_create }) => post_create).filter((e) => e != "");
17
17
  return formTemplate(create_action_name, newfilefullpath, {
18
+ success_message: "Created!",
18
19
  postimport: `import {${toPascalCase(
19
20
  collection_name
20
21
  )}FormFields, ${toPascalCase(
@@ -76,7 +77,8 @@ async function createItemFormTemplate(create_action_name, newfilefullpath, colle
76
77
  >
77
78
  \${await super.render(ctx, data, show_field_errors)}
78
79
  </div>\`,
79
- description: ""
80
+ description: "",
81
+ css_clumps: ["admin-forms"]
80
82
  }
81
83
  );
82
84
  }`
@@ -14,6 +14,7 @@ async function editItemFormTemplate(edit_action_name, newfilefullpath, collectio
14
14
  })
15
15
  );
16
16
  return formTemplate(edit_action_name, newfilefullpath, {
17
+ success_message: "Changes saved!",
17
18
  postimport: `import {${toPascalCase(
18
19
  collection_name
19
20
  )}FormFields, ${toPascalCase(
@@ -152,7 +153,7 @@ async function editItemFormTemplate(edit_action_name, newfilefullpath, collectio
152
153
  >
153
154
  \${await super.render(ctx, data, show_field_errors)}
154
155
  </div>\`,
155
- description: ""}
156
+ description: "", css_clumps: ["admin-forms"]}
156
157
  );
157
158
  }`
158
159
  });
@@ -200,7 +200,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
200
200
  return html({
201
201
  ctx,
202
202
  title: "${action_name}",
203
- description: "",
203
+ description: "",
204
204
  body: <div class="sealious-list-wrapper ${toKebabCase(action_name)}--wrapper">
205
205
  ${hooks.pre_header_html}
206
206
  <h2>${action_name} List</h2>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.17.24",
3
+ "version": "0.17.26",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "test": "node test.cjs",
14
14
  "typecheck": "tsc --noemit",
15
15
  "build-types": "tsc --emitDeclarationOnly",
16
- "prepare": "npm run build",
16
+ "prepare": "husky",
17
17
  "lint": "eslint src",
18
18
  "preinstrument": "npm run build && rm -fr .xunit coverage lib-instrumented",
19
19
  "instrument": "npx nyc instrument --exclude \"\" lib lib-instrumented",
@@ -68,6 +68,7 @@
68
68
  "esbuild": "^0.20.0",
69
69
  "escape-goat": "^4.0.0",
70
70
  "google-fonts-helper": "^3.4.1",
71
+ "husky": "^9.1.7",
71
72
  "is-what": "^4.1.16",
72
73
  "js-convert-case": "^4.2.0",
73
74
  "json5": "^2.2.3",
@@ -44,6 +44,7 @@ describe("single-reference.test", () => {
44
44
  fields: `article: new Fields.CollectionField(true, Comments.fields.article),`,
45
45
  controls: `new Controls.SingleReferenceDropdown(fields.article, {getLabel: item=>item.get("title")}),`,
46
46
  validate_method: "",
47
+ success_message: "Submit OK",
47
48
  })
48
49
  );
49
50
 
@@ -36,16 +36,17 @@ const defaults = {
36
36
  return { canAccess: true, message: "" };
37
37
  }`,
38
38
  render: `async render(ctx: Context, data: FormData, show_field_errors: boolean) {
39
- return html({ctx, title: "Form", description: "", body: await super.render(ctx, data, show_field_errors)});
39
+ return html({ctx, title: "Form", description: "", css_clumps: ["admin-forms"], body: await super.render(ctx, data, show_field_errors)});
40
40
  }`,
41
41
  get_initial_values: "",
42
42
  other_methods: "",
43
+ success_message: "Success!",
43
44
  };
44
45
 
45
46
  export async function formTemplate(
46
47
  action_name: string,
47
48
  newfilefullpath: string,
48
- _params: Partial<typeof defaults> = defaults
49
+ _params: Partial<typeof defaults> & { success_message: string } = defaults
49
50
  ): Promise<string> {
50
51
  const params = { ...defaults, ..._params };
51
52
  const rel = curryImportPath(newfilefullpath);
@@ -28,6 +28,7 @@ export async function createItemFormTemplate(
28
28
  .filter((e) => e != "");
29
29
 
30
30
  return formTemplate(create_action_name, newfilefullpath, {
31
+ success_message: "Created!",
31
32
  postimport: `import {${toPascalCase(
32
33
  collection_name
33
34
  )}FormFields, ${toPascalCase(
@@ -115,7 +116,8 @@ export async function createItemFormTemplate(
115
116
  >
116
117
  \${await super.render(ctx, data, show_field_errors)}
117
118
  </div>\`,
118
- description: ""
119
+ description: "",
120
+ css_clumps: ["admin-forms"]
119
121
  }
120
122
  );
121
123
  }`,
@@ -25,6 +25,7 @@ export async function editItemFormTemplate(
25
25
  );
26
26
 
27
27
  return formTemplate(edit_action_name, newfilefullpath, {
28
+ success_message: "Changes saved!",
28
29
  postimport: `import {${toPascalCase(
29
30
  collection_name
30
31
  )}FormFields, ${toPascalCase(
@@ -195,7 +196,7 @@ export async function editItemFormTemplate(
195
196
  >
196
197
  \${await super.render(ctx, data, show_field_errors)}
197
198
  </div>\`,
198
- description: ""}
199
+ description: "", css_clumps: ["admin-forms"]}
199
200
  );
200
201
  }`,
201
202
  });
@@ -227,7 +227,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
227
227
  return html({
228
228
  ctx,
229
229
  title: "${action_name}",
230
- description: "",
230
+ description: "",
231
231
  body: <div class="sealious-list-wrapper ${toKebabCase(action_name)}--wrapper">
232
232
  ${hooks.pre_header_html}
233
233
  <h2>${action_name} List</h2>