Skip to content

Commit

Permalink
Merge branch '6.0/reformat-ticket-basics'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Dec 5, 2024
2 parents 6e6f5a2 + 84f04cb commit 9c14eaf
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 85 deletions.
10 changes: 10 additions & 0 deletions lib/RT/Test/Selenium.pm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ sub scroll_to {
$self->execute_script( $script, $selector );
}

sub click {
my $self = shift;
my $selector = shift;

$self->scroll_to($selector);
my $element = $self->find_element( selector_to_xpath($selector) );
$element->click;
return $element;
}

sub login {
my $self = shift;
my $user = shift || 'root';
Expand Down
2 changes: 1 addition & 1 deletion share/html/Helpers/TicketUpdate
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if ( !$checks_failure ) {
push @events, 'ticketOwnerChanged' if @owner_changes;
push @events, 'ticketMessageChanged' if @message_changes;
push @events, 'ticketWatchersChanged' if @watchers_changes;
push @events, 'ticketBasicsChanged' if @basics_changes;
push @events, 'ticketBasicsChanged' if @basics_changes || @owner_changes;
push @events, 'ticketLinksChanged' if @links_changes;
push @events, 'ticketDatesChanged' if @dates_changes;
push @events, 'ticketCustomFieldsChanged' if @cfs_changes;
Expand Down
31 changes: 20 additions & 11 deletions share/html/Ticket/Elements/EditBasics
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $InTable => 0
%defaults => ()
$ExcludeCustomRoles => 0
$ExcludeOwner => 0
$DelayOwner => 0
$ReadOnly => 0
</%ARGS>
<%INIT>
Expand Down Expand Up @@ -96,21 +97,11 @@ unless ( @fields ) {
TicketObj => $TicketObj,
Default => $defaults{'Owner'} || $TicketObj->OwnerObj->Id,
DefaultValue => 0,
Delay => $DelayOwner,
ReadOnly => $ReadOnly,
},
labelfor => 'SelectOwner',
},
$QueueObj->SLADisabled ? () : (
{ name => 'SLA',
comp => '/Elements/SelectSLA',
args => {
Name => 'SLA',
Default => $defaults{SLA},
DefaultFromArgs => 0,
TicketObj => $TicketObj,
},
labelfor => 'SelectSLA',
}),
# Priority and Final Priority
(
map {
Expand All @@ -128,6 +119,17 @@ unless ( @fields ) {
}
} ('Priority', 'Final Priority')
),
$QueueObj->SLADisabled ? () : (
{ name => 'SLA',
comp => '/Elements/SelectSLA',
args => {
Name => 'SLA',
Default => $defaults{SLA},
DefaultFromArgs => 0,
TicketObj => $TicketObj,
},
labelfor => 'SelectSLA',
}),
{ special => 'roles' },
);
}
Expand Down Expand Up @@ -190,6 +192,13 @@ for my $field (@fields) {
ReadOnly => 0,
&>
% }

% if ( $TicketObj && $TicketObj->Id ) {
<div class="edit-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditCustomFields?ObjectType=RT::Ticket&ObjectId=<% $TicketObj->Id %>&Grouping=Basics&InTable=1" hx-swap="innerHTML">
<& /Elements/EditCustomFields, Object => $TicketObj, Grouping => 'Basics', InTable => 1 &>
</div>
% }

