Skip to content

Commit

Permalink
Refresh main content on big inline edit changes like queue
Browse files Browse the repository at this point in the history
Previously we refreshed the whole HTML including menu, which was not necessary.
  • Loading branch information
sunnavy committed Sep 6, 2024
1 parent f573687 commit c7b84df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
9 changes: 9 additions & 0 deletions share/html/Elements/Header
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@
% $m->abort;
% } else {
<div class="main-container">

%# To refresh main container, here we create a separated div so its hx-* attributes are not inherited.
<div
hx-get="<% RT::Interface::Web::RequestENV('REQUEST_URI') %>"
hx-trigger="mainContainerChanged from:body"
hx-target="closest .main-container"
hx-select=".main-container"
hx-swap="outerHTML"
></div>
% }

% if ($Refresh && $Refresh =~ /^(\d+)/ && $1 > 0) {
Expand Down
2 changes: 1 addition & 1 deletion share/html/Helpers/AssetUpdate
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ for my $txn ( @{ $asset->{_TransactionBatch} || [] } ) {
if ( $txn->Type eq 'Set' ) {
push @events, 'asset' . $txn->Field . 'Changed';
if ( $txn->Field eq 'Catalog' ) {
push @events, 'reloadRequired';
push @events, 'mainContainerChanged';
}
elsif ( $txn->Field =~ /^(Name|Status|Description)$/ ) {
push @events, 'assetBasicsChanged';
Expand Down
4 changes: 2 additions & 2 deletions share/html/Helpers/TicketUpdate
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ for my $txn (@{ $TicketObj->{_TransactionBatch} || [] }) {
if ( $txn->Type eq 'Set' ) {
push @events, 'ticket' . $txn->Field . 'Changed';
if ( $txn->Field eq 'Queue' ) {
push @events, 'reloadRequired';
push @events, 'mainContainerChanged';
}
}
elsif ( $txn->Type eq 'CustomField' ) {
push @events, 'customField-' . $txn->Field . 'Changed';
}
elsif ( $txn->Type =~ /(?:Add|Delete)Link/ ) {
if ( $txn->Field eq 'MergedInto' ) {
push @events, 'reloadRequired';
push @events, 'mainContainerChanged';
}
elsif ( ( $txn->OldValue // '' ) =~ m{^asset://} || ( $txn->NewValue // '' ) =~ m{^asset://} ) {
push @events, 'ticketAssetsChanged';
Expand Down
6 changes: 0 additions & 6 deletions share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,6 @@ jQuery(function() {
document.title = decodeURIComponent(escape(evt.detail.value));
});

document.body.addEventListener('reloadRequired', function(evt) {
setTimeout(function () {
document.location = document.location;
}, 3000); // Give users some time to see growl messages.
});

document.body.addEventListener('triggerChanged', function(evt) {
evt.detail.elt.setAttribute('hx-trigger', evt.detail.value);
htmx.process(evt.detail.elt);
Expand Down

0 comments on commit c7b84df

Please sign in to comment.