[Rt-commit] rt branch 5.0/saved-search-jschart-subquery created. rt-5.0.3-329-g1db06229c5

BPS Git Server git at git.bestpractical.com
Fri Mar 24 20:29:55 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/saved-search-jschart-subquery has been created
        at  1db06229c5839a158f2365c436d9aa325d6ea459 (commit)

- Log -----------------------------------------------------------------
commit 1db06229c5839a158f2365c436d9aa325d6ea459
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 1 05:05:42 2022 +0800

    Make pie/bar in js charts clickable again for saved searches
    
    In 319f64de28 we supported multiple js charts on a single page, which
    generated canvas id attribute dynamically, but it missed to update id in
    js code that registers the click event and didn't consider js var name
    collisions. This commit fixes them accordingly.

diff --git a/share/html/Search/JSChart b/share/html/Search/JSChart
index bc3f9d3ac2..f3a1b61c86 100644
--- a/share/html/Search/JSChart
+++ b/share/html/Search/JSChart
@@ -60,6 +60,8 @@ $StackedGroupBy => undef
 % my $id = join '-', 'search-chart', $SavedSearchId || ();
 <canvas id="<% $id %>" width="<% $Width %>" height="<% $Height %>"></canvas>
 <script type="text/javascript">
+// wrap code to not pollute default namespaces to support multiple charts on one page
+(function() {
 var data_labels = data_labels || {};
 data_labels['<% $SavedSearchId %>'] = <% JSON( \@data_labels ) |n %>;
 
@@ -161,7 +163,7 @@ var searchChart = new Chart(ctx, {
 var group_by = <% JSON( \@GroupBy ) |n %>;
 var data_queries = <% JSON( \@data_queries ) |n %>;
 
-jQuery('#search-chart').click(function(e) {
+jQuery('[id="<% $id |n %>"]').click(function(e) {
     var slice = searchChart.getElementAtEvent(e);
     if ( !slice[0] ) return;
 
@@ -182,7 +184,7 @@ jQuery('#search-chart').click(function(e) {
     window.open(RT.Config.WebPath + '/Search/Results.html?Query=' + encodeURIComponent(query)
         + '&' + <% $m->comp('/Elements/QueryString', map { $_ => $DECODED_ARGS->{$_} } grep { $_ ne 'Query' } keys %$DECODED_ARGS) |n,j%>);
 });
-
+})();
 </script>
 
 <%init>

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list