Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create datamodel for subform in config #14138

Merged
merged 30 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
021f7b6
add link to datamodel --WIP
JamalAlabdullah Nov 19, 2024
a597693
Merge branch '13764-support-link-a-sub-form-to-data-model' of https:/…
lassopicasso Nov 19, 2024
63d71ec
Merge branch 'main' into 13764-support-link-a-sub-form-to-data-model
lassopicasso Nov 19, 2024
0b7bd00
display close button when create new datamodel is enabled
lassopicasso Nov 19, 2024
e2b074f
group datamodels for subform files
lassopicasso Nov 19, 2024
c01659b
use form onSubmit in StudioRecommendedNextAction
lassopicasso Nov 20, 2024
f6b174b
renaming and moving files
lassopicasso Nov 21, 2024
80202d6
Refactor SelectSubformSection
lassopicasso Nov 21, 2024
ad39290
move create subform buttons to own file
lassopicasso Nov 21, 2024
a811297
refactor createNewSubformSection
lassopicasso Nov 21, 2024
1efe572
make editLayoutset file simpler
lassopicasso Nov 21, 2024
5e5f7a7
rename folder
lassopicasso Nov 21, 2024
f193db2
update useCreateSubform
lassopicasso Nov 22, 2024
dde4aa1
Invalidate layoutsets for preview
mlqn Nov 22, 2024
169c921
Adjust createNewSubformSection and fix/update tests
lassopicasso Nov 22, 2024
67c0570
update tests in subformdataModel + rename + remove files
lassopicasso Nov 22, 2024
ff4d2e8
update tests in selectSubformSection
lassopicasso Nov 22, 2024
b5a57c4
small adjustments
lassopicasso Nov 22, 2024
d54007e
Merge branch 'main' into 13764-support-link-a-sub-form-to-data-model
lassopicasso Nov 22, 2024
6f1ee41
update useCreateSubform.test.ts
lassopicasso Nov 22, 2024
c176a36
add test to appContext.test.tsx
lassopicasso Nov 22, 2024
d2bfd49
update createNewSubformSection.test.tsx
lassopicasso Nov 22, 2024
aefe570
adjust css styles of displayDataModelButton
lassopicasso Nov 26, 2024
a7f1edb
Merge branch 'main' into 13764-support-link-a-sub-form-to-data-model
lassopicasso Nov 26, 2024
2b61835
feedback
lassopicasso Nov 27, 2024
af16678
update subformdatamodel tests
lassopicasso Nov 27, 2024
d58f85b
Merge branch 'main' into 13764-support-link-a-sub-form-to-data-model
lassopicasso Nov 27, 2024
00b372e
adjust logic to improve user journey
lassopicasso Nov 27, 2024
6d5f300
Merge branch 'main' into 13764-support-link-a-sub-form-to-data-model
Jondyr Nov 28, 2024
bb39d3a
Merge branch 'main' into 13764-support-link-a-sub-form-to-data-model
Jondyr Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1373,11 +1373,14 @@
"ux_editor.component_properties.stickyHeader": "Fest tittelraden",
"ux_editor.component_properties.style": "Stil",
"ux_editor.component_properties.subdomains": "Subdomener (kommaseparert)",
"ux_editor.component_properties.subform.choose_data_model": "Velg datamodell...",
"ux_editor.component_properties.subform.choose_layout_set": "Velg et underskjema...",
"ux_editor.component_properties.subform.choose_layout_set_description": "Velg først underskjemaet du vil bruke i Tabell for underskjema. Deretter kan du sette opp egenskapene for komponenten.",
"ux_editor.component_properties.subform.choose_layout_set_header": "Velg underskjemaet du vil bruke",
"ux_editor.component_properties.subform.choose_layout_set_label": "Velg et underskjema",
"ux_editor.component_properties.subform.create_layout_set_button": "Opprett et nytt underskjema",
"ux_editor.component_properties.subform.create_new_data_model": "Lag ny datamodell",
"ux_editor.component_properties.subform.create_new_data_model_label": "Navn på ny datamodell",
"ux_editor.component_properties.subform.created_layout_set_name": "Navn på underskjema",
"ux_editor.component_properties.subform.data_model_binding_label": "Velg datamodellknytning",
"ux_editor.component_properties.subform.data_model_empty_messsage": "Ingen tilgjengelige datamodeller",
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/shared/src/types/AppsQueryKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum AppsQueryKey {
AppLayouts = 'formLayouts',
AppLayoutSets = 'fetchLayoutSets',
AppLayoutSettings = 'layoutSettings',
AppTextResources = 'fetchTextResources',
}
15 changes: 15 additions & 0 deletions frontend/packages/ux-editor/src/AppContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ describe('AppContext', () => {
);
});

