[Rt-commit] rt branch, 4.2/more-about-requestor-generalization, created. rt-4.1.6-326-g3d6be52

Thomas Sibley trs at bestpractical.com
Thu Mar 7 19:45:15 EST 2013


The branch, 4.2/more-about-requestor-generalization has been created
        at  3d6be52d96eb4cddf303c70c4128aefd41db9d4f (commit)

- Log -----------------------------------------------------------------
commit 060bdca8d1d282cec3f0e4d10938807ed15f4ce1
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 11:14:25 2013 -0800

    Generalize the "More About Requestors" accordion styles
    
    This lets other, future, accordion elements use the same style.
    
    The switch from an id-based selector to a class-based selector changes
    precedence of the CSS rules.  Preserving precedence requires changing h3
    to .ui-accordion-header, which matches the native jQuery UI selectors.

diff --git a/share/html/NoAuth/css/base/main.css b/share/html/NoAuth/css/base/accordion.css
similarity index 71%
copy from share/html/NoAuth/css/base/main.css
copy to share/html/NoAuth/css/base/accordion.css
index b47fcf4..e2d56e9 100644
--- a/share/html/NoAuth/css/base/main.css
+++ b/share/html/NoAuth/css/base/accordion.css
@@ -45,32 +45,40 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $m->callback(CallbackName => 'Begin');
+.rt-accordion .ui-accordion-content {
+    padding: 0 0 0 20px;
+    margin: -0.5em 0 0.5em 0;
+    border: none;
+    background: none;
+    color: black;
+}
 
- at import "yui-fonts.css";
- at import "jquery-ui.css";
- at import "jquery-ui-timepicker-addon.css";
- at import "jquery.modal.css";
- at import "superfish.css";
- at import "superfish-navbar.css";
- at import "superfish-vertical.css";
- at import "tablesorter.css";
- at import "farbtastic.css";
- at import "collection.css";
- at import "forms.css";
- at import "misc.css";
- at import "nav.css";
- at import "ticket-form.css";
- at import "rights-editor.css";
- at import "theme-editor.css";
- at import "ticket.css";
- at import "admin.css";
- at import "articles.css";
- at import "portlets.css";
- at import "tools.css";
- at import "login.css";
- at import "history-folding.css";
- at import "history.css";
+.rt-accordion {
+    margin: 0.5em 0 0 0;
+}
 
-% $m->callback(CallbackName => 'End');
+.rt-accordion .ui-accordion-header .ui-icon {
+    background-image: url(<%RT->Config->Get('WebPath')%>/static/images/jquery_ui/ui-icons_4488cc_256x240.png);
+    left: 0;
+}
 
+.rt-accordion .ui-accordion-header {
+    padding: 0;
+    background: none;
+}
+
+.rt-accordion .ui-accordion-header, .rt-accordion .ui-accordion-header a {
+    color: black;
+    border: none;
+    margin: 0;
+}
+
+.rt-accordion .ui-accordion-header a {
+    font-size: 90%;
+    padding: 0 0 0.25em 20px;
+}
+
+.rt-accordion .ui-accordion-header a:hover,
+.rt-accordion .ui-accordion-header.ui-state-active a {
+    text-decoration: underline;
+}
diff --git a/share/html/NoAuth/css/base/main.css b/share/html/NoAuth/css/base/main.css
index b47fcf4..fab2651 100644
--- a/share/html/NoAuth/css/base/main.css
+++ b/share/html/NoAuth/css/base/main.css
@@ -64,6 +64,7 @@
 @import "rights-editor.css";
 @import "theme-editor.css";
 @import "ticket.css";
+ at import "accordion.css";
 @import "admin.css";
 @import "articles.css";
 @import "portlets.css";
