Skip to content

Commit

Permalink
Merge branch '6.0/htmx-widgets-with-long-params'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Jan 24, 2025
2 parents 77059c5 + 17f1861 commit b15be31
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 29 deletions.
3 changes: 1 addition & 2 deletions share/html/Asset/Widgets/Display/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="assetBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowBasics?id=<% $AssetObj->id %>">
<div class="inline-edit-display" hx-trigger="assetBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowBasics">
<& /Asset/Elements/ShowBasics, AssetObj => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form hx-post="<%RT->Config->Get('WebPath')%>/Helpers/AssetUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<& /Asset/Elements/EditBasics, AssetObj => $AssetObj &>
<div class="row mt-2">
<div class="col-12 text-end">
Expand Down
5 changes: 2 additions & 3 deletions share/html/Asset/Widgets/Display/Dates
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="actionsChanged from:body, assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowDates?id=<% $AssetObj->id %>">
<div class="inline-edit-display" hx-trigger="actionsChanged from:body, assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowDates">
<& /Asset/Elements/ShowDates, AssetObj => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form class="inline-edit" hx-post="<%RT->Config->Get('WebPath')%>/Helpers/AssetUpdate" hx-swap="none" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<div hx-trigger="assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditDates?id=<% $AssetObj->id %>"hx-swap="innerHTML">
<div hx-trigger="assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditDates" hx-swap="innerHTML">
<& /Asset/Elements/EditDates, AssetObj => $AssetObj &>
</div>
<div class="row mt-2">
Expand Down
1 change: 0 additions & 1 deletion share/html/Asset/Widgets/Display/Links
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
% }
% if ($modify_behavior ne 'hide') {
<form class="inline-edit" hx-post="<% RT->Config->Get('WebPath') %>/Helpers/AssetUpdate" hx-swap="none" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<div hx-trigger="assetLinksChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditLinks?ObjectType=RT::Asset&ObjectId=<% $AssetObj->id %>&TwoColumn=0" hx-swap="innerHTML">
<& /Elements/EditLinks, Object => $AssetObj, TwoColumn => 0 &>
<& /Elements/EditCustomFields, Object => $AssetObj, Grouping => 'Links', InTable => 1 &>
Expand Down
5 changes: 2 additions & 3 deletions share/html/Asset/Widgets/Display/People
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="assetPeopleChanged from:body" hx-get="<%RT->Config->Get('WebPath')%>/Views/Asset/ShowPeople?id=<% $AssetObj->id %>">
<div class="inline-edit-display" hx-trigger="assetPeopleChanged from:body" hx-get="<%RT->Config->Get('WebPath')%>/Views/Asset/ShowPeople">
<& /Asset/Elements/ShowPeople, AssetObj => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form hx-post="<% RT->Config->Get('WebPath') %>/Helpers/AssetUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<div hx-trigger="assetPeopleChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditPeopleInline?id=<% $AssetObj->id %>" hx-swap="innerHTML">
<div hx-trigger="assetPeopleChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditPeopleInline" hx-swap="innerHTML">
<& /Asset/Elements/EditPeopleInline, AssetObj => $AssetObj &>
</div>
<div class="row mt-2">
Expand Down
6 changes: 5 additions & 1 deletion share/html/Elements/ShowWidgets
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@
% }
<& $path, %args &>
% } else {
<& /Widgets/HTMXLoadStart, htmx_get => RT->Config->Get('WebPath') . "/Views$path?" . QueryString( defined $argument ? ( Argument => $argument ) : (), %$DECODED_ARGS ), lazy_load => $Page =~ /Create|Update/ ? 0 : 1 &>
<& /Widgets/HTMXLoadStart,
$Page =~ /Create|Update/ ? 'htmx_post' : 'htmx_get' => RT->Config->Get('WebPath') . "/Views$path",
htmx_values => { defined $argument ? ( Argument => $argument ) : (), %$DECODED_ARGS },
lazy_load => $Page =~ /Create|Update/ ? 0 : 1,
&>
<& /Widgets/HTMXLoadEnd &>
% }
% } else {
Expand Down
5 changes: 2 additions & 3 deletions share/html/Ticket/Widgets/Display/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% 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=<% $TicketObj->id %>">
<div class="inline-edit-display" hx-trigger="ticketBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowBasics">
<& /Ticket/Elements/ShowBasics, Ticket => $TicketObj, 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="<% $TicketObj->id %>" />

<div hx-trigger="ticketBasicsChanged from:body, ticketOwnerChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditBasics?id=<% $TicketObj->id %>" hx-swap="innerHTML">
<div hx-trigger="ticketBasicsChanged from:body, ticketOwnerChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditBasics" hx-swap="innerHTML">
<& /Ticket/Elements/EditBasics, TicketObj => $TicketObj, InTable => 1, ExcludeOwner => $exclude_owner, ExcludeCustomRoles => 1, DelayOwner => $delay_owner &>
</div>
<div class="row mt-2">
Expand Down
5 changes: 2 additions & 3 deletions share/html/Ticket/Widgets/Display/Dates
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="actionsChanged from:body, ticketDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowDates?id=<% $TicketObj->id %>">
<div class="inline-edit-display" hx-trigger="actionsChanged from:body, ticketDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowDates">
<& /Ticket/Elements/ShowDates, Ticket => $TicketObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form class="inline-edit" hx-post="<%RT->Config->Get('WebPath')%>/Helpers/TicketUpdate" hx-swap="none" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $TicketObj->id %>" />
<div hx-trigger="ticketDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditDates?id=<% $TicketObj->id %>"hx-swap="innerHTML">
<div hx-trigger="ticketDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditDates" hx-swap="innerHTML">
<& /Ticket/Elements/EditDates, TicketObj => $TicketObj &>
</div>
<div class="row mt-2">
Expand Down
3 changes: 1 addition & 2 deletions share/html/Ticket/Widgets/Display/Description
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="ticketDescriptionChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowDescription?id=<% $TicketObj->id %>">
<div class="inline-edit-display" hx-trigger="ticketDescriptionChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowDescription">
<& /Ticket/Elements/ShowDescription, Ticket => $TicketObj, InTable => 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="<% $TicketObj->id %>" />
<& /Ticket/Elements/EditDescription, TicketObj => $TicketObj, InTable => 1 &>
<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 => 'Description', InTable => 1 &>
Expand Down
1 change: 0 additions & 1 deletion share/html/Ticket/Widgets/Display/Links
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
% }
% if ($modify_behavior ne 'hide') {
<form class="inline-edit" hx-post="<% RT->Config->Get('WebPath') %>/Helpers/TicketUpdate" hx-swap="none" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $TicketObj->id %>" />
<div hx-trigger="ticketLinksChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditLinks?ObjectType=RT::Ticket&ObjectId=<% $TicketObj->id %>&TwoColumn=0" hx-swap="innerHTML">
<& /Elements/EditLinks, Object => $TicketObj, TwoColumn => 0 &>
</div>
Expand Down
5 changes: 2 additions & 3 deletions share/html/Ticket/Widgets/Display/People
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="ticketWatchersChanged from:body, ticketOwnerChanged from:body" hx-get="<%RT->Config->Get('WebPath')%>/Views/Ticket/ShowPeople?id=<% $TicketObj->id %>">
<div class="inline-edit-display" hx-trigger="ticketWatchersChanged from:body, ticketOwnerChanged from:body" hx-get="<%RT->Config->Get('WebPath')%>/Views/Ticket/ShowPeople">
<& /Ticket/Elements/ShowPeople, Ticket => $TicketObj &>
</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="<% $TicketObj->id %>" />
<div hx-trigger="ticketWatchersChanged from:body, ticketOwnerChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditPeopleInline?id=<% $TicketObj->id %>" hx-swap="innerHTML">
<div hx-trigger="ticketWatchersChanged from:body, ticketOwnerChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditPeopleInline" hx-swap="innerHTML">
<& /Ticket/Elements/EditPeopleInline, Ticket => $TicketObj &>
</div>
<div class="row mt-2">
Expand Down
2 changes: 1 addition & 1 deletion share/html/Ticket/Widgets/Display/Reminders
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
class => 'ticket-info-reminders fullwidth',
&>
<form hx-post="<% RT->Config->Get('WebPath') %>/Helpers/TicketUpdate" hx-swap="none" name="UpdateReminders" id="UpdateReminders">
<div hx-trigger="ticketRemindersChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/Reminders?ShowCompleted=0&id=<% $TicketObj->id %>" hx-swap="innerHTML">
<div hx-trigger="ticketRemindersChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/Reminders?ShowCompleted=0" hx-swap="innerHTML">
<& /Ticket/Elements/Reminders, Ticket => $TicketObj, ShowCompleted => 0 &>
</div>
</form>
Expand Down
3 changes: 1 addition & 2 deletions share/html/Ticket/Widgets/Display/Times
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="ticketBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowTimes?id=<% $TicketObj->id %>">
<div class="inline-edit-display" hx-trigger="ticketBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/ShowTimes">
<& /Ticket/Elements/ShowTimes, Ticket => $TicketObj, InTable => 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="<% $TicketObj->id %>" />
<& /Ticket/Elements/EditTimes, TicketObj => $TicketObj, InTable => 1 &>
<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=Times&InTable=1" hx-swap="innerHTML">
<& /Elements/EditCustomFields, Object => $TicketObj, Grouping => 'Times', InTable => 1 &>
Expand Down
25 changes: 23 additions & 2 deletions share/html/Widgets/HTMXLoadStart
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,37 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
<div hx-get="<% $htmx_get %>" hx-trigger="<% $lazy_load ? 'revealed' : 'load' %>" target="_top">
<div
% if ( $htmx_get ) {
hx-get="<% $htmx_get %>"
% }

% if ( $htmx_post ) {
hx-post="<% $htmx_post %>"
% }

% if ( $htmx_values ) {
hx-vals="<% JSON($htmx_values) %>"
% }

% if ( $htmx_params ) {
hx-params="<% $htmx_params %>"
% }

hx-trigger="<% $lazy_load ? 'revealed' : 'load' %>" target="_top">
% if ( $show_spinner ) {
<div class="text-center htmx-indicator"><div class="spinner-border text-secondary" role="status"><span class="visually-hidden">Loading...</span></div></div>
% }
<%ARGS>
$htmx_get => undef
$htmx_post => undef
$htmx_values => undef
$htmx_params => undef
$show_spinner => 1
$lazy_load => 1
</%ARGS>

<%init>
RT->Logger->error("No htmx_get provided. HTMX needs a get path to issue the request for content.") unless $htmx_get;
RT->Logger->error("No htmx_get or htmx_post provided. HTMX needs a get/post path to issue the request for content.")
unless $htmx_get || $htmx_post;
</%init>
5 changes: 4 additions & 1 deletion share/html/Widgets/TitleBox
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
% }

% if ( $htmx_load ) {
<& HTMXLoadStart, htmx_get => $htmx_get &>
<& HTMXLoadStart, htmx_get => $htmx_get, htmx_post => $htmx_post, htmx_params => $htmx_params, htmx_values => $htmx_values &>
% }

<% $content | n %>
Expand All @@ -78,6 +78,9 @@ $hide_empty => 0
$hide_chrome => 0
$htmx_load => undef
$htmx_get => undef
$htmx_post => undef
$htmx_params => undef
$htmx_values => undef
</%ARGS>
<%INIT>

Expand Down
4 changes: 3 additions & 1 deletion share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ function ReplaceAllTextareas(elt) {
// here we set height of its parent(.ck-editor__main) instead.
editor.ui.view.editable.element.parentNode.style.height = height;
AddAttachmentWarning(editor);

editor.on('destroy', () => {
delete CKEDITOR.instances[editor.sourceElement.name];
});
})
.catch( error => {
console.error( error );
Expand Down

0 comments on commit b15be31

Please sign in to comment.