[Rt-commit] rtir branch, 5.0/allow-inline-edit-on-ticket-display, created. 5.0.0-18-g1b471554

Craig Kaiser craig at bestpractical.com
Wed Nov 18 09:45:54 EST 2020


The branch, 5.0/allow-inline-edit-on-ticket-display has been created
        at  1b4715541eb156eb3549c61fa396808a7e4f8ab7 (commit)

- Log -----------------------------------------------------------------
commit 1717af7a072fd9a71544430a4e5a2b24694c5ceb
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Nov 18 08:42:04 2020 -0500

    Add inline edit to 'The Basics' section

diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index c8358da9..49c5f359 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -59,61 +59,146 @@
   <div class="boxcontainer col-md-6">
 % $m->callback( %ARGS, Ticket => $Ticket, CallbackName => 'LeftColumnStart' );
 
+<%PERL>
+my $edit_label = $m->interp->apply_escapes( loc("Edit"), 'h' );
+my $cancel_label = $m->interp->apply_escapes( loc("Cancel"), 'h' );
+
+my $modify_url = RT->Config->Get('WebPath')."/RTIR/Display.html?id=".$Ticket->Id;
+my $modify_inline
+    = '<a class="inline-edit-toggle edit" href="%s">'
+    . qq{<span class="fas fa-pencil-alt icon-bordered fa-2x" alt="$edit_label" data-toggle="tooltip" data-placement="top" data-original-title="$edit_label"></span>}
+    . '</a>'
+    . '<a class="inline-edit-toggle cancel hidden" href="#">'
+    . qq{<span class="fas fa-times icon-bordered fa-2x" alt="$cancel_label" data-toggle="tooltip" data-placement="top" data-original-title="$cancel_label"></span>}
+    . '</a>';
+my $modify_basics = sprintf( $modify_inline, $m->interp->apply_escapes( $modify_url, 'h' ) );
+my $modify_behavior = $inline_edit_behavior{Basics} || $inline_edit_behavior{_default} || 'link';
+</%PERL>
+
 <&| /Widgets/TitleBox,
     title => loc("The Basics"),
-    title_href  => RT::IR->HREFTo("Edit.html?id=".$Ticket->Id),
+    title_href  => RT::IR->HREFTo("Display.html?id=".$Ticket->Id),
     class => 'ticket-info-basics',
+    data => { 'inline-edit-behavior' => 1 },
+    (($can_modify || $can_modify_cf) && $modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $modify_basics) : ()),
+    class => (join " ", ($modify_behavior eq 'always' ? 'editing' : ())),
+    data => { 'inline-edit-behavior' => $modify_behavior },
 &>
