Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22424610
form.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
form.ts
View Options
import
{
curryImportPath
}
from
"../utils/import-path"
;
export
async
function
formTemplate
(
action_name
:
string
,
newfilefullpath
:
string
)
:
Promise
<
string
>
{
const
rel
=
curryImportPath
(
newfilefullpath
);
return
`import { BaseContext } from "koa";
import {Users} from "
${
rel
(
"src/back/collections/collections"
)
}
";
import { FormHeader, SimpleInput } from "
${
rel
(
"src/back/forms/controls"
)
}
";
import { FormField } from "
${
rel
(
"src/back/forms/field"
)
}
";
import Form, { FormData } from "
${
rel
(
"src/back/forms/form"
)
}
";
import { collectionFieldValidator } from "
${
rel
(
"src/back/forms/validator"
)
}
";
import html from "
${
rel
(
"src/back/html"
)
}
";
export const actionName = "
${
action_name
}
";
export default new(class
${
action_name
}
Form extends Form {
defaultSuccessMessage = "Pomyślnie utworzono użytkownika";
fields = [new FormField("email", true, collectionFieldValidator(Users.fields.email))];
controls = [
new FormHeader("Enter your email address"),
new SimpleInput("email", { label: "Your email", type: "email" }),
];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async canAccess(_: BaseContext) {
return { canAccess: true, message: "" };
}
async onSubmit(ctx: BaseContext, values: Record<"email", string>) {
await ctx.$app.collections.users.create(ctx.$context, {
username: values.email,
...values,
});
}
async render(ctx: BaseContext, data: FormData, path: string) {
return html(ctx, "
${
action_name
}
", await super.render(ctx, data, path));
}
})();
`
;
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, Nov 28, 04:06 (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1222568
Default Alt Text
form.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline