@sealcode/sealgen 0.17.25 → 0.17.27
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/@types/src/components/toggle-modal.d.ts +1 -1
- package/@types/src/forms/controls/checkboxed-list-input.d.ts +1 -1
- package/@types/src/forms/controls/collapsible-field-group.d.ts +1 -1
- package/@types/src/forms/controls/derived-frame.d.ts +1 -1
- package/@types/src/forms/controls/multiple-files.d.ts +1 -1
- package/@types/src/templates/form.d.ts +4 -1
- package/lib/forms/controls/single-reference.test.js +2 -1
- package/lib/templates/form.js +2 -1
- package/lib/templates/shared/collection-create-form.js +1 -0
- package/lib/templates/shared/collection-edit-form.js +1 -0
- package/lib/utils/input-wrapper.js +1 -1
- package/package.json +2 -2
- package/src/forms/controls/single-reference.test.ts +1 -0
- package/src/templates/form.ts +2 -1
- package/src/templates/shared/collection-create-form.ts +1 -0
- package/src/templates/shared/collection-edit-form.ts +1 -0
- package/src/utils/input-wrapper.ts +1 -1
|
@@ -3,4 +3,4 @@ export declare function toggleModal(options: {
|
|
|
3
3
|
name: string;
|
|
4
4
|
contentWrapped: (id: string) => FlatTemplatable | Promise<FlatTemplatable>;
|
|
5
5
|
contentUnwrapped: (id: string) => FlatTemplatable | Promise<FlatTemplatable>;
|
|
6
|
-
}): Promise<string>;
|
|
6
|
+
}): string | Promise<string>;
|
|
@@ -14,7 +14,7 @@ export declare class CollapsibleFieldGroup extends FieldGroup {
|
|
|
14
14
|
options: CollapsibleFieldGroupOptions;
|
|
15
15
|
collapseID: string;
|
|
16
16
|
constructor(controls: FormControl[], options?: CollapsibleFieldGroupOptions);
|
|
17
|
-
getGroupLabelProps(): Promise<string>;
|
|
17
|
+
getGroupLabelProps(): string | Promise<string>;
|
|
18
18
|
preLabelContainer(): FlatTemplatable;
|
|
19
19
|
postLabel(): FlatTemplatable;
|
|
20
20
|
}
|
|
@@ -16,6 +16,6 @@ export declare class DerivedFrame extends Derived<{
|
|
|
16
16
|
generateFrameContent: (ctx: FormControlContext, args: ParsedUrlQuery) => Promise<FlatTemplatable>;
|
|
17
17
|
frame_id: string;
|
|
18
18
|
constructor(frame_name: string, fields: FormField[], generateFrameContent: (ctx: FormControlContext, args: ParsedUrlQuery) => Promise<FlatTemplatable>, frame_id?: string);
|
|
19
|
-
renderBackendResponseFrame(_ctx: Context, content: FlatTemplatable): Promise<string>;
|
|
19
|
+
renderBackendResponseFrame(_ctx: Context, content: FlatTemplatable): string | Promise<string>;
|
|
20
20
|
mount(router: Router): void;
|
|
21
21
|
}
|
|
@@ -22,7 +22,7 @@ export declare class MultipleFiles extends FormFieldControl {
|
|
|
22
22
|
addFileAssociation(ctx: Context, file: FilePointer): Promise<void>;
|
|
23
23
|
getFrameRelativeURL(): string;
|
|
24
24
|
getFrameID(): string;
|
|
25
|
-
renderFrame(_ctx: Context, content?: FlatTemplatable): Promise<string>;
|
|
25
|
+
renderFrame(_ctx: Context, content?: FlatTemplatable): string | Promise<string>;
|
|
26
26
|
render(fctx: FormControlContext): FlatTemplatable | Promise<FlatTemplatable>;
|
|
27
27
|
getReferencingCollection(): Collection;
|
|
28
28
|
getFileField(): SealiousField<any> | null;
|
|
@@ -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>
|
|
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();
|
package/lib/templates/form.js
CHANGED
|
@@ -38,7 +38,8 @@ const defaults = {
|
|
|
38
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(
|
|
@@ -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(
|
|
@@ -5,7 +5,7 @@ function getRequiredClass(isRequired) {
|
|
|
5
5
|
function getModifierClasses(modifiers) {
|
|
6
6
|
return modifiers.map((m) => "form-input__wrapper--" + m).join(" ");
|
|
7
7
|
}
|
|
8
|
-
function inputWrapper(type, modifiers, input) {
|
|
8
|
+
async function inputWrapper(type, modifiers, input) {
|
|
9
9
|
return tempstream`<div
|
|
10
10
|
class="form-input form-input--type-${type} form-input__wrapper ${getModifierClasses(
|
|
11
11
|
modifiers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/sealgen",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.27",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"prompts": "^2.4.2",
|
|
80
80
|
"recursive-readdir": "^2.2.3",
|
|
81
81
|
"tempfile": "^5.0.0",
|
|
82
|
-
"tempstream": "^0.4.
|
|
82
|
+
"tempstream": "^0.4.6",
|
|
83
83
|
"tiny-glob": "^0.2.9",
|
|
84
84
|
"ws": "^8.16.0",
|
|
85
85
|
"yargs": "^17.6.2"
|
|
@@ -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
|
|
package/src/templates/form.ts
CHANGED
|
@@ -40,12 +40,13 @@ const defaults = {
|
|
|
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(
|
|
@@ -8,7 +8,7 @@ function getModifierClasses(modifiers: string[]) {
|
|
|
8
8
|
return modifiers.map((m) => "form-input__wrapper--" + m).join(" ");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function inputWrapper(
|
|
11
|
+
export async function inputWrapper(
|
|
12
12
|
type: string,
|
|
13
13
|
modifiers: string[],
|
|
14
14
|
input: FlatTemplatable
|