-    <div>
+
+% unless ($modify_behavior eq 'always') {
+  <div class="inline-edit-display">
+% if (my $constituency = RT::IR->ConstituencyFor($Ticket)) {
+    <div class="form-row">
+      <div class="label col-3">
+        <% loc("Constituency") %>:
+      </div>
+      <div class="value col-9">
+        <span class="current-value"><% $constituency %></span>
+      </div>
+    </div>
+% }
+    <div class="form-row">
+      <div class="label col-3">
+        <% loc("Status") %>:
+      </div>
+      <div class="value col-9">
+        <span class="current-value"><% $Ticket->Status %></span>
+      </div>
+    </div>
+% if ( !$Ticket->QueueObj->SLADisabled ) {
+    <div class="form-row">
+      <div class="label col-3">
+        <&|/l&>SLA</&>:
+      </div>
+      <div class="value col-9">
+        <span class="current-value"><% loc($Ticket->SLA) %></span>
+      </div>
+    </div>
+% }
+    <div class="form-row">
+      <div class="label col-3">
+        <% loc("Incident") %>:
+      </div>
+      <div class="value col-9">
+        <& /RTIR/Elements/ShowIncidents, Ticket => $Ticket, InlineEdit => 0 &>
+      </div>
+    </div>
+    <div class="form-row">
+      <div class="label col-3">
+        <&|/l&>Time Worked</&>:
+      </div>
+      <div class="value col-9">
+        <span class="current-value"><%loc('[_1] min', $TimeWorked)%></span>
+      </div>
+    </div>
+
+    <& /Elements/ShowCustomFields, Grouping => 'Basics', Object => $Ticket, Table => 0 &>
+
+  </div>
+% }
+% if ($modify_behavior ne 'hide') {
+  <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/RTIR/Display.html" method="post" enctype="multipart/form-data">
+    <input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
+
 % if (my $constituency = RT::IR->ConstituencyFor($Ticket)) {
-      <div class="form-row">
-        <div class="label col-3">
-          <% loc("Constituency") %>:
-        </div>
-        <div class="value col-9">
-          <span class="current-value"><% $constituency %></span>
-        </div>
+    <div class="form-row">
+      <div class="label col-3">
+        <% loc("Constituency") %>:
+      </div>
+      <div class="value col-9">
+        <span class="current-value"><% $constituency %></span>
       </div>
+    </div>
 % }
-      <div class="form-row">
-        <div class="label col-3">
-          <% loc("Status") %>:
-        </div>
-        <div class="value col-9">
-          <span class="current-value"><% $Ticket->Status %></span>
-        </div>
+    <div class="form-row">
+      <div class="label col-3">
+        <% loc("Status") %>:
       </div>
+      <div class="value col-9">
+        <span class="current-value"><% $Ticket->Status %></span>
+      </div>
+    </div>
 % if ( !$Ticket->QueueObj->SLADisabled ) {
-      <div class="form-row">
-        <div class="label col-3">
-          <&|/l&>SLA</&>:
-        </div>
-        <div class="value col-9">
-          <span class="current-value"><% loc($Ticket->SLA) %></span>
-        </div>
+    <div class="form-row">
+      <div class="label col-3">
+        <&|/l&>SLA</&>:
       </div>
+      <div class="value col-9">
+        <& /Elements/SelectSLA, Default => $Ticket->SLA, TicketObj => $Ticket &>
+      </div>
+    </div>
 % }
-      <div class="form-row">
-        <div class="label col-3">
-          <% loc("Incident") %>:
-        </div>
-        <div class="value col-9">
-          <& /RTIR/Elements/ShowIncidents, Ticket => $Ticket &>
-        </div>
+    <div class="form-row">
+      <div class="label col-3">
+        <% loc("Incident") %>:
+      </div>
+      <div class="value col-9">
+        <& /RTIR/Elements/ShowIncidents, Ticket => $Ticket, InlineEdit => 0 &>
+      </div>
+    </div>
+    <div class="form-row">
+      <div class="label col-3">
+        <&|/l&>Time Worked</&>:
       </div>
-      <div class="form-row">
-        <div class="label col-3">
-          <&|/l&>Time Worked</&>:
-        </div>
-        <div class="value col-9">
-          <span class="current-value"><%loc('[_1] min', $TimeWorked)%></span>
-        </div>
+      <div class="value col-9">
+        <& /Elements/EditTimeValue,
+            Name    => 'TimeWorked',
+            Default => $ARGS{'TimeWorked'} || $Ticket->TimeWorked || '',
+            Ticket  => $Ticket
+        &>
       </div>
+    </div>
 
-  <& /Elements/ShowCustomFields, Grouping => 'Basics', Object => $Ticket, Table => 0 &>
+    <& /Elements/EditCustomFields, Grouping => 'Basics', Object => $Ticket, Table => 0 &>
 
+    <div class="form-row">
+      <div class="col-12 text-right">
+        <input type="submit" class="button btn btn-primary" value="<&|/l&>Save</&>" />
+      </div>
     </div>
 
+  </form>
+% }
 </&>
 
 <& /Elements/ShowCustomFieldCustomGroupings,
@@ -195,6 +280,16 @@ unless ( $id eq 'new' ) {
     $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
 }
 
+my %inline_edit_behavior;
+if (RT->Config->Get('InlineEditPanelBehavior')) {
+    %inline_edit_behavior = %{ RT->Config->Get('InlineEditPanelBehavior')->{'RT::Ticket'} || {} };
+}
+my $can_modify = $Ticket->CurrentUserHasRight('ModifyTicket');
+my $can_modify_cf = $Ticket->CurrentUserHasRight('ModifyCustomField');
+my ($can_modify_owner) = $Ticket->CurrentUserCanSetOwner();
+my $can_modify_people = $Ticket->CurrentUserHasRight('Watch')
+                     || $Ticket->CurrentUserHasRight('WatchAsAdminCc');
+
 my $Type = RT::IR::TicketType( Lifecycle => $QueueObj->Lifecycle );
 # If it's not an RTIR ticket type, just show the regular 
 # RT ticket display page

