commit 59ae50bf0381b135eb58e838b2530a5420af9129
parent 5b86aa33f5f1d8a394f31826bf45fdc6d36ed349
Author: Florian Dold <florian@dold.me>
Date: Tue, 25 Mar 2025 02:16:50 +0100
generic forms
Diffstat:
5 files changed, 207 insertions(+), 0 deletions(-)
diff --git a/packages/web-util/src/forms/form-list.ts b/packages/web-util/src/forms/form-list.ts
diff --git a/packages/web-util/src/forms/gana/generic_note.stories.tsx b/packages/web-util/src/forms/gana/generic_note.stories.tsx
@@ -0,0 +1,34 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ *
+ * @author Sebastian Javier Marchano (sebasjm)
+ */
+
+import { i18n, setupI18n } from "@gnu-taler/taler-util";
+import * as tests from "../../tests/hook.js";
+import { DefaultForm } from "../forms-ui.js";
+import { form_generic_note } from "./generic_note.js";
+
+setupI18n("en", {});
+
+export const EmptyForm = tests.createExample(DefaultForm, {
+ initial: {},
+ design: form_generic_note(i18n),
+});
+
+export default { title: "generic_note" };
diff --git a/packages/web-util/src/forms/gana/generic_note.ts b/packages/web-util/src/forms/gana/generic_note.ts
@@ -0,0 +1,76 @@
+/*
+ This file is part of GNU Taler
+ (C) 2025 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero Public License for more details.
+
+ You should have received a copy of the GNU Affero Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+import { format } from "date-fns";
+import {
+ DoubleColumnFormDesign,
+ InternationalizationAPI,
+} from "../../index.browser.js";
+import { TalerFormAttributes } from "./taler_form_attributes.js";
+
+/**
+ * Design of the vqf_902_1_officer form.
+ */
+export function form_generic_note(
+ i18n: InternationalizationAPI,
+): DoubleColumnFormDesign {
+ const today = format(new Date(), "yyyy-MM-dd");
+
+ return {
+ type: "double-column",
+ sections: [
+ {
+ title: i18n.str`Note / Memorandum`,
+ fields: [
+ {
+ id: TalerFormAttributes.NOTE_TEXT,
+ label: i18n.str`Free-form notes`,
+ type: "textArea",
+ required: true,
+ },
+ ],
+ },
+ {
+ title: i18n.str`Supplemental File Upload`,
+ description: i18n.str`Optional supplemental information for the establishment of the business relationship with the customer.`,
+ fields: [
+ {
+ id: TalerFormAttributes.SUPPLEMENTAL_FILES_LIST,
+ label: i18n.str`Supplemental Files`,
+ type: "array",
+ labelFieldId: "FILE.FILENAME",
+ required: false,
+ fields: [
+ {
+ id: TalerFormAttributes.DESCRIPTION,
+ label: i18n.str`Description`,
+ type: "textArea",
+ required: true,
+ },
+ {
+ id: TalerFormAttributes.FILE,
+ label: i18n.str`File (PDF)`,
+ type: "file",
+ accept: "application/pdf",
+ required: true,
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+}
diff --git a/packages/web-util/src/forms/gana/generic_upload.stories.tsx b/packages/web-util/src/forms/gana/generic_upload.stories.tsx
@@ -0,0 +1,37 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ *
+ * @author Sebastian Javier Marchano (sebasjm)
+ */
+
+import { i18n, setupI18n } from "@gnu-taler/taler-util";
+import * as tests from "../../tests/hook.js";
+import { DefaultForm } from "../forms-ui.js";
+import { form_generic_upload } from "./generic_upload.js";
+
+setupI18n("en", {});
+
+export const EmptyForm = tests.createExample(DefaultForm, {
+ initial: {},
+ design: form_generic_upload(i18n, {
+ DOCUMENT_REQUEST_NAME: "Doc XYZ",
+ DOCUMENT_REQUEST_DESCRIPTION: "Please upload document XYZ",
+ }),
+});
+
+export default { title: "generic_upload" };
diff --git a/packages/web-util/src/forms/gana/generic_upload.ts b/packages/web-util/src/forms/gana/generic_upload.ts
@@ -0,0 +1,60 @@
+/*
+ This file is part of GNU Taler
+ (C) 2025 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero Public License for more details.
+
+ You should have received a copy of the GNU Affero Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+import { format } from "date-fns";
+import {
+ DoubleColumnFormDesign,
+ InternationalizationAPI,
+} from "../../index.browser.js";
+import { TalerFormAttributes } from "./taler_form_attributes.js";
+
+/**
+ * Design of the vqf_902_1_officer form.
+ */
+export function form_generic_upload(
+ i18n: InternationalizationAPI,
+ context: {
+ DOCUMENT_REQUEST_NAME: string;
+ DOCUMENT_REQUEST_DESCRIPTION: string;
+ },
+): DoubleColumnFormDesign {
+ const today = format(new Date(), "yyyy-MM-dd");
+
+ return {
+ type: "double-column",
+ sections: [
+ {
+ title: i18n.str`Document upload (${context.DOCUMENT_REQUEST_NAME})`,
+ description: i18n.str`${context.DOCUMENT_REQUEST_DESCRIPTION}`,
+ fields: [
+ {
+ id: TalerFormAttributes.FILE,
+ label: i18n.str`File (PDF)`,
+ type: "file",
+ accept: "application/pdf",
+ required: false,
+ },
+ {
+ id: TalerFormAttributes.NOTE_TEXT,
+ label: i18n.str`Free-form message`,
+ type: "textArea",
+ required: false,
+ },
+ ],
+ },
+ ],
+ };
+}