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

Merge branch 'essential'

parents 1e33f8a0 b974e25e
......@@ -56,11 +56,20 @@ update_report_list = ->
$("#report-tab-list").append html
# Add building reports if this building is in the list
# Track # of reports.
rpt_count = 0
if _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
if _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.
......@@ -69,6 +78,11 @@ update_report_list = ->
# Select the first tab
$("#report-tab-list a:first").addClass("active").click()
else
# No reports, so hide tabs and iFrame
$("#report-tabs").hide()
$("#iframe-related").hide()
load_report = ->
# href attribute contains info about where the report is located
report_info = $(this).attr("href").substring(1)
......@@ -121,3 +135,8 @@ $ ->
$("#select_org").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 @@
};
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();
bldg = $("#select_bldg").val();
$("#report-tab-list").empty();
......@@ -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>";
return $("#report-tab-list").append(html);
};
rpt_count = 0;
if (_bldg_reports[bldg] != null) {
ref = _bldg_reports[bldg];
for (i = 0, len = ref.length; i < len; i++) {
rpt = ref[i];
add_report(rpt, "B");
}
rpt_count += 1;
}
if (_org_reports[org] != null) {
ref1 = _org_reports[org];
......@@ -53,9 +55,17 @@
rpt = ref1[j];
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();
}
};
load_report = function() {
......@@ -105,6 +115,10 @@
$("#select_org").change(update_bldg_list);
$("#select_org").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 @@
<h5><i>{{ error_message }}</i></h5>
<div id="debug-out"></div>
<div class="row mx-1">
<div id="bldg-selection" class="row mx-1">
<form class="form-inline">
<label class="mr-2" for="select_bldg" id="label_bldg"">Facility:</label>
<select class="form-control" id="select_bldg" name="select_bldg">
......@@ -34,7 +32,7 @@
<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>
</div>
......@@ -42,15 +40,17 @@
{% endblock %}
{% block fullwidth %}
<div class="row mt-3 mx-2">
<div id="iframe-related">
<div class="row mt-3 mx-2">
<div class="col">
<a id="print-link" href="" class="float-right" target="_blank">
Click Here for Printable Report View
</a>
</div>
</div>
<div class="row mx-2">
</div>
<div class="row mx-2">
<iframe id="report-content" src="" width="100%" height="750px"></iframe>
</div>
</div>
{% 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