Skip to content

Commit

Permalink
Merge pull request #131 from empowerplan/fix/scenario-main-sliders
Browse files Browse the repository at this point in the history
Fix main slider values for scenarios
  • Loading branch information
nesnoj authored May 6, 2024
2 parents 118201a + 925a53a commit 1dd7c85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion digiplan/static/js/scenarios.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { getCurrentMenuTab } from "./menu.js";
import { detailSliders, panelSliders, updateSliderMarks } from "./sliders.js";
import {
detailSliders,
panelSliders,
updateSliderMarks,
adaptMainSliders,
} from "./sliders.js";

const scenarioSettings = JSON.parse(
document.getElementById("scenario_settings").textContent,
Expand Down Expand Up @@ -137,8 +142,11 @@ function adaptSlidersScenario(msg, scenario) {
input: [{ id: slider.id }],
from: sliderValue,
};
// Has to be called manually, as otherwise main slider is not ready for scenario data update
adaptMainSliders(eventTopics.DETAIL_PANEL_SLIDER_CHANGE, data);
PubSub.publish(eventTopics.DETAIL_PANEL_SLIDER_CHANGE, data);
}
console.log("Start adapting main sliders");
// update main panel Sliders afterwards
for (const slider of panelSliders) {
// Check if the slider is defined in scenario settings
Expand Down
2 changes: 1 addition & 1 deletion digiplan/static/js/sliders.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function adaptDetailSliders(msg, data) {
* @param {string} msg Publisher message
* @param {object} data Data from changed ionrangeslider
*/
function adaptMainSliders(msg, data) {
export function adaptMainSliders(msg, data) {
const slider_id = data.input[0].id;
if (slider_id === "id_s_w_6" || slider_id === "id_s_w_7") {
calculate_max_wind();
Expand Down

0 comments on commit 1dd7c85

Please sign in to comment.