diff --git a/share/html/NoAuth/css/base/ticket.css b/share/html/NoAuth/css/base/ticket.css
index bb16f4e..c9c3b4b 100644
--- a/share/html/NoAuth/css/base/ticket.css
+++ b/share/html/NoAuth/css/base/ticket.css
@@ -45,44 +45,6 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-#requestor-accordion .ui-accordion-content {
-    padding: 0 0 0 20px;
-    margin: -0.5em 0 0.5em 0;
-    border: none;
-    background: none;
-    color: black !important;
-}
-
-#requestor-accordion {
-    margin: 0.5em 0 0 0;
-}
-
-#requestor-accordion h3 .ui-icon {
-    background-image: url(<%RT->Config->Get('WebPath')%>/static/images/jquery_ui/ui-icons_4488cc_256x240.png);
-    left: 0;
-}
-
-#requestor-accordion h3 {
-    padding: 0;
-    background: none !important;
-}
-
-#requestor-accordion h3, #requestor-accordion h3 a {
-    color: black !important;
-    border: none !important;
-    margin: 0;
-}
-
-#requestor-accordion h3 a {
-    font-size: 90%;
-    padding: 0 0 0.25em 20px;
-}
-
-#requestor-accordion h3 a:hover,
-#requestor-accordion h3.ui-state-active a {
-    text-decoration: underline;
-}
-
 #requestor-accordion a.modify-user {
     font-size: 80%;
     color: black !important;
diff --git a/share/html/Ticket/Elements/ShowRequestor b/share/html/Ticket/Elements/ShowRequestor
index 0b4bf1e..4582922 100644
--- a/share/html/Ticket/Elements/ShowRequestor
+++ b/share/html/Ticket/Elements/ShowRequestor
@@ -68,7 +68,7 @@
     class => 'ticket-info-requestor'
 &>
 
