[Rt-commit] rt branch, 4.6/pjax, updated. rt-4.4.1-5-gc4f355c
Shawn Moore
shawn at bestpractical.com
Fri Sep 23 14:00:10 EDT 2016
The branch, 4.6/pjax has been updated
via c4f355c37f8e635bfeeba98c72606b64e2414f42 (commit)
via 278ae61bca6414207a1b2295de7f7daa6a22b3f9 (commit)
from add68035c3c46a67ef65f9448db655869ff9f010 (commit)
Summary of changes:
lib/RT/Interface/Web.pm | 1 +
lib/RT/Interface/Web/Menu.pm | 32 ++++++++++++++++++++++++--------
share/html/Widgets/ComboBox | 5 -----
share/static/js/util.js | 3 +++
4 files changed, 28 insertions(+), 13 deletions(-)
- Log -----------------------------------------------------------------
commit 278ae61bca6414207a1b2295de7f7daa6a22b3f9
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Sep 23 16:49:52 2016 +0000
Migrate inline combobox activation JS into util.js
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index a7bbaef..a542a48 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -127,6 +127,7 @@ sub JSFiles {
chosen.jquery.min.js
history-folding.js
cascaded.js
+ combobox.js
forms.js
event-registration.js
late.js
diff --git a/share/html/Widgets/ComboBox b/share/html/Widgets/ComboBox
index dca2693..bf1d814 100644
--- a/share/html/Widgets/ComboBox
+++ b/share/html/Widgets/ComboBox
@@ -52,8 +52,6 @@ my $z_index = 9999;
%# reset $z_index. assuming at most 1000 comboboxx in one page
% $z_index = 9999 if $z_index < 9000;
<nobr>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/static/js/combobox.js"></script>
-
<div id="<% $Name %>_Container" class="combobox <%$Class%>" style="z-index: <%$z_index--%>">
<input name="<% $Name %>" id="<% $Name %>" class="combo-text" value="<% $Default || '' %>" type="text" <% $Size ? "size='$Size'" : '' |n %> autocomplete="off" />
<br style="display: none" /><span id="<% $Name %>_Button" class="combo-button">▼</span><select name="List-<% $Name %>" id="<% $Name %>_List" class="combo-list" onchange="ComboBox_SimpleAttach(this, this.form[<% $Name |n,j%>]); " size="<% $Rows %>">
@@ -63,9 +61,6 @@ my $z_index = 9999;
% }
</select>
</div>
-<script language="javascript"><!--
-ComboBox_InitWith(<% $Name |n,j %>);
-//--></script>
</nobr>
<%ARGS>
$Name
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 26f404d..20b32f9 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -547,6 +547,9 @@ jQuery(function() {
}, 'json');
return false;
});
+ jQuery('.combobox input.combo-text').each(function () {
+ ComboBox_Init(this.id)();
+ });
});
// focus jquery object in window, only moving the screen when necessary
commit c4f355c37f8e635bfeeba98c72606b64e2414f42
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Sep 23 17:53:40 2016 +0000
Consider only query params provided by menu item for active status
This fixes a longstanding bug where, e.g. if you reply to a ticket, the
Display page menu item is no longer bolded. This is because the query
string doesn't match exactly, as in:
expected: ?id=1
got: ?id=1&results=hash
The new implementation considers only the query parameters that are
provided in the menu item, so any additional parameters (such as "results"
above) are not included in the comparison. The query parameters that are
provided in the menu item must be considered (as opposed to) because otherwise
you get lots of false positives, especially with the multitude of links
to /Ticket/Update.html with various different query parameters.
This also fixes the menu bolding to occur during pjax page loads, which add a
_pjax=1 query parameter, breaking the old implementation completely.
diff --git a/lib/RT/Interface/Web/Menu.pm b/lib/RT/Interface/Web/Menu.pm
index 3d22a15..20e4db9 100644
--- a/lib/RT/Interface/Web/Menu.pm
+++ b/lib/RT/Interface/Web/Menu.pm
@@ -48,12 +48,14 @@
package RT::Interface::Web::Menu;
+use 5.10.1;
use strict;
use warnings;
use base qw/Class::Accessor::Fast/;
use URI;
+use URI::QueryParam;
use Scalar::Util qw(weaken);
__PACKAGE__->mk_accessors(qw(
@@ -236,18 +238,32 @@ sub child {
# Activate it
if ( defined $path and length $path ) {
- my $base_path = $HTML::Mason::Commands::r->path_info;
- my $query = $HTML::Mason::Commands::m->cgi_object->query_string;
- $base_path =~ s!/+!/!g;
- $base_path .= "?$query" if defined $query and length $query;
+ my $got_path = $HTML::Mason::Commands::r->path_info;
+ $got_path =~ s!/+!/!g;
- $base_path =~ s/index\.html$//;
- $base_path =~ s/\/+$//;
+ $got_path =~ s/index\.html$//;
+ $got_path =~ s/\/+$//;
$path =~ s/index\.html$//;
$path =~ s/\/+$//;
+ (my $base_path = $path) =~ s/[?;#](.*)//;
+
+ # activate this menu item if and only if the base path (ie no
+ # query parameters) match, and any query parameters that are
+ # specified by this menu item are already in ARGS. any additional
+ # ARGS provided (such as "&results=...") are ignored.
+ if ( $base_path eq $got_path ) {
+ my $uri = URI->new($path);
+ my $match = 1;
+
+ for my $key ($uri->query_param) {
+ if (($HTML::Mason::Commands::DECODED_ARGS->{$key}//'') ne $uri->query_param($key)) {
+ $match = 0;
+ last;
+ }
+ }
- if ( $path eq $base_path ) {
- $self->{children}{$key}->active(1);
+ $self->{children}{$key}->active(1)
+ if $match;
}
}
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list