[Rt-commit] rt branch, 4.6/canned-reports, updated. rt-4.4.1-157-g5d85527
Dustin Collins
strega at bestpractical.com
Thu Dec 22 12:17:24 EST 2016
The branch, 4.6/canned-reports has been updated
via 5d85527229c7903d003363dbd093ca877d2b7c7e (commit)
from 38f4bb38bd7c3682390f10700210807e13e0ec31 (commit)
Summary of changes:
share/html/CannedReport/Elements/MenuItem | 12 ++--
.../CannedReport/Elements/MenuItems/ReportSelect | 4 +-
share/static/css/base/canned-reports.css | 2 +
share/static/js/canned-reports.js | 66 +++++++++++++++++++++-
4 files changed, 73 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit 5d85527229c7903d003363dbd093ca877d2b7c7e
Author: Dustin Collins <strega at bestpractical.com>
Date: Thu Dec 22 12:16:45 2016 -0500
Add javascript management endpoints for menu and graphing
Utilizing a parameters object, and associated setter, any javascript can trigger an update to the menu and graph. Timers pad changes allowing repeated parameter changes.
diff --git a/share/html/CannedReport/Elements/MenuItem b/share/html/CannedReport/Elements/MenuItem
index 0c25183..eff4b89 100644
--- a/share/html/CannedReport/Elements/MenuItem
+++ b/share/html/CannedReport/Elements/MenuItem
@@ -38,18 +38,18 @@
<%ARGS>
$title => undef
+$id => undef
</%ARGS>
<%INIT>
my $content = $m->content;
</%INIT>
-<div class="reports-menu-item">
- <button class="reports-menu-item-btn"><% $title %>
- <svg width="24" height="14">
- <image xlink:href="/static/images/disclosure-down.svg" src="/static/images/disclosure-down.png" width="24" height="14" />
- </svg>
- </button>
+<div class="reports-menu-item" <% (defined $id) ? " id=$id" : "" %>>
+ <div class="reports-menu-item-btn">
+ <span><% $title %></span>
+ <image src="/static/images/disclosure-down.png" width="24" height="14" />
+ </div>
<div id="ReportDropdown" class="reports-menu-item-content">
% if ($content) {
<% $content | n %>
diff --git a/share/html/CannedReport/Elements/MenuItems/ReportSelect b/share/html/CannedReport/Elements/MenuItems/ReportSelect
index 831ea81..3a81242 100644
--- a/share/html/CannedReport/Elements/MenuItems/ReportSelect
+++ b/share/html/CannedReport/Elements/MenuItems/ReportSelect
@@ -48,9 +48,9 @@ my @names = $reports->AllReportNames();
</%INIT>
-<&| ../MenuItem, title => $names[0] &>
+<&| ../MenuItem, title => $names[0], id => "name" &>
% for my $aReportName (@names) {
- <a href="#<% $name %>"><% $aReportName %></a>
+ <a onclick="setParameter('name', '<% $aReportName %>')"><% $aReportName %></a>
% }
</&>
diff --git a/share/static/css/base/canned-reports.css b/share/static/css/base/canned-reports.css
index f16cacb..14644e0 100644
--- a/share/static/css/base/canned-reports.css
+++ b/share/static/css/base/canned-reports.css
@@ -27,6 +27,8 @@
padding-left: 3px;
padding-right: 3px;
+
+ vertical-align: middle;
}
.reports-menu-item-content {
diff --git a/share/static/js/canned-reports.js b/share/static/js/canned-reports.js
index e791301..a60306c 100644
--- a/share/static/js/canned-reports.js
+++ b/share/static/js/canned-reports.js
@@ -25,17 +25,77 @@ function submit(path, pairs, data, completion) {
}
+//MARK: Tools
+
+function getQueryParams() {
+ var qs = document.location.search.split('+').join(' ');
+
+ var params = {},
+ tokens,
+ re = /[?&]?([^=]+)=([^&]*)/g;
+
+ while (tokens = re.exec(qs)) {
+ params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
+ }
+
+ return params;
+}
+
+
+//MARK: State
+
+var _parameters = getQueryParams();
+var _paramsTimer = {};
+function setParameter(key, value) {
+ _parameters[key] = value;
+ window.clearTimeout(_paramsTimer);
+ _paramsTimer = window.setTimeout(function() {paramsChanged()}, 30);
+}
+
+function paramsChanged() {
+ updateMenu();
+ setGraphNeedsUpdate();
+}
+
+jQuery(document).ready(function() {
+ setParameter("name", "Resolved");
+})
+
+
//MARK: Menu
+function updateMenu() {
+ //Report name menu item
+ var menu = jQuery("#name.reports-menu-item")
+ var label = menu.find("div").find("span")
+ label.text(_parameters["name"])
+}
+
jQuery(document).ready(function() {
- jQuery(".reports-menu-item-btn").click(function() {
+ jQuery(".reports-menu-item-btn").on('click', '*', function() {
jQuery('.reports-menu-item-content').hide();
- jQuery(this).parent().find(".reports-menu-item-content").toggle();
+ var menu = jQuery(this).parents(".reports-menu-item");
+ menu.find(".reports-menu-item-content").toggle();
})
})
window.onclick = function(event) {
- if (!event.target.matches('.reports-menu-item-btn')) {
+ //Close open menus
+ if (!jQuery(event.target).parent().hasClass('reports-menu-item-btn')) {
jQuery('.reports-menu-item-content').hide();
}
}
+
+
+//MARK: Graph
+
+function updateGraph() {
+ alert("updateGraph called :)");
+}
+
+var _graphUpdateTimer = {}
+function setGraphNeedsUpdate(key, value) {
+ window.clearTimeout(_graphUpdateTimer)
+ _graphUpdateTimer = window.setTimeout(function() {updateGraph()}, 2000)
+}
+
-----------------------------------------------------------------------
More information about the rt-commit
mailing list