-<div id="requestor-accordion">
+<div id="requestor-accordion" class="rt-accordion">
 
 % while ( my $requestor = $people->Next ) {
   <h3><a href="#"><& /Elements/ShowUser, User => $requestor &></a></h3>

commit 54133c5a6d907ffd0d501e65e3017906b9c00053
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 11:41:14 2013 -0800

    Adjust margins of accordion headers and content
    
    Rather than pulling up the content with a negative margin (which may not
    be generally applicable), just reduce the top margin of the contained
    elements by the same amount.  While this affects all content sections of
    "More About Requestors", the effect is not noticeable without
    side-by-side comparison.

diff --git a/share/html/NoAuth/css/base/accordion.css b/share/html/NoAuth/css/base/accordion.css
index e2d56e9..3318df1 100644
--- a/share/html/NoAuth/css/base/accordion.css
+++ b/share/html/NoAuth/css/base/accordion.css
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 .rt-accordion .ui-accordion-content {
     padding: 0 0 0 20px;
-    margin: -0.5em 0 0.5em 0;
+    margin: 0 0 0.5em 0;
     border: none;
     background: none;
     color: black;
diff --git a/share/html/NoAuth/css/base/ticket.css b/share/html/NoAuth/css/base/ticket.css
index c9c3b4b..34657f0 100644
--- a/share/html/NoAuth/css/base/ticket.css
+++ b/share/html/NoAuth/css/base/ticket.css
@@ -171,7 +171,7 @@ div.requestor-ticket-links {
 .ticket-info-requestor .more-about-requestor-tickets,
 .ticket-info-requestor .more-about-user-groups
 {
-    margin: 1em 0;
+    margin: 0.5em 0 1em 0;
 }
 
 .ticket-info-requestor .comments-about-user .label,

commit 42e8a14deaff1d539f53097e57d6564e34ffce73
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 11:43:06 2013 -0800

    A normal sized accordion title is better than a slightly smaller one

diff --git a/share/html/NoAuth/css/base/accordion.css b/share/html/NoAuth/css/base/accordion.css
index 3318df1..1cbe71f 100644
--- a/share/html/NoAuth/css/base/accordion.css
+++ b/share/html/NoAuth/css/base/accordion.css
@@ -74,7 +74,6 @@
 }
 
 .rt-accordion .ui-accordion-header a {
-    font-size: 90%;
     padding: 0 0 0.25em 20px;
 }
 

commit 1b51f94ad7501b14d6e89b94abd0ff723a8d399e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 13:47:18 2013 -0800

    The need for a top margin on accordions is unnecessary for the general case
    
    … and indeed unnecessary for the ticket requestor case as well.  No idea
    why it was originally present.

diff --git a/share/html/NoAuth/css/base/accordion.css b/share/html/NoAuth/css/base/accordion.css
index 1cbe71f..4c032bc 100644
--- a/share/html/NoAuth/css/base/accordion.css
+++ b/share/html/NoAuth/css/base/accordion.css
@@ -45,6 +45,10 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
+.rt-accordion {
+    margin: 0;
+}
+
 .rt-accordion .ui-accordion-content {
     padding: 0 0 0 20px;
     margin: 0 0 0.5em 0;
@@ -53,10 +57,6 @@
     color: black;
 }
 
-.rt-accordion {
-    margin: 0.5em 0 0 0;
-}
-
 .rt-accordion .ui-accordion-header .ui-icon {
     background-image: url(<%RT->Config->Get('WebPath')%>/static/images/jquery_ui/ui-icons_4488cc_256x240.png);
     left: 0;

commit 3fcacd51f7e42dae7cc961ed01ff4389585fe95b
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 14:48:54 2013 -0800

    Add a $Collection->ColumnMapClassName equivalent for individual record objects
    
    This saves repeating the necessary ref/blessed and s/:/_/g in future
    code and encapsulates the logic in a single place.

diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 1942e7e..b124c0c 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2226,6 +2226,23 @@ sub ACLEquivalenceObjects { }
 
 sub ModifyLinkRight { }
 
+=head2 ColumnMapClassName
+
+ColumnMap needs a massaged collection class name to load the correct list
+display.  Equivalent to L<RT::SearchBuilder/ColumnMapClassName>, but provided
+for a record instead of a collection.
+
+Returns a string.  May be called as a package method.
+
+=cut
+
+sub ColumnMapClassName {
+    my $self  = shift;
+    my $Class = ref($self) || $self;
+       $Class =~ s/:/_/g;
+    return $Class;
+}
+
 sub BasicColumns { }
 
 sub WikiBase {

commit 5adcf03971eecd2bc4f91c52e541420983228f68
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 15:40:40 2013 -0800

    Use _SingularClass in $Collection->ColumnMapClassName
    
    Allows ColumnMapClassName to be called as a class method and
    consolidates functionality into the appropriate existing methods.

diff --git a/lib/RT/Classes.pm b/lib/RT/Classes.pm
index 60122c7..08bd47b 100644
--- a/lib/RT/Classes.pm
+++ b/lib/RT/Classes.pm
@@ -83,9 +83,7 @@ sub Next {
 
 }
 
-sub ColumnMapClassName {
-    return 'RT__Class';
-}
+sub _SingularClass { "RT::Class" }
 
 =head2 NewItem
 
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 4bb4177..eedef34 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -362,10 +362,9 @@ algorithm that this code uses.
 =cut
 
 sub ColumnMapClassName {
-    my $self = shift;
-    my $Class = ref $self;
-    $Class =~ s/s$//;
-    $Class =~ s/:/_/g;
+    my $self  = shift;
+    my $Class = $self->_SingularClass;
+       $Class =~ s/:/_/g;
     return $Class;
 }
 

commit 3d6be52d96eb4cddf303c70c4128aefd41db9d4f
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Mar 7 15:59:26 2013 -0800

    Generalize UserInfo's use of ColumnMap to display a single record object
    
    Displaying other individual record types is now very simple.  By
    default, the passed in Format is untrusted and will be scrubbed of
    disallowed HTML.  If the calling code knows the format is safe, perhaps
    because it can only be from a config file, TrustFormat => 1 may be
    passed.  This flag is present for use by UserInfo.

diff --git a/share/html/User/Elements/UserInfo b/share/html/Elements/ShowRecord
similarity index 74%
copy from share/html/User/Elements/UserInfo
copy to share/html/Elements/ShowRecord
index cb1502c..cd5ea16 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/Elements/ShowRecord
@@ -45,14 +45,38 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<div class="<% $ClassPrefix %>-extra">
-% for my $column (@formats) {
+<%args>
+$Object
+$Format
+$TrustFormat => 0
+$Class       => ""
+</%args>
+<%init>
+$Format = ScrubHTML($Format) unless $TrustFormat;
+
+my @columns = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $Format);
+
+my $fetch_columnmap = sub {
+    my ($name, $attr, $arguments, $no_escape) = @_;
+    my $tmp = $m->comp(
+        '/Elements/ColumnMap',
+        Class => $Object->ColumnMapClassName,
+        Name  => $name,
+        Attr  => $attr,
+    );
+    return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => !$no_escape );
+};
+</%init>
+<div class="record <% CSSClass($Class) %> <% CSSClass(blessed($Object)) %>">
+% for my $column (@columns) {
 % my $title = $m->interp->apply_escapes($column->{title} || '', 'h');
-% my $attr = $column->{'attribute'} || $column->{'last_attribute'};
+% my $attr  = $column->{'attribute'} || $column->{'last_attribute'};
 % unless (defined $column->{title}) {
+%   # No format-supplied title, so use the one from the column map as-is.  It's
+%   # trustworthy.
 %   $title = $fetch_columnmap->($attr,'title',[$attr]);
 % }
-<div class="<% $ClassPrefix %>-extra-field <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr],'no_escape')) %>" >
+<div class="record-field <% $Class ? CSSClass("$Class-field") : "" %> <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr],'no_escape')) %>">
 <span class="label"><% loc($title) |n %></span>
 % my @out;
 % foreach my $subcol ( @{ $column->{output} } ) {
@@ -61,37 +85,10 @@
 %         push @out, $subcol;
 %         next;
 %     }
-%     push @out, $fetch_columnmap->($col, 'value', [$User]);
+%     push @out, $fetch_columnmap->($col, 'value', [$Object]);
 % }
 % @out = grep { defined $_ and length $_ } @out;
 <span class="value"><% join(' ', at out) |n %></span>
 </div>
 % }
 </div>
-<%INIT>
-return unless $FormatConfig;
-my $format = RT->Config->Get($FormatConfig);
-return unless $format;
-
-# Note that we don't need to ScrubHTML($format), because it's only modifiable
-# by the RT server admin.
-my @formats = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $format);
-
-my $fetch_columnmap = sub {
-    my ($name, $attr, $arguments, $no_escape) = @_;
-    my $tmp = $m->comp( '/Elements/ColumnMap',
-            Class => $Class,
-            Name  => $name,
-            Attr  => $attr,
-            );
-    return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => !$no_escape );
-};
-
-$ClassPrefix = CSSClass($ClassPrefix) if $ClassPrefix;
-</%INIT>
-<%ARGS>
-$User => undef
-$Class => 'RT__User';
-$FormatConfig => undef,
-$ClassPrefix => undef,
-</%ARGS>
diff --git a/share/html/NoAuth/css/base/main.css b/share/html/NoAuth/css/base/main.css
index fab2651..be0155d 100644
--- a/share/html/NoAuth/css/base/main.css
+++ b/share/html/NoAuth/css/base/main.css
@@ -65,6 +65,7 @@
 @import "theme-editor.css";
 @import "ticket.css";
 @import "accordion.css";
