UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

70 lines (69 loc) 4.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const react_intl_1 = require("react-intl"); const useAsync_1 = __importDefault(require("react-use/esm/useAsync")); const formio_1 = require("../../components/formio"); const context_1 = require("../../context"); const groupDocumentTypeOptions = (options) => { const optionsWithGroupLabel = options.map(item => { const groupLabel = [item.backendLabel, item.catalogueLabel].filter(Boolean).join(' > '); return { groupLabel, value: item.url, label: item.description, }; }); const groups = optionsWithGroupLabel.reduce((accumulator, optionWithGroupLabel) => { const { groupLabel, value, label } = optionWithGroupLabel; if (!accumulator[groupLabel]) { accumulator[groupLabel] = []; } accumulator[groupLabel].push({ value, label }); return accumulator; }, {}); // now convert this mapping back to a list of opt groups const optGroups = Object.entries(groups).map(([groupLabel, options]) => ({ label: groupLabel, options, })); return optGroups; }; const DocumentTypeSelect = () => { const intl = (0, react_intl_1.useIntl)(); const { getDocumentTypes } = (0, react_1.useContext)(context_1.BuilderContext); const { value: options, loading, error } = (0, useAsync_1.default)(async () => await getDocumentTypes(), []); if (error) { throw error; } const tooltip = intl.formatMessage({ id: "5y8Yt4", defaultMessage: [{ type: 0, value: "Save the attachment in the Documents API with this InformatieObjectType. If unspecified, the registration plugin defaults are used." }] }); return ((0, jsx_runtime_1.jsx)(formio_1.Select, { name: "registration.informatieobjecttype", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: 'fY/8xt', defaultMessage: [{ type: 0, value: "Information object type" }] }), tooltip: tooltip, isLoading: loading, isClearable: true, options: groupDocumentTypeOptions(options || []) })); }; const SourceOrganisation = () => { const intl = (0, react_intl_1.useIntl)(); const tooltip = intl.formatMessage({ id: "yQUV3M", defaultMessage: [{ type: 0, value: "RSIN of the organization which creates the ENKELVOUDIGINFORMATIEOBJECT." }] }); return ((0, jsx_runtime_1.jsx)(formio_1.TextField, { name: "registration.bronorganisatie", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: 'nW5g1S', defaultMessage: [{ type: 0, value: "Bronorganisatie" }] }), tooltip: tooltip, inputMode: "numeric" })); }; const ConfidentialityLevelSelect = () => { const intl = (0, react_intl_1.useIntl)(); const { getConfidentialityLevels } = (0, react_1.useContext)(context_1.BuilderContext); const { value: options, loading, error, } = (0, useAsync_1.default)(async () => await getConfidentialityLevels(), []); if (error) { throw error; } const tooltip = intl.formatMessage({ id: "vlY36U", defaultMessage: [{ type: 0, value: "Indication of the level to which extent the INFORMATIEOBJECT is meant to be public." }] }); return ((0, jsx_runtime_1.jsx)(formio_1.Select, { name: "registration.docVertrouwelijkheidaanduiding", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: '6XG2pL', defaultMessage: [{ type: 0, value: "Confidentiality level" }] }), tooltip: tooltip, isLoading: loading, isClearable: true, options: options, valueProperty: "value" })); }; const Title = () => { const intl = (0, react_intl_1.useIntl)(); const tooltip = intl.formatMessage({ id: "2mgmOj", defaultMessage: [{ type: 0, value: "The title for the document that is related to the case." }] }); return ((0, jsx_runtime_1.jsx)(formio_1.TextField, { name: "registration.titel", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: 'SEu4I2', defaultMessage: [{ type: 0, value: "Title" }] }), tooltip: tooltip })); }; const RegistrationTabFields = () => { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DocumentTypeSelect, {}), (0, jsx_runtime_1.jsx)(SourceOrganisation, {}), (0, jsx_runtime_1.jsx)(ConfidentialityLevelSelect, {}), (0, jsx_runtime_1.jsx)(Title, {})] })); }; exports.default = RegistrationTabFields;