commit 6605b6fe7c08a3ca855b35c7c84f9a611f914d54
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Nov 18 08:47:33 2020 -0500

    Add inline edit for custom field groupings on ticket display

diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index 49c5f359..0c4eda6b 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -201,9 +201,10 @@ my $modify_behavior = $inline_edit_behavior{Basics} || $inline_edit_behavior{_de
 % }
 </&>
 
-<& /Elements/ShowCustomFieldCustomGroupings,
+<& /RTIR/Elements/ShowCustomFieldCustomGroupings,
     Object       => $Ticket,
-    title_href => RT::IR->HREFTo("Edit.html"),
+    title_href   => RT::IR->HREFTo("Edit.html"),
+    InlineEdit   => 1
 &>
 
 <& /RTIR/Elements/ShowArticles, Ticket => $Ticket &>
@@ -346,6 +347,8 @@ if ( $id eq 'new' ) {
 
     push @results, ProcessTicketBasics(  TicketObj => $Ticket, ARGSRef => \%ARGS );
 
+    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $Ticket );
+
     my $strict_acl = RT->Config->Set( StrictLinkACL => 0 );
     push @results, ProcessTicketLinks(   TicketObj => $Ticket, ARGSRef => \%ARGS );
     RT->Config->Set( StrictLinkACL => $strict_acl );
