Skip to content

Commit

Permalink
Allow 'panel' component
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed May 2, 2024
1 parent ec0d8c6 commit 723fe49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/admin/src/components/admin/Admin/Admin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fakeDataProvider from 'ra-data-fakerest'
import { Admin as ReactAdmin, Resource } from 'react-admin'

// import { dataProvider } from '../../dataProvider'
// import { dataProvider } from '../../../app/dataProvider'
import { CategoryCreate } from '../../category/CategoryCreate/CategoryCreate'
import { CategoryEdit } from '../../category/CategoryEdit'
import { CategoryList } from '../../category/CategoryList'
Expand Down Expand Up @@ -71,7 +71,7 @@ export const Admin = () => (
options={{ label: 'Vragenlijsten' }}
/>
<Resource
name="categories"
name="classification"
list={<CategoryList />}
edit={<CategoryEdit />}
create={<CategoryCreate />}
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/components/form/Builder/Builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type BuilderProps = {
export const Builder = ({ data, onChange }: BuilderProps) => (
<FormBuilder
onChange={onChange}
form={data ? { display: 'form', components: data } : { display: 'form' }}
form={data ? { display: 'wizard', components: data } : { display: 'wizard' }}
options={{
noDefaultSubmitButton: true,
builder: {
Expand Down
10 changes: 7 additions & 3 deletions apps/admin/src/utils/filterAttributes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { ExtendedComponentSchema } from '@formio/js'

const allowed = ['label', 'description', 'key', 'type', 'input', 'autoExpand', 'showCharCount']
const textareaAllowed = ['label', 'description', 'key', 'type', 'input', 'autoExpand', 'showCharCount']
const panelAllowed = ['label', 'key', 'type', 'input', 'components']

export const filterAttributes = (raw: ExtendedComponentSchema) =>
Object.keys(raw)
export const filterAttributes = (raw: ExtendedComponentSchema) => {
const allowed = raw.type === 'textarea' ? textareaAllowed : panelAllowed

return Object.keys(raw)
.filter((key) => allowed.includes(key))
.reduce(
(obj, key) => ({
Expand All @@ -12,3 +15,4 @@ export const filterAttributes = (raw: ExtendedComponentSchema) =>
}),
{},
)
}

0 comments on commit 723fe49

Please sign in to comment.