+ at import "record.css";
 @import "admin.css";
 @import "articles.css";
 @import "portlets.css";
diff --git a/share/html/NoAuth/css/base/main.css b/share/html/NoAuth/css/base/record.css
similarity index 73%
copy from share/html/NoAuth/css/base/main.css
copy to share/html/NoAuth/css/base/record.css
index fab2651..9e58449 100644
--- a/share/html/NoAuth/css/base/main.css
+++ b/share/html/NoAuth/css/base/record.css
@@ -45,33 +45,13 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $m->callback(CallbackName => 'Begin');
-
- at import "yui-fonts.css";
- at import "jquery-ui.css";
- at import "jquery-ui-timepicker-addon.css";
- at import "jquery.modal.css";
- at import "superfish.css";
- at import "superfish-navbar.css";
- at import "superfish-vertical.css";
- at import "tablesorter.css";
- at import "farbtastic.css";
- at import "collection.css";
- at import "forms.css";
- at import "misc.css";
- at import "nav.css";
- at import "ticket-form.css";
- at import "rights-editor.css";
- at import "theme-editor.css";
- at import "ticket.css";
- at import "accordion.css";
- at import "admin.css";
- at import "articles.css";
- at import "portlets.css";
- at import "tools.css";
- at import "login.css";
- at import "history-folding.css";
- at import "history.css";
-
-% $m->callback(CallbackName => 'End');
+.record .record-field .label {
+    display: inline-block;
+    width: 8em;
+    font-weight: bold;
+    text-align: right;
+}
 
