diff --git a/.eslintrc.js b/.eslintrc.js index ea72d4e..e222e14 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-explicit-any': 'off', 'react/prop-types': 'off', '@typescript-eslint/no-empty-interface': 'off', 'jsx-a11y/no-autofocus': 'off', diff --git a/CHANGELOG.md b/CHANGELOG.md index 42db32c..3bab40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - update translations (https://github.com/ohmyform/ui/pull/70) - show warning icon in form list if not public - default form layout is now "card" +- creating of new fields combined in new field types ### Fixed - locale scripts were missing dependency - edit user shows now email in title +- focus is now passed also do slide layout fields +- empty fields are no longer submitted ### Security diff --git a/components/form/admin/export.submission.action.tsx b/components/form/admin/export.submission.action.tsx index aa6b37a..1c3b747 100644 --- a/components/form/admin/export.submission.action.tsx +++ b/components/form/admin/export.submission.action.tsx @@ -4,6 +4,7 @@ import { useCallback, useState } from 'react' import { SubmissionFragment } from '../../../graphql/fragment/submission.fragment' import { useFormQuery } from '../../../graphql/query/form.query' import { useSubmissionPagerImperativeQuery } from '../../../graphql/query/submission.pager.query' +import { fieldTypes } from '../types' interface Props { form: string @@ -66,9 +67,9 @@ export const ExportSubmissionAction: React.FC = (props) => { data.fields.forEach((field) => { try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const decoded: { value: CellValue } = JSON.parse(field.value) - row.push(decoded.value || '') + fieldTypes[field.type]?.stringifyValue(field.value) + + row.push(fieldTypes[field.type]?.stringifyValue(field.value)) } catch (e) { row.push('') } diff --git a/components/form/admin/field.card.tsx b/components/form/admin/field.card.tsx index 11c35e8..788f0e8 100644 --- a/components/form/admin/field.card.tsx +++ b/components/form/admin/field.card.tsx @@ -6,9 +6,8 @@ import { FieldData } from 'rc-field-form/lib/interface' import React, { useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { FormFieldFragment, FormFieldLogicFragment } from '../../../graphql/fragment/form.fragment' +import { fieldTypes } from '../types' import { LogicBlock } from './logic.block' -import { adminTypes } from './types' -import { TextType } from './types/text.type' interface Props { form: FormInstance @@ -34,7 +33,7 @@ export const FieldCard: React.FC = ({ const type = form.getFieldValue([ 'form', 'fields', field.name as string, 'type', ]) as string - const TypeComponent = adminTypes[type] || TextType + const TypeComponent = (fieldTypes[type] || fieldTypes['textfield']).adminFormField() const [shouldUpdate, setShouldUpdate] = useState(false) const [nextTitle, setNextTitle] = useState( diff --git a/components/form/admin/fields.tab.tsx b/components/form/admin/fields.tab.tsx index 3ab66cd..b9d2593 100644 --- a/components/form/admin/fields.tab.tsx +++ b/components/form/admin/fields.tab.tsx @@ -7,8 +7,8 @@ import { FieldData } from 'rc-field-form/lib/interface' import React, { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { FormFieldFragment } from '../../../graphql/fragment/form.fragment' +import { fieldTypes } from '../types' import { FieldCard } from './field.card' -import { adminTypes } from './types' const logger = debug('FieldsTab') @@ -61,7 +61,7 @@ export const FieldsTab: React.FC = (props) => { }} >