Skip to content

Commit

Permalink
Add code to ux-editor-v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Standeren authored and Andrea Standeren committed Feb 2, 2024
1 parent be2ff11 commit ffd7f17
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,23 @@ export const Content = () => {
if (editId) return <TextResourceEdit />;
if (!formId || !form) return t('right_menu.content_empty');

return (
<>
{isContainer(form) ? (
<EditFormContainer
editFormId={formId}
container={form}
handleContainerUpdate={async (updatedContainer) => {
handleUpdate(updatedContainer);
debounceSave(formId, updatedContainer);
}}
/>
) : (
<EditFormComponent
editFormId={formId}
component={form}
handleComponentUpdate={async (updatedComponent) => {
handleUpdate(updatedComponent);
debounceSave(formId, updatedComponent);
}}
/>
)}
</>
return isContainer(form) ? (
<EditFormContainer
editFormId={formId}
container={form}
handleContainerUpdate={async (updatedContainer) => {
handleUpdate(updatedContainer);
debounceSave(formId, updatedContainer);
}}
/>
) : (
<EditFormComponent
editFormId={formId}
component={form}
handleComponentUpdate={async (updatedComponent) => {
handleUpdate(updatedComponent);
debounceSave(formId, updatedComponent);
}}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { EditGroupDataModelBindings } from './group/EditGroupDataModelBindings';
import { getTextResource } from '../../utils/language';
import { idExists } from '../../utils/formLayoutUtils';
import type { DatamodelFieldElement } from 'app-shared/types/DatamodelFieldElement';
import { Switch, Checkbox, LegacyFieldSet, LegacyTextField } from '@digdir/design-system-react';
import {
Alert,
Switch,
Checkbox,
LegacyFieldSet,
LegacyTextField,
Paragraph,
} from '@digdir/design-system-react';
import classes from './EditFormContainer.module.css';
import { TextResource } from '../TextResource';
import { useDatamodelMetadataQuery } from '../../hooks/queries/useDatamodelMetadataQuery';
Expand All @@ -20,6 +27,7 @@ import { FormField } from '../FormField';
import type { FormContainer } from '../../types/FormContainer';
import { useStudioUrlParams } from 'app-shared/hooks/useStudioUrlParams';
import { useAppContext } from '../../hooks/useAppContext';
import { ComponentType } from 'app-shared/types/ComponentType';

export interface IEditFormContainerProps {
editFormId: string;
Expand Down Expand Up @@ -130,7 +138,7 @@ export const EditFormContainer = ({
});
};

return (
return container.type === ComponentType.Group ? (
<LegacyFieldSet className={classes.fieldset}>
<FormField
id={container.id}
Expand Down Expand Up @@ -237,5 +245,9 @@ export const EditFormContainer = ({
</>
)}
</LegacyFieldSet>
) : (
<Alert severity='info'>
<Paragraph size='small'>{t('ux_editor.container_not_editable_info')}</Paragraph>
</Alert>
);
};

0 comments on commit ffd7f17

Please sign in to comment.