Skip to content

Commit

Permalink
Fix MultiEnsembleSelect component and update usage (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenherje authored Sep 5, 2023
1 parent 9c0cf06 commit 9c75b4d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export function MultiEnsembleSelect(props: MultiEnsembleSelectProps): JSX.Elemen
selectedArr.push(ident.toString());
}

return <Select options={optionsArr} value={selectedArr} onChange={handleSelectionChanged} {...rest} />;
return (
<Select options={optionsArr} value={selectedArr} onChange={handleSelectionChanged} multiple={true} {...rest} />
);
}
12 changes: 5 additions & 7 deletions frontend/src/modules/SimulationTimeSeries/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EnsembleIdent } from "@framework/EnsembleIdent";
import { ModuleFCProps } from "@framework/Module";
import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings";
import { useEnsembleSet } from "@framework/WorkbenchSession";
import { MultiEnsembleSelect } from "@framework/components/MultiEnsembleSelect";
import { SingleEnsembleSelect } from "@framework/components/SingleEnsembleSelect";
import { fixupEnsembleIdent, maybeAssignFirstSyncedEnsemble } from "@framework/utils/ensembleUiHelpers";
import { ApiStateWrapper } from "@lib/components/ApiStateWrapper";
import { Checkbox } from "@lib/components/Checkbox";
Expand Down Expand Up @@ -82,9 +82,8 @@ export function settings({ moduleContext, workbenchSession, workbenchServices }:

const computedEnsemble = computedEnsembleIdent ? ensembleSet.findEnsemble(computedEnsembleIdent) : null;

function handleEnsembleSelectionChange(ensembleIdentArr: EnsembleIdent[]) {
console.debug("handleEnsembleSelectionChange()", ensembleIdentArr);
const newEnsembleIdent = ensembleIdentArr[0] ?? null;
function handleEnsembleSelectionChange(newEnsembleIdent: EnsembleIdent | null) {
console.debug("handleEnsembleSelectionChange()", newEnsembleIdent);
setSelectedEnsembleIdent(newEnsembleIdent);
if (newEnsembleIdent) {
syncHelper.publishValue(SyncSettingKey.ENSEMBLE, "global.syncValue.ensembles", [newEnsembleIdent]);
Expand Down Expand Up @@ -139,11 +138,10 @@ export function settings({ moduleContext, workbenchSession, workbenchServices }:
text="Ensemble"
labelClassName={syncHelper.isSynced(SyncSettingKey.ENSEMBLE) ? "bg-indigo-700 text-white" : ""}
>
<MultiEnsembleSelect
<SingleEnsembleSelect
ensembleSet={ensembleSet}
value={computedEnsembleIdent ? [computedEnsembleIdent] : []}
value={computedEnsembleIdent}
onChange={handleEnsembleSelectionChange}
size={5}
/>
</Label>
<ApiStateWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EnsembleIdent } from "@framework/EnsembleIdent";
import { ModuleFCProps } from "@framework/Module";
import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings";
import { useEnsembleSet } from "@framework/WorkbenchSession";
import { MultiEnsembleSelect } from "@framework/components/MultiEnsembleSelect";
import { SingleEnsembleSelect } from "@framework/components/SingleEnsembleSelect";
import { fixupEnsembleIdent, maybeAssignFirstSyncedEnsemble } from "@framework/utils/ensembleUiHelpers";
import { ApiStateWrapper } from "@lib/components/ApiStateWrapper";
import { Checkbox } from "@lib/components/Checkbox";
Expand Down Expand Up @@ -83,9 +83,8 @@ export function settings({ moduleContext, workbenchSession, workbenchServices }:
[computedEnsembleIdent, computedVectorName]
);

function handleEnsembleSelectionChange(ensembleIdentArr: EnsembleIdent[]) {
console.debug("handleEnsembleSelectionChange()", ensembleIdentArr);
const newEnsembleIdent = ensembleIdentArr[0] ?? null;
function handleEnsembleSelectionChange(newEnsembleIdent: EnsembleIdent | null) {
console.debug("handleEnsembleSelectionChange()", newEnsembleIdent);
setSelectedEnsembleIdent(newEnsembleIdent);
if (newEnsembleIdent) {
syncHelper.publishValue(SyncSettingKey.ENSEMBLE, "global.syncValue.ensembles", [newEnsembleIdent]);
Expand Down Expand Up @@ -117,11 +116,10 @@ export function settings({ moduleContext, workbenchSession, workbenchServices }:
return (
<>
<Label text="Ensemble" synced={syncHelper.isSynced(SyncSettingKey.ENSEMBLE)}>
<MultiEnsembleSelect
<SingleEnsembleSelect
ensembleSet={ensembleSet}
value={computedEnsembleIdent ? [computedEnsembleIdent] : []}
value={computedEnsembleIdent}
onChange={handleEnsembleSelectionChange}
size={5}
/>
</Label>
<ApiStateWrapper
Expand Down

0 comments on commit 9c75b4d

Please sign in to comment.