Skip to content

Commit

Permalink
Merge branch '5.0/select-owner-dropdown-delay' into 5.0-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Nov 13, 2023
2 parents f9ac17d + 427cfec commit 16991a0
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 1 deletion.
2 changes: 1 addition & 1 deletion share/html/Elements/RT__Ticket/ColumnMap
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ $COLUMN_MAP = {
title => 'Owner', # loc
attribute => 'Owner',
value => sub { return $_[0]->OwnerObj->Name },
edit => sub { return \($m->scomp('/Elements/SelectOwner', TicketObj => $_[0], Name => 'Owner', Default => $_[0]->OwnerObj->Id, DefaultValue => 0)) },
edit => sub { return \($m->scomp('/Elements/SelectOwner', TicketObj => $_[0], Name => 'Owner', Default => $_[0]->OwnerObj->Id, DefaultValue => 0, Delay => 1)) },
},
Status => {
title => 'Status', # loc
Expand Down
2 changes: 2 additions & 0 deletions share/html/Elements/SelectOwner
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if ( !$QueueObj && !$TicketObj && RT->Config->Get('AutocompleteOwnersForSearch')
$Widget ||= RT->Config->Get('AutocompleteOwners', $session{'CurrentUser'})
? 'Autocomplete' : 'Dropdown';

$Widget = 'DropdownDelay' if $Delay;
my @objects;
if ($TicketObj) {
@objects = ($TicketObj);
Expand Down Expand Up @@ -82,4 +83,5 @@ $m->callback(
$TicketObj => undef
$QueueObj => undef
%Queues => ()
$Delay => 0
</%ARGS>
1 change: 1 addition & 0 deletions share/html/Elements/SelectOwnerDropdown
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ unshift @formatednames, $nobody;
$m->callback( CallbackName => 'ModifyOwnerListSorted', ARGSRef => \%ARGS,
NamesRef => \@formatednames, DefaultRef => \$Default, Objects => $Objects );

$ValueAttribute = 'id' unless ( $ValueAttribute // '' ) =~ /^(?:id|Name)$/;
</%INIT>

<%ARGS>
Expand Down
63 changes: 63 additions & 0 deletions share/html/Elements/SelectOwnerDropdownDelay
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
%# BEGIN BPS TAGGED BLOCK {{{
%#
%# COPYRIGHT:
%#
%# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
%# <[email protected]>
%#
%# (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 }}}
<div class="select-owner-dropdown-delay" data-name="<% $Name // '' %>" data-default="<% $Default // '' %>" data-default-value="<% $DefaultValue // '' %>"
data-default-label="<% $DefaultLabel // '' %>" data-value-attribute="<% $ValueAttribute // '' %>" data-size="<% $Size // '' %>"
data-objects="<% JSON([ map { ref($_) . '-' . $_->id } @$Objects] ) %>"
>
<div class="spinner-border spinner-border-sm loading" role="status"><span class="sr-only">Loading...</span></div>
</div>

<%ARGS>
$Name => undef
$Objects => []
$Default => 0
$DefaultValue => 1
$DefaultLabel => "-"
$ValueAttribute => ''
$Size => 0
</%ARGS>
79 changes: 79 additions & 0 deletions share/html/Helpers/SelectOwnerDropdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
%# BEGIN BPS TAGGED BLOCK {{{
%#
%# COPYRIGHT:
%#
%# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
%# <[email protected]>
%#
%# (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 }}}
<& /Elements/SelectOwnerDropdown, %ARGS, Objects => \@objects &>
% $m->abort;
<%INIT>
my @objects;
for my $item ( @{ JSON::from_json($Objects) || [] } ) {
my ( $class, $id ) = split /-/, $item, 2;
if ( $class && $id && $class =~ /^RT::(?:Ticket|Queue)/ ) {
my $object = $class->new( $session{CurrentUser} );
$object->Load($id);
if ( $object->Id ) {
if ( $object->CurrentUserCanSee ) {
push @objects, $object;
}
else {
$m->abort;
}
}
else {
RT->Logger->info("Couldn't load $item");
$m->abort;
}
}
else {
RT->Logger->info("Invalid object: $item");
$m->abort;
}
}
</%INIT>

<%ARGS>
$Objects => ''
</%ARGS>
48 changes: 48 additions & 0 deletions share/html/SelfService/Helpers/SelectOwnerDropdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
%# BEGIN BPS TAGGED BLOCK {{{
%#
%# COPYRIGHT:
%#
%# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
%# <[email protected]>
%#
%# (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 }}}
% $m->comp('/Helpers/SelectOwnerDropdown', %ARGS);
20 changes: 20 additions & 0 deletions share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,26 @@ jQuery(function () {
beginInlineEdit(cell);
});


jQuery(document).on('mouseenter', 'table.inline-edit td.editable .edit-icon', function (e) {
const owner_dropdown_delay = jQuery(this).closest('.editable').find('div.select-owner-dropdown-delay:not(.loaded)');
if ( owner_dropdown_delay.length ) {
owner_dropdown_delay.load(RT.Config.WebHomePath + '/Helpers/SelectOwnerDropdown', {
Name: owner_dropdown_delay.attr('data-name'),
Default: owner_dropdown_delay.attr('data-default'),
DefaultValue: owner_dropdown_delay.attr('data-default-value'),
DefaultLabel: owner_dropdown_delay.attr('data-default-label'),
ValueAttribute: owner_dropdown_delay.attr('data-value-attribute'),
Size: owner_dropdown_delay.attr('data-size'),
Objects: owner_dropdown_delay.attr('data-objects')
}, function () {
owner_dropdown_delay.addClass('loaded');
refreshSelectpicker(owner_dropdown_delay.find('.selectpicker'));
RT.Autocomplete.bind(owner_dropdown_delay);
});
}
});

jQuery(document).on('change', 'td.editable.editing form :input', function () {
jQuery(this).closest('form').data('changed', true);
});
Expand Down

0 comments on commit 16991a0

Please sign in to comment.