[Rt-commit] rt branch, 4.2/saved-chart-show-partly, created. rt-4.2.9-65-gba37905

? sunnavy sunnavy at bestpractical.com
Sun Jan 11 23:56:57 EST 2015


The branch, 4.2/saved-chart-show-partly has been created
        at  ba37905f982983a26cd9298d3ccff4b0ccb1a258 (commit)

- Log -----------------------------------------------------------------
commit aedc560e55bea689e083214f33912abb59ac0617
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Nov 13 01:11:34 2014 +0800

    allow user to customize the visibility of image/table/sql in chart
    
    sometimes users want to show part of it.
    (e.g. when a chart is added to a dashboard)

diff --git a/share/html/Search/Chart b/share/html/Search/Chart
index 4e30b97..881a3d6 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -49,7 +49,7 @@
 $Cache => undef
 $Query => "id > 0"
 @GroupBy => ()
-$ChartStyle => 'bar'
+$ChartStyle => 'bar+table+sql'
 @ChartFunction => 'COUNT'
 $Width  => undef
 $Height => undef
@@ -64,8 +64,8 @@ my $font = $font_config{ $session{CurrentUser}->UserObj->Lang || '' }
 
 s/\D//g for grep defined, $Width, $Height;
 $Width  ||= 600;
-$Height ||= ($ChartStyle eq 'pie' ? $Width : 400);
-$Height = $Width if $ChartStyle eq 'pie';
+$Height ||= ($ChartStyle =~ /\bpie\b/ ? $Width : 400);
+$Height = $Width if $ChartStyle =~ /\bpie\b/;
 
 my $plot_error = sub {
     my $text = shift;
@@ -148,10 +148,10 @@ while ( my $entry = $report->Next ) {
     }
 }
 
-$ChartStyle = 'bar' if @data > 2;
+$ChartStyle =~ s/\bpie\b/bar/ if @data > 2;
 
 my $chart_class;