it('invalidates layout sets query for Apps in preview', async () => {
const { queryClient } = renderAppContext(({ updateLayoutSetsForPreview }: AppContextProps) => (
<Button onClick={() => updateLayoutSetsForPreview()} />
));

await clickButton();

await waitFor(async () => expect(queryClient.invalidateQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
queryKey: [AppsQueryKey.AppLayoutSets],
}),
);
});

it('invalidates layout settings query for Apps in preview', async () => {
const { queryClient } = renderAppContext(
({ updateLayoutSettingsForPreview, selectedFormLayoutSetName }: AppContextProps) => (
Expand Down
10 changes: 10 additions & 0 deletions frontend/packages/ux-editor/src/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface AppContextProps {
selectedFormLayoutName: string;
setSelectedFormLayoutName: (selectedFormLayoutName: string) => void;
updateLayoutsForPreview: (layoutSetName: string, resetQueries?: boolean) => Promise<void>;
updateLayoutSetsForPreview: (resetQueries?: boolean) => Promise<void>;
updateLayoutSettingsForPreview: (layoutSetName: string, resetQueries?: boolean) => Promise<void>;
updateTextsForPreview: (language: string, resetQueries?: boolean) => Promise<void>;
shouldReloadPreview: boolean;
Expand Down Expand Up @@ -75,6 +76,13 @@ export const AppContextProvider = ({
[refetch],
);

const updateLayoutSetsForPreview = useCallback(
async (resetQueries: boolean = false): Promise<void> => {
return await refetch([AppsQueryKey.AppLayoutSets], resetQueries);
},
[refetch],
);

const updateLayoutSettingsForPreview = useCallback(
async (layoutSetName: string, resetQueries: boolean = false): Promise<void> => {
return await refetch([AppsQueryKey.AppLayoutSettings, layoutSetName], resetQueries);
Expand All @@ -97,6 +105,7 @@ export const AppContextProvider = ({
selectedFormLayoutName,
setSelectedFormLayoutName,
updateLayoutsForPreview,
updateLayoutSetsForPreview,
updateLayoutSettingsForPreview,
updateTextsForPreview,
shouldReloadPreview,
Expand All @@ -109,6 +118,7 @@ export const AppContextProvider = ({
selectedFormLayoutName,
setSelectedFormLayoutName,
updateLayoutsForPreview,
updateLayoutSetsForPreview,
updateLayoutSettingsForPreview,
updateTextsForPreview,
shouldReloadPreview,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import classes from './CreateNewSubformButtons.module.css';
import { CheckmarkIcon, TrashIcon } from '@studio/icons';
import { StudioButton, StudioSpinner } from '@studio/components';
import { useTranslation } from 'react-i18next';

type CreateNewSubformButtonsProps = {
isPendingNewSubformMutation: boolean;
disableSaveButton: boolean;
displayCloseButton: boolean;
handleCloseButton: () => void;
};

export const CreateNewSubformButtons = ({
isPendingNewSubformMutation,
disableSaveButton,
displayCloseButton,
handleCloseButton,
}: CreateNewSubformButtonsProps) => {
const { t } = useTranslation();

const saveIcon = isPendingNewSubformMutation ? (
<StudioSpinner size='sm' spinnerTitle={t('general.loading')} />
) : (
<CheckmarkIcon />
);

return (
<div className={classes.buttonGroup}>
<StudioButton
icon={saveIcon}
type='submit'
title={t('general.save')}
disabled={disableSaveButton}
variant='secondary'
color='success'
/>
{displayCloseButton && (
<StudioButton
onClick={handleCloseButton}
title={t('general.close')}
icon={<TrashIcon />}
variant='secondary'
color='danger'
/>
)}
</div>
);
};
Loading