-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move relations to table dataset form
- Loading branch information
Showing
13 changed files
with
423 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 34 additions & 25 deletions
59
...mponents/dataset-form/components/access-rights.tsx/dataset-form-access-rights-section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
import { AccessRights, Dataset } from '@catalog-frontend/types'; | ||
import { TitleWithTag } from '@catalog-frontend/ui'; | ||
import { localization } from '@catalog-frontend/utils'; | ||
import { NativeSelect } from '@digdir/designsystemet-react'; | ||
import { Field, FormikHelpers, useFormikContext } from 'formik'; | ||
import { Card, Combobox } from '@digdir/designsystemet-react'; | ||
import { useFormikContext } from 'formik'; | ||
import { AccessRightsUriTable } from './access-rights-uri-table'; | ||
|
||
export const AccessRightsForm = () => { | ||
const { values } = useFormikContext<Dataset>(); | ||
const accessRightsOptions = [ | ||
{ value: AccessRights.PUBLIC, label: localization.datasetForm.accessRight.public }, | ||
{ value: AccessRights.RESTRICTED, label: localization.datasetForm.accessRight.restricted }, | ||
{ value: AccessRights.NON_PUBLIC, label: localization.datasetForm.accessRight.nonPublic }, | ||
]; | ||
|
||
export const AccessRightFields = () => { | ||
const { values, setFieldValue } = useFormikContext<Dataset>(); | ||
|
||
return ( | ||
<> | ||
<Field name='accessRights.uri'> | ||
{({ field, form }: { field: any; form: FormikHelpers<Dataset> }) => ( | ||
<NativeSelect | ||
{...field} | ||
label={ | ||
<TitleWithTag | ||
title={localization.access} | ||
tagColor='info' | ||
tagTitle={localization.tag.recommended} | ||
/> | ||
} | ||
> | ||
<option value={''}>{`${localization.choose}...`}</option> | ||
<option value={AccessRights.PUBLIC}>{localization.datasetForm.accessRight.public}</option> | ||
<option value={AccessRights.RESTRICTED}>{localization.datasetForm.accessRight.restricted}</option> | ||
<option value={AccessRights.NON_PUBLIC}>{localization.datasetForm.accessRight.nonPublic}</option> | ||
</NativeSelect> | ||
)} | ||
</Field> | ||
<Card> | ||
<div> | ||
<TitleWithTag | ||
title={localization.access} | ||
tagColor='info' | ||
tagTitle={localization.tag.recommended} | ||
/> | ||
<Combobox | ||
size='sm' | ||
value={[values.accessRights?.uri || AccessRights.PUBLIC]} | ||
onValueChange={(values) => setFieldValue('accessRights.uri', values.toString())} | ||
> | ||
{accessRightsOptions.map((option) => ( | ||
<Combobox.Option | ||
key={option.value} | ||
value={option.value} | ||
> | ||
{option.label} | ||
</Combobox.Option> | ||
))} | ||
</Combobox> | ||
</div> | ||
|
||
{(values.accessRights?.uri === AccessRights.RESTRICTED || | ||
values.accessRights?.uri === AccessRights.NON_PUBLIC) && <AccessRightsUriTable />} | ||
</> | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.