diff --git a/html/RTIR/Elements/ShowCustomFieldCustomGroupings b/html/RTIR/Elements/ShowCustomFieldCustomGroupings
new file mode 100644
index 00000000..846a925f
--- /dev/null
+++ b/html/RTIR/Elements/ShowCustomFieldCustomGroupings
@@ -0,0 +1,132 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2020 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%perl>
+for my $group ( @Groupings ) {
+    my $CustomFields = $Object->CustomFields;
+    $m->callback(
+        Table        => 1, # default is true
+        %ARGS,
+        CallbackPage => '/Elements/ShowCustomFields',
+        CallbackName => 'MassageCustomFields',
+        Object       => $Object,
+        CustomFields => $CustomFields,
+    );
+
+    $CustomFields->LimitToGrouping( $Object => $group );
+    next unless $CustomFields->First;
+
+    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 edit" href="'
+        . $m->interp->apply_escapes( ( $modify_url || '#' ), 'h' ) . '">'
+        . qq{<span class="fas fa-pencil-alt icon-bordered fa-2x" alt="$edit_label" data-toggle="tooltip" data-placement="top" data-original-title="$edit_label"></span>}
+        . '</a>'
+        . '<a class="inline-edit-toggle cancel hidden" href="#">'
+        . qq{<span class="fas fa-times icon-bordered fa-2x" alt="$cancel_label" data-toggle="tooltip" data-placement="top" data-original-title="$cancel_label"></span>}
+        . '</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 => (join " ", @class),
+        hide_empty => 1,
+        title_href => $modify_url,
+        ($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 &>
+% unless ($modify_behavior eq 'always') {
+  <div class="inline-edit-display">
+    <& /Elements/ShowCustomFields, %ARGS, Object => $Object, Grouping => $group &>
+  </div>
+% }
+% if ($modify_behavior ne 'hide') {
+  <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/RTIR/Display.html" method="post" enctype="multipart/form-data">
+    <input type="hidden" class="hidden" name="id" value="<% $Object->id %>" />
+    <& /Elements/EditCustomFields, Object => $Object, Grouping => $group, InTable => 0 &>
+    <div class="form-row">
+      <div class="col-12 text-right">
+        <input type="submit" class="button btn btn-primary" value="<&|/l&>Save</&>" />
+      </div>
+    </div>
+  </form>
+% }
+</&>
+% }
+<%ARGS>
+$Object
+$title_href => ""
+$InlineEdit => 0
+ at Groupings => ()
+</%ARGS>
+<%INIT>
+my $css_class = lc(ref($Object)||$Object);
+$css_class =~ s/^rt:://;
+$css_class =~ s/::/-/g;
+$css_class = CSSClass($css_class);
+$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' );
+
+ at Groupings = (RT::CustomField->CustomGroupings( $Object ), '') unless @Groupings;
+</%INIT>

commit 88a45696a406df599b5647a9b553d94ceed121d9
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Nov 18 09:35:40 2020 -0500

    Add inline edit for peoples portlet

diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index 0c4eda6b..a507db79 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -216,12 +216,36 @@ my $modify_behavior = $inline_edit_behavior{Basics} || $inline_edit_behavior{_de
   <div class="boxcontainer col-md-6">
 % $m->callback( %ARGS, Ticket => $Ticket, CallbackName => 'RightColumnStart' );
 
+<%PERL>
+  my $people_url = RT->Config->Get('WebPath')."/Ticket/ModifyPeople.html?id=".$Ticket->Id;
+  my $people_inline = sprintf( $modify_inline, $m->interp->apply_escapes( $people_url, 'h' ) );
+  my $people_behavior = $inline_edit_behavior{People} || $inline_edit_behavior{_default} || 'link';
+</%PERL>
+
     <&| /Widgets/TitleBox,
-        title => loc('People'), 
-        title_href  => RT::IR->HREFTo("Edit.html?id=". $Ticket->Id),
-        class => 'ticket-info-people',
+        title => loc('People'),
+        (($can_modify || $can_modify_owner || $can_modify_people) ? (title_href => RT->Config->Get('WebPath')."/RTIR/Edit.html?id=".$Ticket->Id) : ()),
+        class => (join " ", 'ticket-info-people', ($people_behavior eq 'always' ? 'editing' : ())),
+        (($can_modify || $can_modify_owner || $can_modify_people) && $people_behavior =~ /^(link|click)$/ ? (titleright_raw => $people_inline) : ()),
+        data => { 'inline-edit-behavior' => $people_behavior },
     &>
+
+% unless ($people_behavior eq 'always') {
+  <div class="inline-edit-display">
     <& /RTIR/Elements/ShowPeople, Ticket => $Ticket &>
+  </div>
+% }
+% if ($people_behavior ne 'hide') {
+  <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/RTIR/Display.html" method="post" enctype="multipart/form-data">
+    <input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
+    <& /RTIR/Elements/EditPeople, Ticket => $Ticket &>
+    <div class="form-row">
+      <div class="col-12 text-right">
+        <input type="submit" class="button btn btn-primary" value="<&|/l&>Save</&>" />
+      </div>
+    </div>
+  </form>
+% }
     </&>
     <&| /Widgets/TitleBox, title => loc("Dates"),
     title_href  => RT::IR->HREFTo("Edit.html?id=". $Ticket->Id),

commit 1b4715541eb156eb3549c61fa396808a7e4f8ab7
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Nov 18 09:35:58 2020 -0500

    Add inline edit for dates portlet

diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index a507db79..6da34f62 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -247,11 +247,36 @@ my $modify_behavior = $inline_edit_behavior{Basics} || $inline_edit_behavior{_de
   </form>
 % }
     </&>
-    <&| /Widgets/TitleBox, title => loc("Dates"),
-    title_href  => RT::IR->HREFTo("Edit.html?id=". $Ticket->Id),
+
+<%PERL>
+  my $dates_url = RT->Config->Get('WebPath')."/Ticket/ModifyDates.html?id=".$Ticket->Id;
+  my $dates_inline = sprintf( $modify_inline, $m->interp->apply_escapes( $dates_url, 'h' ) );
+  my $dates_behavior = $inline_edit_behavior{Dates} || $inline_edit_behavior{_default} || 'link';
+</%PERL>
+
+    <&| /Widgets/TitleBox,
+        title => loc("Dates"),
+        ($can_modify ? (title_href => $dates_url) : ()),
         class => 'ticket-info-dates',
+        ($can_modify && $dates_behavior =~ /^(link|click)$/ ? (titleright_raw => $dates_inline) : ()),
+        data => { 'inline-edit-behavior' => $dates_behavior },
     &>
-    <& /RTIR/Elements/ShowDates, Ticket => $Ticket &>
+% unless ($modify_behavior eq 'always') {
+    <div class="inline-edit-display">
+      <& /RTIR/Elements/ShowDates, Ticket => $Ticket &>
+    </div>
+% }
+% if ($modify_behavior ne 'hide') {
+    <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/RTIR/Display.html" method="post" enctype="multipart/form-data">
+      <input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
+      <& /Ticket/Elements/EditDates, TicketObj => $Ticket &>
+      <div class="form-row">
+        <div class="col-12 text-right">
+          <input type="submit" class="button btn btn-primary" value="<&|/l&>Save</&>" />
+        </div>
+      </div>
+    </form>
+% }
     </&>
 % $m->callback( %ARGS, Ticket => $Ticket, CallbackName => 'BeforeRequestor' );
     <br />  

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


More information about the rt-commit mailing list