-if ($ChartStyle eq 'pie') {
+if ($ChartStyle =~ /\bpie\b/) {
     require GD::Graph::pie;
     $chart_class = "GD::Graph::pie";
 } else {
diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index c957bac..e08616a 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'],
+    ChartStyle => ['bar+table+sql'],
     ChartFunction => ['COUNT'],
 };
     
@@ -174,18 +174,43 @@ $m->callback( ARGSRef => \%ARGS, QueryArgsRef => \%query );
 </&>
 
 <&| /Widgets/TitleBox, title => loc('Picture'), class => "chart-picture" &>
-<label><% loc('Style') %>: <& Elements/SelectChartType, Default => $query{ChartStyle}[0], Name => 'ChartStyle' &></label>
+<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>
+<span class="width">
 <label><% loc("Width") %>: <input type="text" name="Width" value="<% $query{'Width'} || q{} %>"> <% loc("px") %></label>
+</span>
 <span class="height">
   &#x00d7;
   <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') %>
+</div>
+<div class="include-sql">
+    <input type="checkbox" name="ChartStyleIncludeSQL" <% $query{ChartStyle}[0] =~ /\bsql\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include TicketSQL query') %>
+</div>
 </&>
 <script type="text/javascript">
-jQuery(".chart-picture [name=ChartStyle]").change(function(){
+var updateChartStyle = function() {
+    var val = jQuery(".chart-picture [name=ChartType]").val();
+    if ( val != 'table' && jQuery(".chart-picture [name=ChartStyleIncludeTable]").is(':checked') ) {
+        val += '+table';
+    }
+    if ( jQuery(".chart-picture [name=ChartStyleIncludeSQL]").is(':checked') ) {
+        val += '+sql';
+    }
+    jQuery(".chart-picture [name=ChartStyle]").val(val);
+};
+jQuery(".chart-picture [name=ChartType]").change(function(){
     var t = jQuery(this);
-    t.closest("form").find("[name=Height]").closest(".height").toggle( t.val() !== "pie" );
+    t.closest("form").find("[name=Height]").closest(".height").toggle( t.val() == 'bar' );
+    t.closest("form").find("[name=Width]").closest(".width").toggle( t.val() !== 'table' );
+    t.closest("form .chart-picture").find("div.include-table").toggle( t.val() !== 'table' );
+    updateChartStyle();
 }).change();
+
+jQuery(".chart-picture [name=ChartStyleIncludeTable]").change( updateChartStyle );
+jQuery(".chart-picture [name=ChartStyleIncludeSQL]").change( updateChartStyle );
 </script>
 
 <& /Elements/Submit, Label => loc('Update Chart'), Name => 'Update' &>
diff --git a/share/html/Search/Elements/Chart b/share/html/Search/Elements/Chart
index 6a8d2ff..83f51ed 100644
--- a/share/html/Search/Elements/Chart
+++ b/share/html/Search/Elements/Chart
@@ -48,7 +48,7 @@
 <%args>
 $Query => "id > 0"
 @GroupBy => ()
-$ChartStyle => 'bar'
+$ChartStyle => 'bar+table+sql'
 @ChartFunction => 'COUNT'
 </%args>
 <%init>
@@ -67,6 +67,7 @@ $report->SortEntries;
 my $query_string = $m->comp('/Elements/QueryString', %ARGS, GroupBy => \@GroupBy );
 </%init>
 <div class="chart-wrapper">
+% if ( ($ChartStyle || '') =~ /\b(?:pie|bar)\b/ ) {
 <span class="chart image">
 % if (RT->Config->Get('DisableGD')) {
 <% loc('Graphical charts are not available.') %><br />
@@ -77,6 +78,13 @@ my $query_string = $m->comp('/Elements/QueryString', %ARGS, GroupBy => \@GroupBy
 <img src="<% RT->Config->Get('WebPath') %>/Search/Chart?Cache=<% $key |un %>&<% $query_string |n %>" />
 % }
 </span>
+% }
+
+% if ( ($ChartStyle || '') =~ /\btable\b/ ) {
 <& ChartTable, %ARGS, Table => { $report->FormatTable( %columns ) } &>
+% }
+
+% if ( ($ChartStyle || '') =~ /\bsql\b/ ) {
 <div class="query"><span class="label"><% loc('Query') %>:</span><span class="value"><% $Query %></span></div>
+% }
 </div>
diff --git a/share/html/Search/Elements/SelectChartType b/share/html/Search/Elements/SelectChartType
index 266885f..c4d95d0 100644
--- a/share/html/Search/Elements/SelectChartType
+++ b/share/html/Search/Elements/SelectChartType
@@ -50,9 +50,10 @@ $Name => 'ChartType'
 $Default => 'bar'
 </%args>
 <select id="<%$Name%>" name="<%$Name%>">
-% foreach my $option (qw(bar pie)) {
+% foreach my $option ('bar', 'pie', 'table') {
 % # 'bar' # loc
 % # 'pie' # loc
+% # 'table' # loc
 <option value="<%$option%>"<% $option eq $Default ? qq[ selected="selected"] : '' |n %>><%loc($option)%></option>
 % }
 </select>
diff --git a/share/static/css/aileron/ticket-lists.css b/share/static/css/aileron/ticket-lists.css
index 3e55cfc..de86164 100644
--- a/share/static/css/aileron/ticket-lists.css
+++ b/share/static/css/aileron/ticket-lists.css
@@ -177,6 +177,7 @@ padding-bottom: 1em;
 .chart-meta {
     padding-top: 2em;
     border-top: 1px solid #ccc;
+    clear: both;
 }
 
 .chart-meta .chart-type {
diff --git a/share/static/css/ballard/ticket-lists.css b/share/static/css/ballard/ticket-lists.css
index 4bb616c..be83108 100644
--- a/share/static/css/ballard/ticket-lists.css
+++ b/share/static/css/ballard/ticket-lists.css
@@ -176,6 +176,7 @@ padding-bottom: 1em;
 .chart-meta {
     padding-top: 2em;
     border-top: 1px solid #ccc;
+    clear: both;
 }
 
 .chart-meta .chart-type {
diff --git a/share/static/css/rudder/ticket-lists.css b/share/static/css/rudder/ticket-lists.css
index 94e6070..5645dc5 100644
--- a/share/static/css/rudder/ticket-lists.css
+++ b/share/static/css/rudder/ticket-lists.css
@@ -211,6 +211,7 @@ div.paging {
 .chart-meta {
     padding-top: 2em;
     border-top: 1px solid #ccc;
+    clear: both;
 }
 
 .chart-meta .chart-type {
diff --git a/share/static/css/web2/ticket-lists.css b/share/static/css/web2/ticket-lists.css
index 4bb616c..be83108 100644
--- a/share/static/css/web2/ticket-lists.css
+++ b/share/static/css/web2/ticket-lists.css
@@ -176,6 +176,7 @@ padding-bottom: 1em;
 .chart-meta {
     padding-top: 2em;
     border-top: 1px solid #ccc;
+    clear: both;
 }
 
 .chart-meta .chart-type {
diff --git a/t/mail/dashboard-chart-with-utf8.t b/t/mail/dashboard-chart-with-utf8.t
index d42675f..4fe483a 100644
--- a/t/mail/dashboard-chart-with-utf8.t
+++ b/t/mail/dashboard-chart-with-utf8.t
@@ -23,6 +23,7 @@ $m->submit_form(
     fields    => {
         SavedSearchDescription => 'chart foo',
         SavedSearchOwner       => 'RT::User-' . $root->id,
+        ChartStyle             => 'bar',
     },
     button => 'SavedSearchSave',
 );

commit d594f4f3cfa3c43261810faaea104600b9436dba
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 01:10:16 2015 +0800

    only bars need to be lifted up a bit
    
    bar images have a padding-top like stuff themselves, I believe that's why we
    lifted the whole bar image up so they can be top aligned horizontally with the
    data table.
    
    pie images don't have this issue and if we lift them up too, they could
    overlap with the div.titlebox.title in a dashboard when data table is not
    shown.

diff --git a/share/html/Search/Elements/Chart b/share/html/Search/Elements/Chart
index 83f51ed..6285fac 100644
--- a/share/html/Search/Elements/Chart
+++ b/share/html/Search/Elements/Chart
@@ -67,8 +67,8 @@ $report->SortEntries;
 my $query_string = $m->comp('/Elements/QueryString', %ARGS, GroupBy => \@GroupBy );
 </%init>
 <div class="chart-wrapper">
-% if ( ($ChartStyle || '') =~ /\b(?:pie|bar)\b/ ) {
-<span class="chart image">
+% if ( ($ChartStyle || '') =~ /\b(pie|bar)\b/ ) {
+<span class="chart image <% $1 %>">
 % if (RT->Config->Get('DisableGD')) {
 <% loc('Graphical charts are not available.') %><br />
 % } else {
diff --git a/share/static/css/aileron/ticket-lists.css b/share/static/css/aileron/ticket-lists.css
index de86164..a62ab4d 100644
--- a/share/static/css/aileron/ticket-lists.css
+++ b/share/static/css/aileron/ticket-lists.css
@@ -125,12 +125,15 @@ padding-bottom: 1em;
 }
 
 .chart.image {
-    margin-top: -1em;
     padding-right: 2em;
     float: left;
     clear: both;
 }
 
+.chart.image.bar {
+    margin-top: -1em;
+}
+
 .chart-wrapper {
     display: block;
     width: auto;
diff --git a/share/static/css/rudder/ticket-lists.css b/share/static/css/rudder/ticket-lists.css
index 5645dc5..cdf1019 100644
--- a/share/static/css/rudder/ticket-lists.css
+++ b/share/static/css/rudder/ticket-lists.css
@@ -160,12 +160,15 @@ div.paging {
 }
 
 .chart.image {
-    margin-top: -1em;
     padding-right: 2em;
     float: left;
     clear: both;
 }
 
+.chart.image.bar {
+    margin-top: -1em;
+}
+
 .chart-wrapper {
     display: block;
     width: auto;

commit ba37905f982983a26cd9298d3ccff4b0ccb1a258
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 01:54:45 2015 +0800

    upgrade step as old "bar" or "pie" implies "bar+table+sql" or "pie+table+sql"

diff --git a/etc/upgrade/4.2.9/content b/etc/upgrade/4.2.9/content
new file mode 100644
index 0000000..d9aadcc
--- /dev/null
+++ b/etc/upgrade/4.2.9/content
@@ -0,0 +1,19 @@
+use strict;
+use warnings;
+
+our @Initial = (
+    sub {
+        my $attrs = RT::Attributes->new(RT->SystemUser);
+        $attrs->Limit( FIELD => 'Name', VALUE => 'SavedSearch' );
+        while ( my $attr = $attrs->Next ) {
+            my $content = $attr->Content;
+            if ( $content->{ChartStyle} && $content->{ChartStyle} =~ /^(?:pie|bar)$/ ) {
+                $content->{ChartStyle} .= '+table+sql';
+                my ($ret, $msg) = $attr->SetContent($content);
+                unless ( $ret ) {
+                    RT->Logger->error("Failed to update ChartStyle for SavedSearch #" . $attr->id . ": $msg");
+                }
+            }
+        }
+    },
+);

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


More information about the rt-commit mailing list