Skip to content

Commit

Permalink
fix: should be possible to not select accessRight
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal committed Jan 22, 2025
1 parent c7fadad commit a691f5a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { AccessRightsUriTable } from './access-rights-uri-table';
import styles from '../../dataset-form.module.css';

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 },
{ value: '', label: localization.accessRight.none },
{ value: AccessRights.PUBLIC, label: localization.accessRight.public },
{ value: AccessRights.RESTRICTED, label: localization.accessRight.restricted },
{ value: AccessRights.NON_PUBLIC, label: localization.accessRight.nonPublic },
];

export const AccessRightFields = () => {
Expand All @@ -34,7 +35,7 @@ export const AccessRightFields = () => {
<Combobox
id='accessRights.uri-combobox'
size='sm'
value={[values.accessRights?.uri || AccessRights.PUBLIC]}
value={[values?.accessRights?.uri || '']}
onValueChange={(values) => setFieldValue('accessRights.uri', values.toString())}
virtual
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export const DistributionDetails = ({ distribution, searchEnv, referenceDataEnv,
size='2xs'
>{`${localization.datasetForm.fieldLabel.mediaType}:`}</Heading>
<ul className={styles.list}>
{distribution?.mediaType?.map((uri, index) => (
<li key={`mediatype-${uri}-${index}`}>
{distribution?.mediaType?.map((uri) => (
<li key={`mediatype-${uri}`}>
<Tag
size='sm'
color='info'
Expand Down Expand Up @@ -88,20 +88,18 @@ export const DistributionDetails = ({ distribution, searchEnv, referenceDataEnv,
</Table.Head>
<Table.Body>
{distribution.accessServiceUris &&
distribution.accessServiceUris.map((uri, i) => {
distribution.accessServiceUris.map((uri) => {
const match = selectedDataServices?.find((type) => type.uri === uri);
return match ? (
<Table.Row key={`accessSerivce-row-${i}`}>
<Table.Row key={`accessSerivce-row-${uri}`}>
<Table.Cell>
<Link href={getDataNorgeUri(match.id, 'data-services')}>
{getTranslateText(match?.title, language) || localization.noTitleAvailable}
</Link>
</Table.Cell>
<Table.Cell>{getTranslateText(match?.organization?.prefLabel)}</Table.Cell>
</Table.Row>
) : (
<></>
);
) : null;
})}
</Table.Body>
</Table>
Expand Down Expand Up @@ -140,8 +138,8 @@ export const DistributionDetails = ({ distribution, searchEnv, referenceDataEnv,
</Table.Row>
</Table.Head>
<TableBody>
{distribution?.conformsTo.map((conform, index) => (
<Table.Row key={`conformsTo-${index}-${conform.uri}`}>
{distribution?.conformsTo.map((conform) => (
<Table.Row key={`conformsTo-${conform.uri}`}>
<Table.Cell>{getTranslateText(conform.prefLabel, language)}</Table.Cell>
<Table.Cell>{conform.uri}</Table.Cell>
</Table.Row>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Dataset, DataTheme, LosTheme, Option } from '@catalog-frontend/types';
import { LabelWithHelpTextAndTag } from '@catalog-frontend/ui';
import { Combobox } from '@digdir/designsystemet-react';
import { Combobox, Fieldset } from '@digdir/designsystemet-react';
import { getTranslateText, localization } from '@catalog-frontend/utils';
import { FastField, useFormikContext } from 'formik';
import styles from '../dataset-form.module.css';

type Props = {
losThemes: LosTheme[];
Expand All @@ -18,16 +17,18 @@ export const ThemeSection = ({ losThemes, euDataThemes }: Props) => {

return (
<>
<div className={styles.fieldContainer}>
<LabelWithHelpTextAndTag
tagTitle={localization.tag.required}
helpAriaLabel={localization.datasetForm.fieldLabel.euDataTheme}
helpText={localization.datasetForm.helptext.euDataTheme}
fieldId='euDataTheme-combobox'
>
{localization.datasetForm.fieldLabel.euDataTheme}
</LabelWithHelpTextAndTag>

<Fieldset
legend={
<LabelWithHelpTextAndTag
tagTitle={localization.tag.required}
helpAriaLabel={localization.datasetForm.fieldLabel.euDataTheme}
helpText={localization.datasetForm.helptext.euDataTheme}
fieldId='euDataTheme-combobox'
>
{localization.datasetForm.fieldLabel.euDataTheme}
</LabelWithHelpTextAndTag>
}
>
<FastField
id='euDataTheme-combobox'
as={Combobox}
Expand All @@ -38,7 +39,7 @@ export const ThemeSection = ({ losThemes, euDataThemes }: Props) => {
value={values.euDataTheme}
onValueChange={(values: string[]) => setFieldValue('euDataTheme', values)}
size='sm'
virtual
portal={false}
>
<Combobox.Empty>{localization.search.noHits}</Combobox.Empty>
{euDataThemes &&
Expand All @@ -51,16 +52,19 @@ export const ThemeSection = ({ losThemes, euDataThemes }: Props) => {
</Combobox.Option>
))}
</FastField>
</div>
<div className={styles.fieldContainer}>
<LabelWithHelpTextAndTag
helpAriaLabel={localization.datasetForm.fieldLabel.losTheme}
helpText={localization.datasetForm.helptext.losTheme}
fieldId='losTheme-combobox'
>
{localization.datasetForm.fieldLabel.losTheme}
</LabelWithHelpTextAndTag>
</Fieldset>

<Fieldset
legend={
<LabelWithHelpTextAndTag
helpAriaLabel={localization.datasetForm.fieldLabel.losTheme}
helpText={localization.datasetForm.helptext.losTheme}
fieldId='losTheme-combobox'
>
{localization.datasetForm.fieldLabel.losTheme}
</LabelWithHelpTextAndTag>
}
>
<FastField
id='losTheme-combobox'
as={Combobox}
Expand All @@ -70,7 +74,6 @@ export const ThemeSection = ({ losThemes, euDataThemes }: Props) => {
placeholder={`${localization.search.search}...`}
onValueChange={(values: string[]) => setFieldValue('losTheme', values)}
size='sm'
virtual
>
<Combobox.Empty>{localization.search.noHits}</Combobox.Empty>
{losThemes?.map((theme) => (
Expand All @@ -82,7 +85,7 @@ export const ThemeSection = ({ losThemes, euDataThemes }: Props) => {
</Combobox.Option>
))}
</FastField>
</div>
</Fieldset>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const datasetToBeCreatedTemplate = (): DatasetToBeCreated => {
losTheme: [],
type: undefined,
keywordList: { nb: [] },
keyword: [{ nb: '' }],
conceptList: [],
provenance: undefined,
accrualPeriodicity: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export const AccessRightsDetails = ({ dataset }: Props) => {

const accessRightsOptions = useMemo(
() => [
{ 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 },
{ value: AccessRights.PUBLIC, label: localization.accessRight.public },
{ value: AccessRights.RESTRICTED, label: localization.accessRight.restricted },
{ value: AccessRights.NON_PUBLIC, label: localization.accessRight.nonPublic },
],
[],
);
Expand Down
5 changes: 0 additions & 5 deletions libs/utils/src/lib/language/dataset.form.nb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ export const datasetFormNb = {
informationModel: 'Informasjonsmodell',
contactPoint: 'Kontaktpunkt',
},
accessRight: {
public: 'Allmenn tilgang',
restricted: 'Betinget tilgang',
nonPublic: 'Ikke-allmenn tilgang',
},
fieldLabel: {
losTheme: 'LOS-tema(er)',
euDataTheme: 'Hovedtema(er)',
Expand Down
7 changes: 7 additions & 0 deletions libs/utils/src/lib/language/nb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,11 @@ export const nb = {
icon: {
trash: 'Søppelikon',
},

accessRight: {
public: 'Allmenn tilgang',
restricted: 'Betinget tilgang',
nonPublic: 'Ikke-allmenn tilgang',
none: 'Ingen tilgangsrettighet valgt',
},
};

0 comments on commit a691f5a

Please sign in to comment.