Skip to content

Commit

Permalink
Show empowerplan scenario panel only at step 3
Browse files Browse the repository at this point in the history
  • Loading branch information
henhuy committed Nov 14, 2023
1 parent 8ff98bd commit f5699b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
38 changes: 19 additions & 19 deletions digiplan/static/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {resultsTabs, futureDropdown} from "./elements.js";

const menuNextBtn = document.getElementById("menu_next_btn");
const menuPreviousBtn = document.getElementById("menu_previous_btn");
const mapTab = document.getElementById("map-view-tab");
const chartTab = document.getElementById("chart-view-tab");
const regionChart = document.getElementById("region_chart_2045");

menuNextBtn.addEventListener("click", function () {
Expand All @@ -15,23 +13,16 @@ menuPreviousBtn.addEventListener("click", function() {
PubSub.publish(eventTopics.MENU_CHANGED);
});

mapTab.addEventListener("click", function () {
PubSub.publish(eventTopics.MAP_VIEW_SELECTED);
});

chartTab.addEventListener("click", function () {
PubSub.publish(eventTopics.CHART_VIEW_SELECTED);
});

PubSub.subscribe(eventTopics.MENU_STATUS_QUO_SELECTED, setMapChartViewVisibility);
PubSub.subscribe(eventTopics.MENU_STATUS_QUO_SELECTED, showMapView);
PubSub.subscribe(eventTopics.MENU_STATUS_QUO_SELECTED, hidePotentialLayers);
PubSub.subscribe(eventTopics.MENU_STATUS_QUO_SELECTED, hideEmpowerplanScenarios);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, setMapChartViewVisibility);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, showMapView);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, deactivateChoropleth);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, terminateSimulation);
PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, hideEmpowerplanScenarios);
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, setMapChartViewVisibility);
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, hidePotentialLayers);
PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, showEmpowerplanScenarios);
PubSub.subscribe(eventTopics.MAP_VIEW_SELECTED, setResultsView);
PubSub.subscribe(eventTopics.CHART_VIEW_SELECTED, setResultsView);

Expand Down Expand Up @@ -79,13 +70,6 @@ function getCurrentMenuTab() {
return document.querySelector("#js-panel-container > .panel__content > .tab-content > .active");
}


function showMapView(msg) {
bootstrap.Tab.getInstance(mapTab).show();
PubSub.publish(eventTopics.MAP_VIEW_SELECTED);
return logMessage(msg);
}

function setMapChartViewVisibility(msg) {
const view_toggle = document.getElementsByClassName("view-toggle")[0];
view_toggle.hidden = msg !== eventTopics.MENU_RESULTS_SELECTED;
Expand Down Expand Up @@ -119,3 +103,19 @@ function terminateSimulation(msg) {
}
return logMessage(msg);
}

function showEmpowerplanScenarios(msg) {
const map_wrap = document.getElementsByClassName("map-wrap")[0];
document.getElementsByClassName("map-wrap")[0].style.alignItems = "center";
document.getElementsByClassName("map-wrap")[0].style.padding = "3rem";
map_wrap.getElementsByTagName("img")[0].hidden = false;
return logMessage(msg);
}

function hideEmpowerplanScenarios(msg) {
const map_wrap = document.getElementsByClassName("map-wrap")[0];
document.getElementsByClassName("map-wrap")[0].style.alignItems = null;
document.getElementsByClassName("map-wrap")[0].style.padding = "0rem";
map_wrap.getElementsByTagName("img")[0].hidden = true;
return logMessage(msg);
}
6 changes: 3 additions & 3 deletions digiplan/templates/components/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% include "components/onboarding.html" %}

<section class="map-wrap" style="display: flex; justify-content: start; align-items: center; padding-top: 3rem;">
<img width="862" height="487" src="{% static 'images/sketches/scenarios-main.png' %}" alt="">
<section class="map-wrap">
<img hidden width="862" height="487" src="{% static 'images/sketches/scenarios-main.png' %}" alt="">
{% include 'components/toggle_view.html' %}
</section>

0 comments on commit f5699b0

Please sign in to comment.