Skip to content

Commit

Permalink
Merge pull request #124 from cmu-delphi/OKRS24-204
Browse files Browse the repository at this point in the history
OKRS24-204
  • Loading branch information
dmytrotsko committed May 28, 2024
2 parents 2403047 + 11ede81 commit 176bd87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/fixtures/nation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"model": "signals.geographyunit",
"pk": 3985,
"fields": {
"created": "2024-05-27T13:52:04.705Z",
"modified": "2024-05-27T13:52:04.705Z",
"geo_id": "US",
"name": "United States",
"display_name": "United States",
"level": 5,
"geography": 5
}
}
]
15 changes: 9 additions & 6 deletions src/templates/signals/epivis_export_data_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h5>Plot / Export data</h5>
<script>
var geoValues = [];
var currentMode = 'epivis';

function getFilteredGeographicValues(geographicType) {
var data = geoValues.reduce((data, geoValue) => {
if (geoValue.geoType === geographicType) {
Expand All @@ -130,7 +130,7 @@ <h5>Plot / Export data</h5>
} else {
data = [];
}


$('#geographic_value').select2({
data: data,
Expand All @@ -146,7 +146,7 @@ <h5>Plot / Export data</h5>

function handleModeChange(mode) {
document.getElementById("epivis-form").reset();

var choose_dates = document.getElementsByName('choose_date');
if (mode === 'epivis') {
currentMode = 'epivis';
Expand Down Expand Up @@ -179,7 +179,7 @@ <h5>Plot / Export data</h5>
$(document).ready(function () {
{% for geography in signal.available_geography.all %}
{% for unit in geography.geography_units.all %}
geoValues.push({'id': '{{ unit.geo_id }}', 'geoType': '{{ unit.geography }}', 'text': '{{ unit.display_name }}'});
geoValues.push({'id': '{{ unit.geo_id }}', 'geoType': '{{ unit.geography }}', 'text': '{{ unit.display_name }}'});
{% endfor %}
{% endfor %}

Expand All @@ -201,11 +201,14 @@ <h5>Plot / Export data</h5>

function submitMode(event) {
event.preventDefault();

var dataSource = document.getElementById('source').value;
var dataSignal = document.getElementById('signal').value;
var geographicType = document.getElementById('geographic_type').value;
var geographicValue = $('#geographic_value').select2('data').map((el) => el.id).join(',');
// geographicValue is a comma separated string of geographic values. type can be string or integer
// in case of string, it should be converted to lowercase
// else it will be treated as integer
var geographicValue = $('#geographic_value').select2('data').map((el) => (typeof el.id === 'string') ? el.id.toLowerCase() : el.id).join(',');

if (geographicType === 'Choose...' || geographicValue === '') {
showWarningAlert("Geographic Type or Geographic Value is not selected.");
Expand Down

0 comments on commit 176bd87

Please sign in to comment.