Skip to content

Commit

Permalink
Merge branch '6.0/refresh-main-content-on-big-inline-edit-changes'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Sep 13, 2024
2 parents 1fa65ba + 092cdd3 commit 6ff4df4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 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
9 changes: 6 additions & 3 deletions share/html/Elements/ShowHistoryHeader
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ else {
# Oldest Txns first is ASC, so reverse it for this option default
$reverse_txns = RT->Config->Get("OldestTransactionsFirst", $session{'CurrentUser'}) ? 'DESC' : 'ASC';
}

my $container_id = 'history-container-' . Digest::MD5::md5_hex(time . {} . $$ . rand(1024));
</%INIT>
<div class="history <% lc $record_type %>" id="<% $histid %>">
<%perl>
Expand Down Expand Up @@ -158,7 +160,7 @@ else {

<script type="text/javascript">
jQuery(function(){
var container = document.querySelector('div.history-container');
var container = document.getElementById(<% $container_id | j%>);
container.setAttribute('data-oldest-transactions-first', '<% $oldestTransactionsFirst %>');
% if ( !$ScrollShowHistory ) {
container.setAttribute('data-disable-scroll-loading', '');
Expand Down Expand Up @@ -198,7 +200,8 @@ jQuery(function(){
};

var loadHistoryPage = function() {
if (isLoading || container.hasAttribute('data-disable-scroll-loading')) return;
container = document.getElementById(<% $container_id |j %>);
if (isLoading || !container || container.hasAttribute('data-disable-scroll-loading')) return;

isLoading = true;
showLoadingMessage();
Expand Down Expand Up @@ -315,4 +318,4 @@ jQuery(function(){
</script>
% }

<div class="history-container" data-url="<% $url %>">
<div class="history-container" data-url="<% $url %>" id="<% $container_id %>">
2 changes: 1 addition & 1 deletion share/html/Helpers/AssetUpdate
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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 @@ -107,15 +107,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 @@ -812,12 +812,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 6ff4df4

Please sign in to comment.