Skip to content

Commit

Permalink
feat: Add mouthbar as option for compute object. (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund authored Jun 19, 2024
1 parent 403004b commit 5894133
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/components/CaseCardComponent/FormattedMethodNames.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const titleMapping: Record<string, string> = {
Channel: 'Channel',
Mouthbar: 'Mouthbar',
Indicator: 'Indicator',
'Net-To-Gross': 'Net-to-gross',
ContiniousParameter: 'Continious parameter',
Expand Down
17 changes: 12 additions & 5 deletions src/features/Compute/CaseGroup/CaseGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ export const CaseGroup = ({
const setListItem = (methodType: string, newCase: ComputeCaseDto) => {
const filteredList = filerLocalList(methodType);

if (methodType === 'Channel' && filteredList.length < 1) {
if (
(methodType === 'Channel' || methodType === 'Mouthbar') &&
filteredList.length < 1
) {
setLocalList([...localList, newCase]);
} else if (
methodType !== 'Channel' &&
Expand Down Expand Up @@ -325,7 +328,7 @@ export const CaseGroup = ({

return (
<>
{methodName === 'Channel' && (
{(methodName === 'Channel' || methodName === 'Mouthbar') && (
<Styled.ButtonDiv>
<Styled.ButtonGroup>
<Tooltip
Expand All @@ -335,7 +338,7 @@ export const CaseGroup = ({
>
<Button
variant="outlined"
onClick={() => addCase('Channel')}
onClick={() => addCase(methodName)}
disabled={localList.length >= 1}
>
<Icon data={ADD} size={18}></Icon>
Expand All @@ -353,7 +356,7 @@ export const CaseGroup = ({
localList={localList}
>
<Styled.CaseList>
{methodName === 'Channel' ? (
{methodName === 'Channel' || methodName === 'Mouthbar' ? (
<>
{caseList.concat(localList).map((c, index) => (
<CaseRow
Expand All @@ -362,7 +365,11 @@ export const CaseGroup = ({
id={c.computeCaseId}
allCasesList={caseList.concat(localList)}
caseList={caseList}
caseType={methodName === 'Channel' ? 'Object' : 'Variogram'}
caseType={
methodName === 'Channel' || methodName === 'Mouthbar'
? 'Object'
: 'Variogram'
}
saveCase={saveCase}
deleteCase={deleteCase}
setAlertMessage={setAlertMessage}
Expand Down
13 changes: 13 additions & 0 deletions src/features/Compute/CaseGroup/CaseRow/CaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,19 @@ export const CaseRow = ({
</Styled.AutocompleteWrapper>
)}

{rowCase.computeMethod.name === 'Mouthbar' && (
<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
3 changes: 3 additions & 0 deletions src/features/Compute/CaseGroup/CaseRow/hooks/useSetSaved.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const useSetSaved = (
if (r.computeCaseId === id && r.computeMethod.name === 'Channel') {
setSaved(false);
}
if (r.computeCaseId === id && r.computeMethod.name === 'Mouthbar') {
setSaved(false);
}
}

allCasesList
Expand Down
17 changes: 13 additions & 4 deletions src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,26 @@ export const ComputeObject = () => {
(method) => method.computeMethod.name === 'Channel',
);

// const mouthbar = data?.data.filter(
// (method) => method.computeMethod.name === 'Mouthbar',
// )
const mouthbar = data?.data.filter(
(method) => method.computeMethod.name === 'Mouthbar',
);

return (
<>
<Styled.Case>
<ComputeHeader caseInfo={ObjectCaseInfo} />
<CaseGroup
caseList={channel !== undefined && channel.length > 0 ? channel : []}
methodName={ObjectCaseInfo.type}
methodName="Channel"
setAlertMessage={setAlertMessage}
runCase={runComputeObject}
/>

<CaseGroup
caseList={
mouthbar !== undefined && mouthbar.length > 0 ? mouthbar : []
}
methodName="Mouthbar"
setAlertMessage={setAlertMessage}
runCase={runComputeObject}
/>
Expand Down

0 comments on commit 5894133

Please sign in to comment.