% $m->callback( CallbackName => 'EndOfList', TicketObj => $TicketObj, %ARGS, Fields => \@fields );
% unless ($InTable) {
</div>
Expand Down
48 changes: 33 additions & 15 deletions share/html/Ticket/Elements/ShowBasics
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,49 @@
%#
%# END BPS TAGGED BLOCK }}}
<div class="row">
<div class="col-lg">
<& /Elements/LabeledValue, Class => 'id',Label => loc("Id"), Value => $Ticket->id &>
<div class="col-sm">
<& /Elements/LabeledValue, Class => 'id',Label => loc("Id"), Value => $Ticket->id &>
</div>
<div class="col-sm">
%# This will check SeeQueue at the ticket role level, queue level, and global level
% if ($Ticket->CurrentUserHasRight('SeeQueue')) {
<& /Elements/LabeledValue, Class =>"queue",Label => loc("Queue"), ValueSpanClass => "current-value", RawValue => $m->scomp("ShowQueue", Ticket => $Ticket, QueueObj => $Ticket->QueueObj) &>
<& /Elements/LabeledValue, Class =>"queue",Label => loc("Queue"), ValueSpanClass => "current-value", RawValue => $m->scomp("ShowQueue", Ticket => $Ticket, QueueObj => $Ticket->QueueObj) &>
% }
% $m->callback( %ARGS, CallbackName => 'AfterQueue', TicketObj => $Ticket );
<& /Elements/LabeledValue, Class => 'status',Label => loc("Status"), Value => loc($Ticket->Status), ValueSpanClass => "current-value" &>
</div>
<div class="col-sm">
<& /Elements/LabeledValue, Class => 'status',Label => loc("Status"), Value => loc($Ticket->Status), ValueSpanClass => "current-value" &>
</div>
</div>
<div class="row">
<div class="col-sm">
<&| /Elements/LabeledValue, Label => loc("Owner"), LabelFor => 'Owner' &>
<& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket &><br />
<& /Elements/ShowUserEmailFrequency, User => $Ticket->OwnerObj, Ticket => $Ticket &>
</&>
</div>
<div class="col-sm">
<& /Elements/LabeledValue, Class => "priority", Label => loc("Priority"), ValueSpanClass => "current-value", RawValue => $m->scomp("ShowPriority", Ticket => $Ticket ) &>
% $m->callback( %ARGS, CallbackName => 'AfterPriority', TicketObj => $Ticket );
</div>
<div class="col-sm">
% if ( !$Ticket->QueueObj->SLADisabled ) {
<& /Elements/LabeledValue, Class => "sla",Label => loc("SLA"), Value => loc($Ticket->SLA), ValueSpanClass => "current_value" &>
<& /Elements/LabeledValue, Class => "sla",Label => loc("SLA"), Value => loc($Ticket->SLA), ValueSpanClass => "current_value" &>
% }
<& /Elements/LabeledValue, Class => "priority", Label => loc("Priority"), ValueSpanClass => "current-value", RawValue => $m->scomp("ShowPriority", Ticket => $Ticket ) &>
% $m->callback( %ARGS, CallbackName => 'AfterPriority', TicketObj => $Ticket );
</div>

<div class="show-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/ShowCustomFields?ObjectType=RT::Ticket&ObjectId=<% $Ticket->Id %>&Grouping=Basics">
<& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket, Grouping => 'Basics', Table => 0 &>
</div>
</div>
<div class="row">
<div class="col">
<div class="show-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/ShowCustomFields?ObjectType=RT::Ticket&ObjectId=<% $Ticket->Id %>&Grouping=Basics">
<& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket, Grouping => 'Basics', Table => 0 &>
</div>
% if ($UngroupedCFs) {
<div class="show-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/ShowCustomFields?ObjectType=RT::Ticket&ObjectId=<% $Ticket->Id %>&Grouping=">
<& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket, Grouping => '', Table => 0 &>
</div>
<div class="show-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/ShowCustomFields?ObjectType=RT::Ticket&ObjectId=<% $Ticket->Id %>&Grouping=">
<& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket, Grouping => '', Table => 0 &>
</div>
% }
% $m->callback( %ARGS, CallbackName => 'EndOfList', TicketObj => $Ticket );

</div>
</div>
% $m->callback( %ARGS, CallbackName => 'AfterTable', TicketObj => $Ticket );
<%ARGS>
Expand Down
3 changes: 0 additions & 3 deletions share/html/Ticket/Elements/ShowSummary
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ my $modify_behavior = $InlineEdit ? ($inline_edit_behavior{Basics} || $inline_ed
<form hx-post="<%RT->Config->Get('WebPath')%>/Helpers/TicketUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<& /Ticket/Elements/EditBasics, TicketObj => $Ticket, InTable => 1, ExcludeOwner => 1, ExcludeCustomRoles => 1 &>
<div class="edit-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditCustomFields?ObjectType=RT::Ticket&ObjectId=<% $Ticket->Id %>&Grouping=Basics&InTable=1" hx-swap="innerHTML">
<& /Elements/EditCustomFields, Object => $Ticket, Grouping => 'Basics', InTable => 1 &>
</div>
<div class="row mt-2">
<div class="col-12 text-end">
<input type="submit" class="button btn btn-primary" value="<&|/l&>Save</&>" />
Expand Down
1 change: 0 additions & 1 deletion share/html/Ticket/ModifyAll.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<div class="col-lg">
<&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
<& Elements/EditBasics, TicketObj => $Ticket, defaults => \%ARGS, ExcludeCustomRoles => 1, InTable => 1 &>
<& /Elements/EditCustomFields, %ARGS, Object => $Ticket, Grouping => 'Basics', InTable => 1 &>
</&>
% $m->callback(CallbackName => 'AfterBasics', Ticket => $Ticket);
</div>
Expand Down
30 changes: 15 additions & 15 deletions share/html/Ticket/Widgets/Create/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,8 @@

{ special => 'roles' },

$Queue->SLADisabled
? ()
: (
{
name => 'SLA',
comp => '/Elements/SelectSLA',
args => {
Name => "SLA",
Default => $ARGS{SLA} || RT::SLA->GetDefaultServiceLevel( Queue => $Queue ),
DefaultValue => RT::SLA->GetDefaultServiceLevel( Queue => $Queue ) ? 0 : 1,
QueueObj => $Queue,
},
}
),
{
name => 'InitialPriority',
name => 'Priority',
comp => '/Elements/SelectPriority',
args => {
Name => "InitialPriority",
Expand All @@ -117,6 +103,20 @@
QueueObj => $Queue,
},
},
$Queue->SLADisabled
? ()
: (
{
name => 'SLA',
comp => '/Elements/SelectSLA',
args => {
Name => "SLA",
Default => $ARGS{SLA} || RT::SLA->GetDefaultServiceLevel( Queue => $Queue ),
DefaultValue => RT::SLA->GetDefaultServiceLevel( Queue => $Queue ) ? 0 : 1,
QueueObj => $Queue,
},
}
),
]
&>

Expand Down
21 changes: 17 additions & 4 deletions share/html/Ticket/Widgets/Display/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="ticketBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowBasics?id=<% $Ticket->id %>">
<& /Ticket/Elements/ShowBasics, Ticket => $Ticket, InTable => 1, ExcludeOwner => 1, ExcludeCustomRoles => 1 &>
<& /Ticket/Elements/ShowBasics, Ticket => $Ticket, InTable => 1, ExcludeCustomRoles => 1 &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form hx-post="<%RT->Config->Get('WebPath')%>/Helpers/TicketUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<& /Ticket/Elements/EditBasics, TicketObj => $Ticket, InTable => 1, ExcludeOwner => 1, ExcludeCustomRoles => 1 &>
<div class="edit-custom-fields-container" hx-trigger="none" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditCustomFields?ObjectType=RT::Ticket&ObjectId=<% $Ticket->Id %>&Grouping=Basics&InTable=1" hx-swap="innerHTML">
<& /Elements/EditCustomFields, Object => $Ticket, Grouping => 'Basics', InTable => 1 &>

<div hx-trigger="ticketBasicsChanged from:body, ticketOwnerChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditBasics?id=<% $Ticket->id %>" hx-swap="innerHTML">
<& /Ticket/Elements/EditBasics, TicketObj => $Ticket, InTable => 1, ExcludeOwner => $exclude_owner, ExcludeCustomRoles => 1, DelayOwner => $delay_owner &>
</div>
<div class="row mt-2">
<div class="col-12 text-end">
Expand All @@ -87,6 +87,19 @@ my $modify_behavior

my $can_modify = $Ticket->CurrentUserHasRight('ModifyTicket');
my $can_modify_cf = $Ticket->CurrentUserHasRight('ModifyCustomField');
my ($can_modify_owner) = $Ticket->CurrentUserCanSetOwner();

my $exclude_owner = 1;
if ( $can_modify_owner ) {
$exclude_owner = 0;
}

# Owner load delay is triggered on pencil click, so only enable for that mode.
my $delay_owner = 0;
if ( $modify_behavior =~ /link|click/ ) {
$delay_owner = 1;
}

</%INIT>
<%ARGS>
$Ticket
Expand Down
2 changes: 1 addition & 1 deletion share/html/Ticket/Widgets/Display/People
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
% if ($modify_behavior ne 'hide') {
<form hx-post="<% RT->Config->Get('WebPath') %>/Helpers/TicketUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<div hx-trigger="ticketWatchersChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditPeopleInline?id=<% $Ticket->id %>" hx-swap="innerHTML">
<div hx-trigger="ticketWatchersChanged from:body, ticketOwnerChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditPeopleInline?id=<% $Ticket->id %>" hx-swap="innerHTML">
<& /Ticket/Elements/EditPeopleInline, Ticket => $Ticket &>
</div>
<div class="row mt-2">
Expand Down
32 changes: 32 additions & 0 deletions share/html/Ticket/Widgets/Update/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,38 @@
}
},
{ special => 'roles' },
{
name => 'Priority',
comp => '/Elements/SelectPriority',
args => {
Name => "Priority",
Default => $Ticket->Priority,
QueueObj => $Ticket->QueueObj,
},
},
{
name => 'FinalPriority',
comp => '/Elements/SelectPriority',
args => {
Name => "FinalPriority",
Default => $Ticket->FinalPriority,
QueueObj => $Ticket->QueueObj,
},
},
$Ticket->QueueObj->SLADisabled
? ()
: (
{
name => 'SLA',
comp => '/Elements/SelectSLA',
args => {
Name => "SLA",
Default => $ARGS{SLA} || RT::SLA->GetDefaultServiceLevel( Queue => $Ticket->QueueObj ),
DefaultFromArgs => 0,
TicketObj => $Ticket,
},
}
),
]
&>

