Add auto resolving fields
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm
2020-03-24 18:33:47 +01:00
parent 68295c148d
commit 0bfdbce908
7 changed files with 245 additions and 180 deletions

View File

@ -5,16 +5,26 @@ interface IFormConfigField {
type: "text" | "number" | "boolean" | "textarea";
label: string;
value?: string;
disabled?: boolean;
}
type IFormConfig = { [name: string]: IFormConfigField }
type IFormConfig = { [name: string]: IFormConfigField };
export default function getForm(url: string, title: string, fieldConfig: IFormConfig): (ctx: Context) => void {
let fields = Object.keys(fieldConfig).map(name => ({ name, ...fieldConfig[name] }))
export default function getForm(
url: string,
title: string,
fieldConfig: IFormConfig
): (ctx: Context) => void {
let fields = Object.keys(fieldConfig).map(name => ({
name,
...fieldConfig[name],
disabled: fieldConfig.disabled ? "disabled" : ""
}));
return ctx => ctx.body = getTemplate("forms")({
url,
title,
fields
});
}
return ctx =>
(ctx.body = getTemplate("forms")({
url,
title,
fields
}));
}