[Rt-commit] rt branch, 4.4/dashboard-charts, created. rt-4.4.0-110-ga919047

Shawn Moore shawn at bestpractical.com
Mon May 9 19:26:55 EDT 2016


The branch, 4.4/dashboard-charts has been created
        at  a919047c7c88e70fbd3f2a4e944bf76d80878b4a (commit)

- Log -----------------------------------------------------------------
commit 2544758ca70912b236d98777f0b3549beb7a166d
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Mon May 9 22:44:05 2016 +0000

    Make ChartStyle a scalar
    
        I can see no reason why this is treated as an array reference
        in /Search/Chart.html; it's treated as a scalar everywhere else,
        including in the UI.

diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index 9dc0d78..57cd0ec 100644
--- a/share/html/Search/Chart.html
+++ b/share/html/Search/Chart.html
@@ -49,7 +49,7 @@
 my $default_value = {
     Query => 'id > 0',
     GroupBy => ['Status'],
-    ChartStyle => ['bar+table+sql'],
+    ChartStyle => 'bar+table+sql',
     ChartFunction => ['COUNT'],
 };
     
@@ -174,8 +174,8 @@ $m->callback( ARGSRef => \%ARGS, QueryArgsRef => \%query );
 </&>
 
 <&| /Widgets/TitleBox, title => loc('Picture'), class => "chart-picture" &>
-<input name="ChartStyle" type="hidden" value="<% $query{ChartStyle}[0] %>" />
-<label><% loc('Style') %>: <& Elements/SelectChartType, Default => $query{ChartStyle}[0] =~ /^(pie|bar|table)\b/ ? $1 : undef &></label>
+<input name="ChartStyle" type="hidden" value="<% $query{ChartStyle} %>" />
+<label><% loc('Style') %>: <& Elements/SelectChartType, Default => $query{ChartStyle} =~ /^(pie|bar|table)\b/ ? $1 : undef &></label>
 <span class="width">
 <label><% loc("Width") %>: <input type="text" name="Width" value="<% $query{'Width'} || q{} %>"> <% loc("px") %></label>
 </span>
@@ -184,10 +184,10 @@ $m->callback( ARGSRef => \%ARGS, QueryArgsRef => \%query );
   <label><% loc("Height") %>: <input type="text" name="Height" value="<% $query{'Height'} || q{} %>"> <% loc("px") %></label>
 </span>
 <div class="include-table">
-    <input type="checkbox" name="ChartStyleIncludeTable" <% $query{ChartStyle}[0] =~ /\btable\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include data table') %>
+    <input type="checkbox" name="ChartStyleIncludeTable" <% $query{ChartStyle} =~ /\btable\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include data table') %>
 </div>
 <div class="include-sql">
-    <input type="checkbox" name="ChartStyleIncludeSQL" <% $query{ChartStyle}[0] =~ /\bsql\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include TicketSQL query') %>
+    <input type="checkbox" name="ChartStyleIncludeSQL" <% $query{ChartStyle} =~ /\bsql\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include TicketSQL query') %>
 </div>
 </&>
 <script type="text/javascript">

commit a919047c7c88e70fbd3f2a4e944bf76d80878b4a
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Mon May 9 22:55:23 2016 +0000

    Fix charts sometimes not showing up on dashboards
    
        The problem was charts that had not been updated using the "Update
        Chart" button were incompletely written into Saved Charts: their
        default values (ChartStyle=bar+table+sql, etc) were not saved
        into the saved chart. This is ordinarily not a problem for saved
        charts because those defaults would be set up when you loaded a
        saved chart using the normal UI. However, dashboards don't have the
        same initialization order, so the $ChartStyle would be empty, causing
        no rendering to happen.
    
        This regression was introduced by
        aedc560e55bea689e083214f33912abb59ac0617 which introduces a
        conditional on the uninitialized $ChartStyle; previously,
        <img src="…/Search/Chart"> was included unconditionally, which
        worked because /Search/Chart provides a default $ChartStyle.
    
        This commit addresses the issue by unconditionally saving the
        default values (e.g. ChartStyle=bar+table+sql) into the Saved Chart
        record. It does so by putting the defaults directly into %ARGS,
        which is used to populate the saved search.
    
    Fixes: I#31557

diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index 57cd0ec..15c1315 100644
--- a/share/html/Search/Chart.html
+++ b/share/html/Search/Chart.html
@@ -63,8 +63,6 @@ my $saved_search = $m->comp( '/Widgets/SavedSearch:new',
     SearchFields => [@search_fields],
 );
 
-my @actions = $m->comp( '/Widgets/SavedSearch:process', args => \%ARGS, self => $saved_search );
-
 my %query;
 
 {
@@ -101,18 +99,20 @@ my %query;
 }
 
 foreach (@search_fields) {
+    # is this field meant to be scalar or array?
     if ( ref $default_value->{$_} ) {
-        $query{$_} = ref $ARGS{$_} ? $ARGS{$_} : [ $ARGS{$_} ];
-        $query{$_} = $default_value->{$_}
-            unless defined $query{$_} && defined $query{$_}[0];
+        $ARGS{$_} = [$ARGS{$_}] if !ref($ARGS{$_});
+        $ARGS{$_} = $default_value->{$_} if !$ARGS{$_}[0];
     }
     else {
-        $query{$_} = ref $ARGS{$_} ? $ARGS{$_} : $ARGS{$_};
-        $query{$_} = $default_value->{$_}
-            unless defined $query{$_};
+        $ARGS{$_} //= $default_value->{$_};
     }
+
+    $query{$_} = $ARGS{$_};
 }
 
+my @actions = $m->comp( '/Widgets/SavedSearch:process', args => \%ARGS, self => $saved_search );
+
 $m->callback( ARGSRef => \%ARGS, QueryArgsRef => \%query );
 
 </%init>

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


More information about the rt-commit mailing list