Skip to content

Commit

Permalink
Merge pull request #197 from RENCI/remove-all-model-runs
Browse files Browse the repository at this point in the history
#198 - Remove all model runs
  • Loading branch information
lstillwe authored Sep 9, 2024
2 parents 29514fa + 1cfc63b commit 2e2040f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
21 changes: 6 additions & 15 deletions src/components/trays/remove/remove-models.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
import React, { Fragment } from 'react';
import { Button } from '@mui/joy';
import {useLayers} from "@context";
import { useLayers } from "@context";

/**
* component that handles the removal of models.
* component that handles the removal of all model runs.
*
* @returns {JSX.Element}
* @constructor
*/
export const RemoveModels = () => {
// get references to the model data/list
const {

} = useLayers();

/**
* remove the observation selections from state and map
*/
function removeModels() {
alert("Not ready yet.");
}
// get the method to remove the observation items in state
const { removeAllModelRuns } = useLayers();

// render the button
return (
<Fragment>
<Button color="primary" onClick={() => removeModels()}>Remove selected models</Button>
<Button color="primary" onClick={ () => removeAllModelRuns() }>Remove all selected model runs</Button>
</Fragment>
);
);
};
15 changes: 14 additions & 1 deletion src/context/map-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,24 @@ export const LayersProvider = ({ children }) => {
layer.state = newLayerDefaultState(layer, newLayers[0].group);
});

// remove all observations when there is a model run removal
// remove all observation dialogs when there is a model run removal
removeObservations();

setDefaultModelLayers(newLayers);
};

/**
* removes all selected model runs
*/
const removeAllModelRuns = () => {

// remove all observation dialogs when removing all model runs
removeObservations();

// reset the default layers array
setDefaultModelLayers([]);
};

const newLayerDefaultState = (layer, group) => {
// if this is an obs layer and is the one just added
if (layer.group === group &&
Expand Down Expand Up @@ -246,6 +258,7 @@ export const LayersProvider = ({ children }) => {
swapLayers,
removeLayer,
removeModelRun,
removeAllModelRuns,
removeObservations,
layerTypes,
baseMap,
Expand Down

0 comments on commit 2e2040f

Please sign in to comment.