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

Chore/user test improvements #316

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Autocomplete, AutocompleteChanges } from '@equinor/eds-core-react';
import { GeologicalStandardDto } from '../../../api/generated';
import { useFetchGrossDepData } from '../../../hooks/useFetchGrossDepData';
import * as StyledDialog from '../../../styles/addRowDialog/AddRowDialog.styled';
import { GdeType } from '../GrossDepositionEnviromentGroup/GrossDepositionEnviromentGroup';

export const GdeSelect = ({
Expand Down Expand Up @@ -38,7 +39,7 @@ export const GdeSelect = ({
);

return (
<div>
<StyledDialog.AutocompleteList>
<Autocomplete
label="Gross Depositional Environment (GDE)"
options={Gde}
Expand Down Expand Up @@ -93,6 +94,6 @@ export const GdeSelect = ({
}}
noOptionsText="No options"
/>
</div>
</StyledDialog.AutocompleteList>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
GeologicalStandardDto,
} from '../../../api/generated';
import { queryClient } from '../../../auth/queryClient';
import * as StyledDialog from '../../../styles/addRowDialog/AddRowDialog.styled';
import { GdeSelect } from '../GdeSelect/GdeSelect';
import * as Styled from './GrossDepositionEnviromentGroup.styled';

Expand Down Expand Up @@ -160,18 +161,18 @@ export const GrossDepositionEnviromentGroup = ({
</div>
</Styled.Wrapper>

<Dialog open={showGdeDialog}>
<StyledDialog.DialogWindow open={showGdeDialog}>
<Dialog.Header>Add Gross Deposition Enviroment</Dialog.Header>
<Dialog.CustomContent>
<GdeSelect gdeObject={gdeObject} setGdeObject={setGdeObject} />
</Dialog.CustomContent>
<Dialog.Actions>
<StyledDialog.Actions>
<Button onClick={handleAddGde}>Add</Button>
<Button variant="outlined" onClick={handleGdeDialog}>
Close
</Button>
</Dialog.Actions>
</Dialog>
</StyledDialog.Actions>
</StyledDialog.DialogWindow>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
OutcropDto,
} from '../../../api/generated';
import { useOutcropAnalouge } from '../../../hooks/useOutcropAnalogue';
import * as StyledDialog from '../../../styles/addRowDialog/AddRowDialog.styled';
import { OutcropSelect } from '../OutcropSelect/OutcropSelect';
import * as Styled from './OutcropAnalogueGroup.styled';

Expand Down Expand Up @@ -131,7 +132,7 @@ export const OutcropAnalogueGroup = ({
</Button>
</div>
</Styled.Wrapper>
<Dialog open={showOutcropDialog}>
<StyledDialog.DialogWindow open={showOutcropDialog}>
<Dialog.Header>Add Outcrop Analogue</Dialog.Header>
<Dialog.CustomContent>
<OutcropSelect
Expand All @@ -140,13 +141,13 @@ export const OutcropAnalogueGroup = ({
setOutcropObject={setOutcropObject}
/>
</Dialog.CustomContent>
<Dialog.Actions>
<StyledDialog.Actions>
<Button onClick={handleAddOutcropAnalogue}>Add</Button>
<Button variant="outlined" onClick={handleOutcropDialog}>
Close
</Button>
</Dialog.Actions>
</Dialog>
</StyledDialog.Actions>
</StyledDialog.DialogWindow>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Autocomplete, AutocompleteChanges } from '@equinor/eds-core-react';
import { OutcropDto } from '../../../api/generated';
import { useFetchOutcropData } from '../../../hooks/useFetchOutcropData';
import * as StyledDialog from '../../../styles/addRowDialog/AddRowDialog.styled';
import { OutcropType } from '../OutcropAnalogueGroup/OutcropAnalogueGroup';

export const OutcropSelect = ({
Expand All @@ -25,7 +26,7 @@ export const OutcropSelect = ({
};

return (
<div>
<StyledDialog.AutocompleteList>
<Autocomplete
label="Analogue"
options={OutcropData.data.data}
Expand Down Expand Up @@ -95,6 +96,6 @@ export const OutcropSelect = ({
noOptionsText="No options"
readOnly
/>
</div>
</StyledDialog.AutocompleteList>
);
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useFetchSmdaMetadataStratigraphicUnits,
useFetchSmdaStratigraphicColumns,
} from '../../../hooks/useFetchStratColData';
import * as Styled from './StratigraphicColumnSelect.styled';
import * as StyledDialog from '../../../styles/addRowDialog/AddRowDialog.styled';

export const StratigraphicColumnSelect = ({
stratColumnObject,
Expand All @@ -39,11 +39,31 @@ export const StratigraphicColumnSelect = ({
)
return <p>Loading ...</p>;

const hasFields = (id: string) => {
const res = fieldData.data.data.filter((f) => f.countryId === id);
return res;
};

const hasStratCol = (id: string) => {
const StratColContryList = stratColumnData.data.data.map((col) =>
col.countries.filter((c) => c.countryId === id),
);
const res = StratColContryList.filter((col) => col.length > 0);
return res;
};

const filterCountries = countryData.data.data.filter(
(c) =>
hasStratCol(c.countryId).length > 0 || hasFields(c.countryId).length > 0,
);

return (
<Styled.AutocompleteList>
<StyledDialog.AutocompleteList>
<Autocomplete
label="Country"
options={countryData.data.data}
options={filterCountries.sort((a, b) =>
a.identifier.localeCompare(b.identifier),
)}
optionLabel={(option) => option.identifier}
onOptionsChange={(e: AutocompleteChanges<CountryDto>) => {
setStratColumnObject({
Expand Down Expand Up @@ -181,6 +201,6 @@ export const StratigraphicColumnSelect = ({
}
noOptionsText="No options"
/>
</Styled.AutocompleteList>
</StyledDialog.AutocompleteList>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Dialog } from '@equinor/eds-core-react';
import styled from 'styled-components';
import { spacings } from '../../../tokens/spacings';

Expand Down Expand Up @@ -26,8 +25,3 @@ export const MetadataInfo = styled.div`

max-width: 60%;
`;

export const Actions = styled(Dialog.Actions)`
display: flex;
column-gap: ${spacings.SMALL};
`;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { OutcropAnalogueGroup } from '../../../components/OutcropAnalogue/Outcro
import { StratigraphicColumnSelect } from '../../../components/StrategraphicColumn/StratigraphicColumnSelect/StratigraphicColumnSelect';
import { StratigrapicGroups } from '../../../components/StrategraphicColumn/StratigrapicGroups/StratigrapicGroups';
import { useFetchModel } from '../../../hooks/useFetchModel';
import * as StyledDialog from '../../../styles/addRowDialog/AddRowDialog.styled';
import { StratColumnType } from '../../HandleModel/HandleModelComponent/HandleModelComponent';
import { EditNameDescription } from '../EditNameDescription/EditNameDescription';
import * as Styled from './ModelMetadataView.styled';
Expand Down Expand Up @@ -330,21 +331,21 @@ export const ModelMetadataView = ({
</div>
</Styled.Metadata>

<Dialog open={showStratColDialog}>
<StyledDialog.DialogWindow open={showStratColDialog}>
<Dialog.Header>Add stratigraphic column</Dialog.Header>
<Dialog.CustomContent>
<StratigraphicColumnSelect
stratColumnObject={stratColumnObject}
setStratColumnObject={setStratColumnObject}
/>
</Dialog.CustomContent>
<Styled.Actions>
<StyledDialog.Actions>
<Button onClick={handleAddStratCol}>Add</Button>
<Button variant="outlined" onClick={handleStratColDialog}>
Close
</Button>
</Styled.Actions>
</Dialog>
</StyledDialog.Actions>
</StyledDialog.DialogWindow>
</Styled.Wrapper>
);
};
19 changes: 19 additions & 0 deletions src/styles/addRowDialog/AddRowDialog.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Dialog } from '@equinor/eds-core-react';
import styled from 'styled-components';
import { spacings } from '../../tokens/spacings';

export const Actions = styled(Dialog.Actions)`
display: flex;
column-gap: ${spacings.SMALL};
`;

export const DialogWindow = styled(Dialog)`
min-width: 400px;
`;

export const AutocompleteList = styled.div`
display: flex;
flex-direction: column;

row-gap: ${spacings.MEDIUM};
`;