Skip to content

Commit

Permalink
#377: correctly reset formatter parameters when changin the widget fo…
Browse files Browse the repository at this point in the history
…rmatter
  • Loading branch information
andreas committed Nov 28, 2024
1 parent b2e79e9 commit 6538f15
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions viewer/components/EditWidgetDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import PropTypes from 'prop-types';
import LayoutHandler from '../util/layouthandler.js';
import OverlayDialog,{dialogHelper} from './OverlayDialog.jsx';
import WidgetFactory, {filterByEditables} from '../components/WidgetFactory.jsx';
import assign from 'object-assign';
import {Input,InputSelect} from './Inputs.jsx';
import DB from './DialogButton.jsx';
import {getList,ParamValueInput} from "./ParamValueInput";
Expand Down Expand Up @@ -62,15 +61,18 @@ class EditWidgetDialog extends React.Component{
if (opt_new){
nvalues=values;
let newState={
widget: assign({weight:this.state.widget.weight},nvalues),
widget: {weight:this.state.widget.weight,...nvalues},
parameters:WidgetFactory.getEditableWidgetParameters(nvalues.name)};
newState.parameters.forEach((p)=>{
p.setDefault(newState.widget);
});
this.setState(newState);
}
else {
nvalues = assign({}, this.state.widget, values);
nvalues = {...this.state.widget, ...values};
if (this.state.widget.formatter !== nvalues.formatter){
nvalues.formatterParameters=[];
}
this.setState({widget: nvalues})
}
}
Expand Down Expand Up @@ -111,7 +113,7 @@ class EditWidgetDialog extends React.Component{
if (this.props.panel !== this.state.panel){
panelClass+=" changed";
}
let completeWidgetData=assign({},cloneDeep(WidgetFactory.findWidget(this.state.widget.name)),this.state.widget);
let completeWidgetData={...cloneDeep(WidgetFactory.findWidget(this.state.widget.name)),...this.state.widget};
return (
<React.Fragment>
<div className="selectDialog editWidgetDialog">
Expand Down

0 comments on commit 6538f15

Please sign in to comment.