Expand Down
45 changes: 29 additions & 16 deletions share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1555,24 +1555,9 @@ jQuery(function () {
beginInlineEdit(cell);
});


jQuery(document).on('mouseenter', 'table.inline-edit div.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);
});
}
loadOwnerDropdownDelay(owner_dropdown_delay);
});

jQuery(document).on('change', 'div.editable.editing form :input', function () {
Expand Down Expand Up @@ -1601,6 +1586,24 @@ jQuery(function () {
});
});

function loadOwnerDropdownDelay(owner_dropdown_delay) {
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);
});
}
}

htmx.onLoad(function(elt) {

/* inline edit on ticket display */
Expand All @@ -1612,6 +1615,16 @@ htmx.onLoad(function(elt) {
}
});

/* Load the owner dropdown when the user clicks the pencil in basics */
jQuery(elt).on('click', '.ticket-info-basics .inline-edit-toggle.edit .rt-inline-icon', function (e) {
/* htmx will run for many portlets. Only run for ticket-info-basics to avoid multiple
calls to the helper for the same dropdown. */
if ( e.delegateTarget.className === "ticket-info-basics" ) {
var owner_dropdown_delay = jQuery('div.ticket-info-basics.editing').find('div.select-owner-dropdown-delay:not(.loaded)');
loadOwnerDropdownDelay(owner_dropdown_delay);
}
});

jQuery('.titlebox[data-inline-edit-behavior="always"]').each(function() {
// If there are only id/submit, there are no fields to edit
if ( jQuery(this).find('form.inline-edit :input').length <= 2 ) {
Expand Down
Loading

0 comments on commit 9c14eaf

Please sign in to comment.