[Rt-commit] rt branch, 4.6/inline-edit, updated. rt-4.4.1-187-gbb2cbc3
Shawn Moore
shawn at bestpractical.com
Tue Dec 27 15:13:50 EST 2016
The branch, 4.6/inline-edit has been updated
via bb2cbc36518a1cd8ebb80abc2afa71cb99dc4e7c (commit)
via c3248e172afa88c7487bfeff6d75f8b156f3d572 (commit)
from 0e40f79855407b1f00c7d18eb554e5d3dab8e52f (commit)
Summary of changes:
etc/RT_Config.pm.in | 55 ++++++++++++++++++++++
lib/RT/Config.pm | 33 +++++++++++++
share/html/Elements/ShowCustomFieldCustomGroupings | 20 ++++++--
share/html/Ticket/Elements/ShowSummary | 53 ++++++++++++++-------
share/html/Widgets/TitleBoxStart | 7 ++-
share/static/js/util.js | 24 ++++++++--
6 files changed, 166 insertions(+), 26 deletions(-)
- Log -----------------------------------------------------------------
commit c3248e172afa88c7487bfeff6d75f8b156f3d572
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Dec 27 19:22:46 2016 +0000
Add support for data- tags on titleboxes
diff --git a/share/html/Widgets/TitleBoxStart b/share/html/Widgets/TitleBoxStart
index c05c126..85e9a50 100644
--- a/share/html/Widgets/TitleBoxStart
+++ b/share/html/Widgets/TitleBoxStart
@@ -45,7 +45,11 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<div class="titlebox<% $class ? " $class " : '' %><% $rolledup ? " rolled-up" : ""%>" id="<% $id %>">
+<div class="titlebox<% $class ? " $class " : '' %><% $rolledup ? " rolled-up" : ""%>" id="<% $id %>"\
+% for my $key (keys %$data) {
+ data-<% $key %>="<% $data->{$key} %>"\
+% }
+>
<div class="titlebox-title<% $title_class ? " $title_class" : ''%>">
% if ($hideable) {
<span class="widget"><a href="#" onclick="return rollup(<%$tid|n,j%>);" title="Toggle visibility"></a></span>
@@ -72,6 +76,7 @@ $titleright_raw => ''
$id => ''
$hideable => 1
$rolledup => 0
+$data => {}
</%ARGS>
<%init>
commit bb2cbc36518a1cd8ebb80abc2afa71cb99dc4e7c
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Dec 27 20:12:27 2016 +0000
Allow fine-tuning inline edit on a panel-by-panel basis
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 4b4dfeb..6caf6ed 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1466,6 +1466,61 @@ pages.
Set($InlineEdit, 1);
+=item C<%InlineEditPanelBehavior>
+
+This setting allows you to control which panels on display pages participate
+in inline edit, as well as fine-tuning their specific behavior.
+
+Much like L</%CustomFieldGroupings>, you first specify a record type you
+want to configure (though since currently only ticket display supports inline
+edit, keys besides C<RT::Ticket> are ignored). Then, for each panel, you
+specify its behavior. The valid behaviors are:
+
+=over 4
+
+=item * link (the default)
+
+The panel will have an "Edit" link in the top right, which when clicked
+immediately activates inline edit. The "Edit" link will change to
+"Cancel" to restore the readonly display.
+
+=item * click
+
+Much like C<link>, except you may click anywhere inside the panel to
+activate inline edit.
+
+=item * hide
+
+Turns off inline edit entirely for this panel.
+
+=item * always
+
+Turns off the readonly display for this panel, providing I<only> inline
+edit capabilities.
+
+=back
+
+You may also provide the special key C<_default> inside a record type to
+specify a default behavior for all panels.
+
+This sample configuration will provide a default inline edit behavior of
+click, but also specifies different behaviors for several other panels.
+Note that the non-standard panel names "Grouping Name" and "Another
+Grouping" are created by the L</%CustomFieldGroupings> setting.
+
+ Set(%InlineEditPanelBehavior,
+ 'RT::Ticket' => {
+ '_default' => 'click',
+
+ 'Grouping Name' => 'link',
+ 'Another Grouping' => 'click',
+ 'Dates' => 'always',
+ 'Links' => 'hide',
+ },
+ );
+
+=cut
+
=back
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 5d3c109..54e4f9f 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -537,6 +537,39 @@ our %META;
}
},
+ InlineEditPanelBehavior => {
+ Type => 'HASH',
+ PostLoadCheck => sub {
+ my $config = shift;
+ # use scalar context intentionally to avoid not a hash error
+ my $behavior = $config->Get('InlineEditPanelBehavior') || {};
+
+ unless (ref($behavior) eq 'HASH') {
+ RT->Logger->error("Config option \%InlineEditPanelBehavior is a @{[ref $behavior]} not a HASH; ignoring");
+ $behavior = {};
+ }
+
+ my %valid = map { $_ => 1 } qw/link click always hide/;
+ for my $class (keys %$behavior) {
+ if (ref($behavior->{$class}) eq 'HASH') {
+ for my $panel (keys %{ $behavior->{$class} }) {
+ my $value = $behavior->{$class}{$panel};
+ if (!$valid{$value}) {
+ RT->Logger->error("Config option \%InlineEditPanelBehavior{$class}{$panel}, which is '$value', must be one of: " . (join ', ', map { "'$_'" } sort keys %valid) . "; ignoring");
+ delete $behavior->{$class}{$panel};
+ }
+ }
+ } else {
+ RT->Logger->error("Config option \%InlineEditPanelBehavior{$class} is not a HASH; ignoring");
+ delete $behavior->{$class};
+ next;
+ }
+ }
+
+ $config->Set( InlineEditPanelBehavior => %$behavior );
+ },
+ },
+
# User overridable locale options
DateTimeFormat => {
Section => 'Locale', #loc
diff --git a/share/html/Elements/ShowCustomFieldCustomGroupings b/share/html/Elements/ShowCustomFieldCustomGroupings
index ad1df06..a82a76e 100644
--- a/share/html/Elements/ShowCustomFieldCustomGroupings
+++ b/share/html/Elements/ShowCustomFieldCustomGroupings
@@ -49,22 +49,29 @@
for my $group ( @Groupings ) {
my $modify_url = $title_href ? "$title_href?id=".$Object->id.($group?";Grouping=".$m->interp->apply_escapes($group,'u')."#".CSSClass("$css_class-$group") : "#".$css_class) : undef;
my $modify_inline = '<a class="inline-edit-toggle" data-edit-label="'.$edit_label.'" data-cancel-label="'.$cancel_label.'" href="'.$m->interp->apply_escapes(($modify_url||'#'), 'h' ).'">'.$edit_label.'</a>';
+ my $modify_behavior = $InlineEdit ? ($inline_edit_behavior{$group} || $inline_edit_behavior{_default} || 'link') : 'hide';
+ my @class = $css_class;
+ push @class, CSSClass("$css_class-$group") if $group;
+ push @class, 'editing' if $modify_behavior eq 'always';
my %grouping_args = (
title => $group? loc($group) : loc('Custom Fields'),
- class => $css_class .' '. ($group? CSSClass("$css_class-$group") : ''),
+ class => (join " ", @class),
hide_empty => 1,
title_href => $modify_url,
- ($InlineEdit ? (titleright_raw => $modify_inline) : ()),
+ ($modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $modify_inline) : ()),
+ data => { 'inline-edit-behavior' => $modify_behavior },
%$TitleBoxARGS,
);
$m->callback( CallbackName => 'TitleBox', Object => $Object, Grouping => $group, ARGSRef => \%grouping_args );
</%perl>
<&| /Widgets/TitleBox, %grouping_args &>
- <div <% $InlineEdit ? 'class="inline-edit-display"' : '' |n%>>
+% unless ($modify_behavior eq 'always') {
+ <div class="inline-edit-display">
<& ShowCustomFields, %ARGS, Object => $Object, Grouping => $group &>
</div>
-% if ($InlineEdit) {
+% }
+% if ($modify_behavior ne 'hide') {
<form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
<input type="hidden" class="hidden" name="id" value="<% $Object->id %>" />
<& /Elements/EditCustomFields, Object => $Object, Grouping => $group, InTable => 0 &>
@@ -89,6 +96,11 @@ $css_class .= '-info-cfs';
my $TitleBoxARGS = delete $ARGS{TitleBoxARGS} || {};
$InlineEdit = 0 unless $Object->isa('RT::Ticket');
+my %inline_edit_behavior;
+if (RT->Config->Get('InlineEditPanelBehavior')) {
+ %inline_edit_behavior = %{ RT->Config->Get('InlineEditPanelBehavior')->{RT::CustomField->_GroupingClass($Object)} || {} };
+}
+
my $edit_label = $m->interp->apply_escapes( loc("Edit"), 'h' );
my $cancel_label = $m->interp->apply_escapes( loc("Cancel"), 'h' );
diff --git a/share/html/Ticket/Elements/ShowSummary b/share/html/Ticket/Elements/ShowSummary
index 49fd8af..bc487ef 100644
--- a/share/html/Ticket/Elements/ShowSummary
+++ b/share/html/Ticket/Elements/ShowSummary
@@ -53,17 +53,21 @@
<%PERL>
my $modify_url = RT->Config->Get('WebPath')."/Ticket/Modify.html?id=".$Ticket->Id;
my $modify_inline = '<a class="inline-edit-toggle" data-edit-label="'.$edit_label.'" data-cancel-label="'.$cancel_label.'" href="'.$m->interp->apply_escapes($modify_url, 'h' ).'">'.$edit_label.'</a>';
+my $modify_behavior = $InlineEdit ? ($inline_edit_behavior{Basics} || $inline_edit_behavior{_default} || 'link') : 'hide';
</%PERL>
<&| /Widgets/TitleBox, title => loc('The Basics'),
(($can_modify || $can_modify_cf) ? (title_href => $modify_url) : ()),
- ($InlineEdit ? (titleright_raw => $modify_inline) : ()),
- class => 'ticket-info-basics',
+ ($modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $modify_inline) : ()),
+ class => (join " ", 'ticket-info-basics', ($modify_behavior eq 'always' ? 'editing' : ())),
+ data => { 'inline-edit-behavior' => $modify_behavior },
&>
- <div <% $InlineEdit ? 'class="inline-edit-display"' : '' |n%>>
- <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
- </div>
-% if ($InlineEdit) {
+% unless ($modify_behavior eq 'always') {
+ <div class="inline-edit-display">
+ <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
+ </div>
+% }
+% if ($modify_behavior ne 'hide') {
<form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<table>
@@ -110,16 +114,20 @@ my $modify_inline = '<a class="inline-edit-toggle" data-edit-label="'.$edit_labe
<%PERL>
my $dates_url = RT->Config->Get('WebPath')."/Ticket/ModifyDates.html?id=".$Ticket->Id;
my $dates_inline = '<a class="inline-edit-toggle" data-edit-label="'.$edit_label.'" data-cancel-label="'.$cancel_label.'" href="'.$m->interp->apply_escapes($dates_url, 'h' ).'">'.$edit_label.'</a>';
+my $dates_behavior = $InlineEdit ? ($inline_edit_behavior{Dates} || $inline_edit_behavior{_default} || 'link') : 'hide';
</%PERL>
<&| /Widgets/TitleBox, title => loc("Dates"),
($can_modify ? (title_href => $dates_url) : ()),
- class => 'ticket-info-dates',
- ($InlineEdit ? (titleright_raw => $dates_inline) : ()),
+ class => (join " ", 'ticket-info-dates', ($dates_behavior eq 'always' ? 'editing' : ())),
+ ($dates_behavior =~ /^(link|click)$/ ? (titleright_raw => $dates_inline) : ()),
+ data => { 'inline-edit-behavior' => $dates_behavior },
&>
- <div <% $InlineEdit ? 'class="inline-edit-display"' : '' |n%>>
- <& /Ticket/Elements/ShowDates, Ticket => $Ticket &>
- </div>
-% if ($InlineEdit) {
+% unless ($dates_behavior eq 'always') {
+ <div class="inline-edit-display">
+ <& /Ticket/Elements/ShowDates, Ticket => $Ticket &>
+ </div>
+% }
+% if ($dates_behavior ne 'hide') {
<form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<& /Ticket/Elements/EditDates, TicketObj => $Ticket &>
@@ -132,10 +140,11 @@ my $dates_inline = '<a class="inline-edit-toggle" data-edit-label="'.$edit_label
<%PERL>
my $links_url = RT->Config->Get('WebPath')."/Ticket/ModifyLinks.html?id=".$Ticket->Id;
my $links_inline = '<a class="inline-edit-toggle" data-edit-label="'.$edit_label.'" data-cancel-label="'.$cancel_label.'" href="'.$m->interp->apply_escapes($links_url, 'h' ).'">'.$edit_label.'</a>';
+my $links_behavior = $InlineEdit ? ($inline_edit_behavior{Links} || $inline_edit_behavior{_default} || 'link') : 'hide';
my $links_graph = '<a href="'. RT->Config->Get('WebPath'). '/Ticket/Graphs/index.html?id='.$Ticket->id.'">'.loc('Graph').'</a>';
my $links_titleright = join ' ',
- ($InlineEdit ? $links_inline : ()),
+ ($links_behavior =~ /^(link|click)$/ ? ($links_inline) : ()),
(RT->Config->Get('DisableGraphViz') ? () : $links_graph);
my @extra;
push @extra, (titleright_raw => $links_titleright) if $links_titleright;
@@ -143,13 +152,16 @@ push @extra, (titleright_raw => $links_titleright) if $links_titleright;
% $m->callback( %ARGS, CallbackName => 'LinksExtra', extra => \@extra );
<&| /Widgets/TitleBox, title => loc('Links'),
($can_modify ? (title_href => $links_url) : ()),
- class => 'ticket-info-links',
+ class => (join " ", 'ticket-info-links', ($links_behavior eq 'always' ? 'editing' : ())),
+ data => { 'inline-edit-behavior' => $links_behavior },
@extra,
&>
- <div <% $InlineEdit ? 'class="inline-edit-display"' : '' |n%>>
- <& /Elements/ShowLinks, Object => $Ticket &>
- </div>
-% if ($InlineEdit) {
+% unless ($links_behavior eq 'always') {
+ <div class="inline-edit-display">
+ <& /Elements/ShowLinks, Object => $Ticket &>
+ </div>
+% }
+% if ($links_behavior ne 'hide') {
<form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<& /Elements/EditLinks, Object => $Ticket, TwoColumn => 0 &>
@@ -179,4 +191,9 @@ my $can_modify_people = $Ticket->CurrentUserHasRight('Watch')
my $edit_label = $m->interp->apply_escapes( loc("Edit"), 'h' );
my $cancel_label = $m->interp->apply_escapes( loc("Cancel"), 'h' );
+
+my %inline_edit_behavior;
+if (RT->Config->Get('InlineEditPanelBehavior')) {
+ %inline_edit_behavior = %{ RT->Config->Get('InlineEditPanelBehavior')->{'RT::Ticket'} || {} };
+}
</%INIT>
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 08743f2..4b73134 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -783,9 +783,8 @@ jQuery(function () {
table.css('table-layout', 'fixed');
});
- jQuery('.inline-edit-toggle').click(function (e) {
- e.preventDefault();
- var link = jQuery(this);
+ /* inline edit on ticket display */
+ var toggle_inline_edit = function (link) {
var container = link.closest('.titlebox');
container.toggleClass('editing');
if (container.hasClass('editing')) {
@@ -794,6 +793,25 @@ jQuery(function () {
else {
link.text(link.data('edit-label'));
}
+ }
+
+ jQuery('.inline-edit-toggle').click(function (e) {
+ e.preventDefault();
+ var link = jQuery(this);
+ toggle_inline_edit(link);
+ });
+
+ jQuery('.titlebox[data-inline-edit-behavior="click"] > .titlebox-content').click(function (e) {
+ if (jQuery(e.target).is('a, input, select, textarea')) {
+ return;
+ }
+
+ e.preventDefault();
+ var container = jQuery(this).closest('.titlebox');
+ if (container.hasClass('editing')) {
+ return;
+ }
+ toggle_inline_edit(container.find('.inline-edit-toggle'));
});
});
-----------------------------------------------------------------------
More information about the rt-commit
mailing list