Commit 0b88e57f authored by Alan Mitchell's avatar Alan Mitchell

Merge branch 'essential'

parents 1e33f8a0 b974e25e
...@@ -56,18 +56,32 @@ update_report_list = -> ...@@ -56,18 +56,32 @@ update_report_list = ->
$("#report-tab-list").append html $("#report-tab-list").append html
# Add building reports if this building is in the list # Add building reports if this building is in the list
# Track # of reports.
rpt_count = 0
if _bldg_reports[bldg]? if _bldg_reports[bldg]?
add_report(rpt, "B") for rpt in _bldg_reports[bldg] add_report(rpt, "B") for rpt in _bldg_reports[bldg]
rpt_count += 1
# Add Organization reports if this building is in the list # Add Organization reports if this building is in the list
if _org_reports[org]? if _org_reports[org]?
add_report(rpt, "O") for rpt in _org_reports[org] add_report(rpt, "O") for rpt in _org_reports[org]
rpt_count += 1
if rpt_count > 0
$("#report-tabs").show()
$("#iframe-related").show()
# add a handler for the click event on all of the a links associated
# with the tabs.
$("#report-tab-list a").click load_report
# add a handler for the click event on all of the a links associated # Select the first tab
# with the tabs. $("#report-tab-list a:first").addClass("active").click()
$("#report-tab-list a").click load_report
# Select the first tab else
$("#report-tab-list a:first").addClass("active").click() # No reports, so hide tabs and iFrame
$("#report-tabs").hide()
$("#iframe-related").hide()
load_report = -> load_report = ->
# href attribute contains info about where the report is located # href attribute contains info about where the report is located
...@@ -120,4 +134,9 @@ $ -> ...@@ -120,4 +134,9 @@ $ ->
$("#select_org").change update_bldg_list $("#select_org").change update_bldg_list
$("#select_org").change update_report_list $("#select_org").change update_report_list
$("#select_bldg").change update_report_list $("#select_bldg").change update_report_list
else
$("#bldg-selection").hide()
$("#report-tabs").hide()
$("#iframe-related").hide()
\ No newline at end of file
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
}; };
update_report_list = function() { update_report_list = function() {
var add_report, bldg, i, j, len, len1, org, ref, ref1, rpt; var add_report, bldg, i, j, len, len1, org, ref, ref1, rpt, rpt_count;
org = $("#select_org").val(); org = $("#select_org").val();
bldg = $("#select_bldg").val(); bldg = $("#select_bldg").val();
$("#report-tab-list").empty(); $("#report-tab-list").empty();
...@@ -40,12 +40,14 @@ ...@@ -40,12 +40,14 @@
html = "<li class=\"nav-item\">\n <a class=\"nav-link\" data-toggle=\"tab\" href=\"#" + rpt_type + "-" + rpt.file_name + "\" role=\"tab\">" + rpt.title + "</a>\n</li>"; html = "<li class=\"nav-item\">\n <a class=\"nav-link\" data-toggle=\"tab\" href=\"#" + rpt_type + "-" + rpt.file_name + "\" role=\"tab\">" + rpt.title + "</a>\n</li>";
return $("#report-tab-list").append(html); return $("#report-tab-list").append(html);
}; };
rpt_count = 0;
if (_bldg_reports[bldg] != null) { if (_bldg_reports[bldg] != null) {
ref = _bldg_reports[bldg]; ref = _bldg_reports[bldg];
for (i = 0, len = ref.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i++) {
rpt = ref[i]; rpt = ref[i];
add_report(rpt, "B"); add_report(rpt, "B");
} }
rpt_count += 1;
} }
if (_org_reports[org] != null) { if (_org_reports[org] != null) {
ref1 = _org_reports[org]; ref1 = _org_reports[org];
...@@ -53,9 +55,17 @@ ...@@ -53,9 +55,17 @@
rpt = ref1[j]; rpt = ref1[j];
add_report(rpt, "O"); add_report(rpt, "O");
} }
rpt_count += 1;
}
if (rpt_count > 0) {
$("#report-tabs").show();
$("#iframe-related").show();
$("#report-tab-list a").click(load_report);
return $("#report-tab-list a:first").addClass("active").click();
} else {
$("#report-tabs").hide();
return $("#iframe-related").hide();
} }
$("#report-tab-list a").click(load_report);
return $("#report-tab-list a:first").addClass("active").click();
}; };
load_report = function() { load_report = function() {
...@@ -105,6 +115,10 @@ ...@@ -105,6 +115,10 @@
$("#select_org").change(update_bldg_list); $("#select_org").change(update_bldg_list);
$("#select_org").change(update_report_list); $("#select_org").change(update_report_list);
return $("#select_bldg").change(update_report_list); return $("#select_bldg").change(update_report_list);
} else {
$("#bldg-selection").hide();
$("#report-tabs").hide();
return $("#iframe-related").hide();
} }
}); });
......
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
<h5><i>{{ error_message }}</i></h5> <h5><i>{{ error_message }}</i></h5>
<div id="debug-out"></div> <div id="bldg-selection" class="row mx-1">
<div class="row mx-1">
<form class="form-inline"> <form class="form-inline">
<label class="mr-2" for="select_bldg" id="label_bldg"">Facility:</label> <label class="mr-2" for="select_bldg" id="label_bldg"">Facility:</label>
<select class="form-control" id="select_bldg" name="select_bldg"> <select class="form-control" id="select_bldg" name="select_bldg">
...@@ -34,7 +32,7 @@ ...@@ -34,7 +32,7 @@
<hr/> <hr/>
<div class="row mx-1 mt-3"> <div id="report-tabs" class="row mx-1 mt-3">
<ul id="report-tab-list" class="nav nav-tabs flex-wrap" role="tablist"> <ul id="report-tab-list" class="nav nav-tabs flex-wrap" role="tablist">
</ul> </ul>
</div> </div>
...@@ -42,15 +40,17 @@ ...@@ -42,15 +40,17 @@
{% endblock %} {% endblock %}
{% block fullwidth %} {% block fullwidth %}
<div class="row mt-3 mx-2"> <div id="iframe-related">
<div class="col"> <div class="row mt-3 mx-2">
<a id="print-link" href="" class="float-right" target="_blank"> <div class="col">
Click Here for Printable Report View <a id="print-link" href="" class="float-right" target="_blank">
</a> Click Here for Printable Report View
</a>
</div>
</div>
<div class="row mx-2">
<iframe id="report-content" src="" width="100%" height="750px"></iframe>
</div> </div>
</div>
<div class="row mx-2">
<iframe id="report-content" src="" width="100%" height="750px"></iframe>
</div> </div>
{% endblock %} {% endblock %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment