[Bps-public-commit] rt-extension-turbo branch master updated. bcba503782971ed122c1e614ac5f71e5528aa79a

BPS Git Server git at git.bestpractical.com
Mon Aug 8 21:11:06 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-turbo".

The branch, master has been updated
       via  bcba503782971ed122c1e614ac5f71e5528aa79a (commit)
       via  008b250e0cc032406a670f43ef30c016cabfe730 (commit)
       via  cf7478b2e405c54113c86a35db31d713f12148e2 (commit)
      from  03c2b8068dea8246eebeee3ba749f9ac22d580a6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bcba503782971ed122c1e614ac5f71e5528aa79a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Aug 8 16:12:08 2022 -0400

    Log per-component time when running at debug level
    
    Leave commented out since it generates a lot of logging for
    every page reload. It's available for profiling if needed.

diff --git a/README b/README
index b733ff9..6652a39 100644
--- a/README
+++ b/README
@@ -32,8 +32,6 @@ INSTALLATION
 ToDo
     *   Make it a user-level and global config option to switch homepages
 
-    *   Add a timer at debug level in logs per component
-
     *   Get forms working (Quickcreate)
 
     *   Add auto-refresh feature per portlet
diff --git a/html/Callbacks/RT-Extension-Turbo/autohandler/Final b/html/Callbacks/RT-Extension-Turbo/autohandler/Final
index 0e8e714..f1bdadb 100644
--- a/html/Callbacks/RT-Extension-Turbo/autohandler/Final
+++ b/html/Callbacks/RT-Extension-Turbo/autohandler/Final
@@ -1,8 +1,13 @@
 <%init>
+my $path = $m->request_path;
+if ( $ARGS{'SavedSearch'} ) {
+    $path .= ' (' . $ARGS{'SavedSearch'} . ') ';
+}
 
 # The only thing after this callback is the default RT footer
 # Abort here for Views requests to avoid outputting the footer
 if ( $m->request_path =~ /^\/Views/ ) {
+    # RT->Logger->debug('Time to render: ' . $path . ' }}} ' . Time::HiRes::tv_interval( $m->{'rt_base_time'} ));
     $m->abort;
 }
 </%init>
diff --git a/lib/RT/Extension/Turbo.pm b/lib/RT/Extension/Turbo.pm
index 7ef97ec..e67e18a 100644
--- a/lib/RT/Extension/Turbo.pm
+++ b/lib/RT/Extension/Turbo.pm
@@ -61,10 +61,6 @@ Make it a user-level and global config option to switch homepages
 
 =item *
 
-Add a timer at debug level in logs per component
-
-=item *
-
 Get forms working (Quickcreate)
 
 =item *
commit 008b250e0cc032406a670f43ef30c016cabfe730
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Aug 8 15:44:22 2022 -0400

    Refresh dropdowns after turbo loads them

diff --git a/README b/README
index 40fbdd6..b733ff9 100644
--- a/README
+++ b/README
@@ -34,8 +34,6 @@ ToDo
 
     *   Add a timer at debug level in logs per component
 
-    *   Fix issue with reloading dropdowns on refresh
-
     *   Get forms working (Quickcreate)
 
     *   Add auto-refresh feature per portlet
diff --git a/lib/RT/Extension/Turbo.pm b/lib/RT/Extension/Turbo.pm
index 28f96e4..7ef97ec 100644
--- a/lib/RT/Extension/Turbo.pm
+++ b/lib/RT/Extension/Turbo.pm
@@ -65,10 +65,6 @@ Add a timer at debug level in logs per component
 
 =item *
 
-Fix issue with reloading dropdowns on refresh
-
-=item *
-
 Get forms working (Quickcreate)
 
 =item *
diff --git a/static/js/rt-extension-turbo.js b/static/js/rt-extension-turbo.js
index 38355bf..3cfb8b8 100644
--- a/static/js/rt-extension-turbo.js
+++ b/static/js/rt-extension-turbo.js
@@ -1,2 +1,9 @@
 // Disable by default, then enable where needed
 Turbo.session.drive = false;
+
+jQuery(function() {
+    jQuery(document).on('turbo:frame-render', function(e) {
+        // Refresh any dropdowns after they are loaded by turbo
+        jQuery('.selectpicker').selectpicker('refresh');
+    });
+});
commit cf7478b2e405c54113c86a35db31d713f12148e2
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Aug 8 15:17:50 2022 -0400

    Load Titlebox titles first, then load content with turbo
    
    Load portlet titles on initial page load, show a loading
    indicator, then load the body via turbo calls. This
    allows the user to see the empty components initially,
    then content loads in.

diff --git a/README b/README
index 78fbf99..40fbdd6 100644
--- a/README
+++ b/README
@@ -14,6 +14,11 @@ INSTALLATION
     make install
         May need root permissions
 
+    Patch RT
+        If you are running on RT 5.0.3 or earlier, apply the included patch:
+
+            patch -p1 -d /opt/rt5 < patches/0001-Add-callback-to-modify-content-presented-via-TitleBo.patch
+
     Edit your /opt/rt4/etc/RT_SiteConfig.pm
         Add this line:
 
@@ -24,6 +29,21 @@ INSTALLATION
 
     Restart your webserver
 
+ToDo
+    *   Make it a user-level and global config option to switch homepages
+
+    *   Add a timer at debug level in logs per component
+
+    *   Fix issue with reloading dropdowns on refresh
+
+    *   Get forms working (Quickcreate)
+
+    *   Add auto-refresh feature per portlet
+
+    *   Update RT to read the "collapsed" cookie setting and load titlebox
+        closed if the titlebox has been hidden. Currently we load open, then
+        quickly close it. This allows lazy load to work properly.
+
 AUTHOR
     Best Practical Solutions, LLC <modules at bestpractical.com>
 
diff --git a/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent b/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
new file mode 100644
index 0000000..11c10e0
--- /dev/null
+++ b/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
@@ -0,0 +1,37 @@
+<%init>
+my $content;
+if ( $m->request_path =~ /^\/Views/ ) {
+    # Turbo refresh, send body, no titlebox
+    $m->out( $$Content );
+
+    # Set values to get TitleBox to return without sending anything more
+    $content = '';
+    $$HideEmpty = 1;
+}
+elsif ( $m->notes('SavedSearchForTitle') ) {
+    # Homepage request for a saved search, send turbo tags
+    my $name = $m->notes('SavedSearchForTitle');
+    $content .= '<turbo-frame id="savedsearch-' . lc($name) . '" src="/Views/Component/SavedSearch?SavedSearch=' . $name . '&Rows=10">';
+    $content .= '<div class="text-center"><div class="spinner-border text-secondary" role="status"><span class="sr-only">Loading...</span></div></div>';
+    $content .= '</turbo-frame>';
+    $m->notes->{'SavedSearchForTitle'} = 0;
+}
+elsif ( $m->notes('ComponentForTitle') ) {
+    # Homepage request for a mason component, send turbo tags
+    my $name = $m->notes('ComponentForTitle');
+    $content .= '<turbo-frame id="component-' . lc($name) . '" src="/Views/Component/' . $name . '" loading="lazy">';
+    $content .= '<div class="text-center"><div class="spinner-border text-secondary" role="status"><span class="sr-only">Loading...</span></div></div>';
+    $content .= '</turbo-frame>';
+    $m->notes->{'ComponentForTitle'} = 0;
+}
+elsif ( $m->request_path =~ /^\/turbo_home\.html$/ ) {
+    # Homepage load that isn't a search or a component
+    $content = '';
+}
+$$Content = $content;
+</%init>
+<%args>
+$ARGSRef
+$Content => undef
+$HideEmpty
+</%args>
diff --git a/html/Elements/MyTurbo b/html/Elements/MyTurbo
index e1560ae..1d3b12f 100644
--- a/html/Elements/MyTurbo
+++ b/html/Elements/MyTurbo
@@ -84,14 +84,19 @@ $show_cb = sub {
         }
         else {
             # Add turbo tags for components
-            $m->out('<turbo-frame id="component-' . lc($name) . '" src="/Views/Component/' . $name . '">');
-            $m->out('</turbo-frame>');
+            $m->notes->{ComponentForTitle} = $name;
+#            $m->out('<turbo-frame id="component-' . lc($name) . '" src="/Views/Component/' . $name . '" loading="lazy">');
+#            $m->comp('/Widgets/Spinner');
+$m->comp( $name, %{ $entry->{arguments} || {} } );
+#            $m->out('</turbo-frame>');
         }
     } elsif ( $type eq 'search' ) {
             # Add turbo tags for saved searches
         my ($saved_search, $search_name) = RT::Dashboard->ShowSearchName($entry);
-        $m->out('<turbo-frame id="savedsearch-' . lc($search_name) . '" src="/Views/Component/SavedSearch?SavedSearch=' . $search_name . '&Rows=' . $Rows . '">');
-        $m->out('</turbo-frame>');
+        $m->notes->{SavedSearchForTitle} = $search_name;
+#        $m->out('<turbo-frame id="savedsearch-' . lc($search_name) . '" src="/Views/Component/SavedSearch?SavedSearch=' . $search_name . '&Rows=' . $Rows . '">');
+$m->comp( '/Elements/ShowSearch', RT::Dashboard->ShowSearchName($entry), Override => { Rows => $Rows } );
+#        $m->out('</turbo-frame>');
     } elsif ( $type eq 'dashboard' ) {
         my $current_dashboard = RT::Dashboard->new($session{CurrentUser});
         my ($ok, $msg) = $current_dashboard->LoadById($entry->{id});
diff --git a/lib/RT/Extension/Turbo.pm b/lib/RT/Extension/Turbo.pm
index 13e21d5..28f96e4 100644
--- a/lib/RT/Extension/Turbo.pm
+++ b/lib/RT/Extension/Turbo.pm
@@ -31,6 +31,12 @@ Works with RT 5.
 
 May need root permissions
 
+=item Patch RT
+
+If you are running on RT 5.0.3 or earlier, apply the included patch:
+
+    patch -p1 -d /opt/rt5 < patches/0001-Add-callback-to-modify-content-presented-via-TitleBo.patch
+
 =item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
 
 Add this line:
@@ -71,7 +77,9 @@ Add auto-refresh feature per portlet
 
 =item *
 
-Add a loading icon for possible slow portlet loads
+Update RT to read the "collapsed" cookie setting and load titlebox
+closed if the titlebox has been hidden. Currently we load open, then
+quickly close it. This allows lazy load to work properly.
 
 =back
 
diff --git a/patches/0001-Add-callback-to-modify-content-presented-via-TitleBo.patch b/patches/0001-Add-callback-to-modify-content-presented-via-TitleBo.patch
new file mode 100644
index 0000000..502bd4f
--- /dev/null
+++ b/patches/0001-Add-callback-to-modify-content-presented-via-TitleBo.patch
@@ -0,0 +1,24 @@
+From 9c42a176ed087ffbc703b963f9c35d2958bca978 Mon Sep 17 00:00:00 2001
+From: Jim Brandt <jbrandt at bestpractical.com>
+Date: Mon, 8 Aug 2022 15:14:06 -0400
+Subject: [PATCH] Add callback to modify content presented via TitleBox
+
+---
+ share/html/Widgets/TitleBox | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/share/html/Widgets/TitleBox b/share/html/Widgets/TitleBox
+index 43735d0c1..042ca4960 100644
+--- a/share/html/Widgets/TitleBox
++++ b/share/html/Widgets/TitleBox
+@@ -59,5 +59,7 @@ $hide_chrome => 0
+ </%ARGS>
+ <%INIT>
+ my $content = $m->content;
++$m->callback( CallbackName => "ModifyContent", ARGSRef => \%ARGS, Content => \$content,
++    Class => \$class, HideEmpty => \$hide_empty, HideChrome => \$hide_chrome );
+ return if $hide_empty && $content =~ /^\s*$/s;
+ </%INIT>
+-- 
+2.35.2
+
-----------------------------------------------------------------------

Summary of changes:
 README                                             | 16 ++++++++++
 .../Widgets/Titlebox/ModifyContent                 | 37 ++++++++++++++++++++++
 .../Callbacks/RT-Extension-Turbo/autohandler/Final |  5 +++
 html/Elements/MyTurbo                              | 13 +++++---
 lib/RT/Extension/Turbo.pm                          | 18 +++++------
 ...k-to-modify-content-presented-via-TitleBo.patch | 24 ++++++++++++++
 static/js/rt-extension-turbo.js                    |  7 ++++
 7 files changed, 107 insertions(+), 13 deletions(-)
 create mode 100644 html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
 create mode 100644 patches/0001-Add-callback-to-modify-content-presented-via-TitleBo.patch


hooks/post-receive
-- 
rt-extension-turbo


More information about the Bps-public-commit mailing list