+.record .record-field .value {
+    display: inline-block;
+}
diff --git a/share/html/NoAuth/css/base/ticket.css b/share/html/NoAuth/css/base/ticket.css
index 34657f0..d2ccf83 100644
--- a/share/html/NoAuth/css/base/ticket.css
+++ b/share/html/NoAuth/css/base/ticket.css
@@ -155,17 +155,6 @@ div.requestor-ticket-links {
     padding-top: 0.25em;
 }
 
-.more-about-requestor-extra-field .label {
-    display: inline-block;
-    width: 8em;
-    font-weight: bold;
-    text-align: right;
-}
-
-.more-about-requestor-extra-field .value {
-    display: inline-block;
-}
-
 .ticket-info-requestor .more-about-requestor-extra,
 .ticket-info-requestor .comments-about-user,
 .ticket-info-requestor .more-about-requestor-tickets,
diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index cb1502c..728e242 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -45,53 +45,20 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<div class="<% $ClassPrefix %>-extra">
-% for my $column (@formats) {
-% my $title = $m->interp->apply_escapes($column->{title} || '', 'h');
-% my $attr = $column->{'attribute'} || $column->{'last_attribute'};
-% unless (defined $column->{title}) {
-%   $title = $fetch_columnmap->($attr,'title',[$attr]);
-% }
-<div class="<% $ClassPrefix %>-extra-field <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr],'no_escape')) %>" >
-<span class="label"><% loc($title) |n %></span>
-% my @out;
-% foreach my $subcol ( @{ $column->{output} } ) {
-%     my ($col) = ($subcol =~ /^__(.*?)__$/);
-%     unless ( $col ) {
-%         push @out, $subcol;
-%         next;
-%     }
-%     push @out, $fetch_columnmap->($col, 'value', [$User]);
-% }
-% @out = grep { defined $_ and length $_ } @out;
-<span class="value"><% join(' ', at out) |n %></span>
-</div>
-% }
-</div>
+<& /Elements/ShowRecord,
+    Object      => $User,
+    Format      => $format,
+    TrustFormat => 1, # Only modifiable by the RT server admin, so no need to scrub.
+    Class       => "$ClassPrefix-extra",
+    &>
 <%INIT>
+return unless blessed($User) and $User->id;
 return unless $FormatConfig;
 my $format = RT->Config->Get($FormatConfig);
 return unless $format;
-
-# Note that we don't need to ScrubHTML($format), because it's only modifiable
-# by the RT server admin.
-my @formats = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $format);
-
-my $fetch_columnmap = sub {
-    my ($name, $attr, $arguments, $no_escape) = @_;
-    my $tmp = $m->comp( '/Elements/ColumnMap',
-            Class => $Class,
-            Name  => $name,
-            Attr  => $attr,
-            );
-    return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => !$no_escape );
-};
-
-$ClassPrefix = CSSClass($ClassPrefix) if $ClassPrefix;
 </%INIT>
 <%ARGS>
-$User => undef
-$Class => 'RT__User';
-$FormatConfig => undef,
-$ClassPrefix => undef,
+$User         => undef
+$FormatConfig => undef
+$ClassPrefix  => undef
 </%ARGS>

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


More information about the Rt-commit mailing list