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/view selected settings #206

Merged
merged 2 commits into from
Jan 24, 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 @@ -6,5 +6,6 @@ export const ButtonDiv = styled.div`
flex: row;
flex-direction: row;
column-gap: ${spacings.SMALL};
align-items: end;
align-items: start;
padding-top: ${spacings.MEDIUM};
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@ export const Case = styled.div`
flex-direction: column;

padding: ${spacings.MEDIUM};
column-gap: ${spacings.MEDIUM};

border-bottom: solid thin ${theme.light.ui.background.medium};
background-color: ${theme.light.ui.background.default};
border-radius: ${spacings.CARD_ROUNDED};

&.local-case {
border: solid lightgreen;
}
`;

export const CaseRow = styled.div`
&.Object {
align-items: center;
}
display: flex;
flex-direction: row;
column-gap: ${spacings.MEDIUM};
`;

export const AutocompleteWrapper = styled.div`
display: flex;
flex: auto;
flex-direction: row;
column-gap: ${spacings.MEDIUM};
`;
27 changes: 16 additions & 11 deletions src/features/Compute/CaseGroup/CaseRow/CaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useFetchModel } from '../../../../hooks/useFetchModel';
import { CaseButtons } from '../CaseButtons/CaseButtons';
import { ModelAreaSelect } from '../CaseSettingSelects/ModelAreaSelect';
import { VariogramOptionSelect } from '../CaseSettingSelects/VariogramSettingSelect';
import { VariogramOptionSelect } from '../VariogramSettingSelect/VariogramSettingSelect';
import * as Styled from './CaseRow.Styled';

export const CaseRow = ({
Expand Down Expand Up @@ -409,8 +409,10 @@ export const CaseRow = ({
}, [caseList, allCasesList, saved]);

return (
<Styled.Case>
<Styled.CaseRow>
<Styled.Case className={id.length <= 3 ? 'local-case' : ''}>
<Styled.CaseRow
className={caseType === 'Object' ? 'Object' : 'Variogram'}
>
{rowCase.computeMethod.name === 'Indicator' && (
<VariogramOptionSelect
rowCase={rowCase}
Expand Down Expand Up @@ -475,15 +477,18 @@ export const CaseRow = ({
)}

{rowCase.computeMethod.name === 'Channel' && (
<ModelAreaSelect
disableSelect={saved}
modelAreas={areaList ? areaList : []}
selectedModelArea={selectedRowArea(rowCase.computeCaseId)}
setModelArea={setModelArea}
existingCases={caseList}
caseError={caseError}
/>
<Styled.AutocompleteWrapper>
<ModelAreaSelect
disableSelect={saved}
modelAreas={areaList ? areaList : []}
selectedModelArea={selectedRowArea(rowCase.computeCaseId)}
setModelArea={setModelArea}
existingCases={caseList}
caseError={caseError}
/>
</Styled.AutocompleteWrapper>
)}

<CaseButtons
id={id}
caseType={caseType === 'Object' ? 'Object' : 'Variogram'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,44 @@ export const ModelAreaSelect = ({
};

return (
<Styled.AutocompleteWrapper>
<Styled.AutocompleteRow>
<Styled.Required>
<Autocomplete
label="Model area"
readOnly={disableSelect}
options={modelAreas && modelAreas.length > 0 ? modelAreas : []}
selectedOptions={
selectedModelArea &&
selectedModelArea.length > 0 &&
selectedModelArea[0].modelAreaId !== ''
? selectedModelArea
: selectedModelArea &&
selectedModelArea.length > 0 &&
selectedModelArea[0].modelAreaType === 'Whole model'
? [
{
modelAreaId: '',
modelAreaType: 'Whole model',
coordinates: [],
},
]
: [
{
modelAreaId: '',
modelAreaType: '',
coordinates: [],
},
]
}
optionLabel={(modelArea) => modelArea.modelAreaType}
onOptionsChange={(changes: AutocompleteChanges<ModelAreaDto>) =>
setModelArea && setModelArea(changes.selectedItems)
}
optionDisabled={!caseType ? filterDisabled : undefined}
variant={caseError.length > 0 ? 'error' : undefined}
/>
{caseError.length > 0 && <Label label={caseError}></Label>}
</Styled.Required>
</Styled.AutocompleteRow>
</Styled.AutocompleteWrapper>
<Styled.AutocompleteRow>
<Styled.Required>
<Autocomplete
label="Model area"
readOnly={disableSelect}
options={modelAreas && modelAreas.length > 0 ? modelAreas : []}
selectedOptions={
selectedModelArea &&
selectedModelArea.length > 0 &&
selectedModelArea[0].modelAreaId !== ''
? selectedModelArea
: selectedModelArea &&
selectedModelArea.length > 0 &&
selectedModelArea[0].modelAreaType === 'Whole model'
? [
{
modelAreaId: '',
modelAreaType: 'Whole model',
coordinates: [],
},
]
: [
{
modelAreaId: '',
modelAreaType: '',
coordinates: [],
},
]
}
optionLabel={(modelArea) => modelArea.modelAreaType}
onOptionsChange={(changes: AutocompleteChanges<ModelAreaDto>) =>
setModelArea && setModelArea(changes.selectedItems)
}
optionDisabled={!caseType ? filterDisabled : undefined}
variant={caseError.length > 0 ? 'error' : undefined}
/>
{caseError.length > 0 && <Label label={caseError}></Label>}
</Styled.Required>
</Styled.AutocompleteRow>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const AutocompleteWrapper = styled.div`
display: flex;
flex: auto;
flex-direction: row;
align-items: top;

column-gap: ${spacings.MEDIUM};
`;
Expand All @@ -25,3 +26,8 @@ export const AutocompleteRow = styled.div`
flex-grow: 1;
}
`;

export const ButtonWrapper = styled.div`
display: flex;
align-items: center;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from 'styled-components';
import { spacings } from '../../../../tokens/spacings';

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

export const SettingsContainer = styled.div`
padding-top: ${spacings.SMALL};
display: flex;
flex-direction: column;
row-gap: ${spacings.SMALL};
`;
Loading