[Bps-public-commit] RT-Extension-PreviewInSearch branch update-for-rt5 created. 0.04-4-gfaac320

BPS Git Server git at git.bestpractical.com
Sun Nov 27 20:03:50 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-PreviewInSearch".

The branch, update-for-rt5 has been created
        at  faac32027eed19fa9c20268bc62f4cccc0db3c0b (commit)

- Log -----------------------------------------------------------------
commit faac32027eed19fa9c20268bc62f4cccc0db3c0b
Author: Brad Embree <brad at bestpractical.com>
Date:   Sun Nov 27 12:03:27 2022 -0800

    Add RT 5 version

diff --git a/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults b/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults
index e69de29..ad3b4ac 100644
--- a/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults
+++ b/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/AfterResults
@@ -0,0 +1,49 @@
+% if ( RT::Handle::cmp_version($RT::VERSION, '5.0.0') >= 0 ) {
+% # RT 5 version
+<style>
+tr.in-preview td { background: #ffb }
+</style>
+<script type="text/javascript">
+var ticket_list = jQuery('table.ticket-list');
+
+% if ( RT->Config->Get('SideBySidePreview') ) {
+ticket_list.wrap( "<div class='row m-0'><div class='ticket-list-with-previewinsearch col-6'></div></div>" );
+jQuery('div.ticket-list-with-previewinsearch').after( "<div id='ticket-preview-container' class='col-6'><p>foobar</p></div>" );
+% } else {
+ticket_list.after( "<div class='row m-0'><div id='ticket-preview-container' class='col-12'><p>foobar</p></div></div>" );
+% }
+
+var get_ticket_row = function (from) {
+    var row = jQuery(from).closest('tr');
+    var even_or_odd = row.hasClass('oddline')? 'evenline': 'oddline';
+    row = row.add(
+        row.prevUntil( '.' + even_or_odd, '[class*="line"]' )
+    ).add(
+        row.nextUntil( '.' + even_or_odd, '[class*="line"]' )
+    );
+    return row;
+};
+
+var do_preview = function (row) {
+    var tid = row.find('> td a[href*="Display.html?id="]').first().attr('href').match(/Display\.html\?id=(\d+)/)[1];
+    var url = <% RT->Config->Get('WebPath') |n,j %> +'/Helpers/TicketPreview?id='+tid;
+    row.closest('table').children('tbody').children('tr').removeClass('in-preview');
+    row.addClass('in-preview');
+    jQuery('#ticket-preview-container').text(<% loc('Loading...') |n,j %>).load( url );
+};
+
+jQuery(document).ready(function() {
+    do_preview( get_ticket_row( jQuery('table.ticket-list tbody tr td').first() ) );
+});
+
+jQuery(function(){
+    jQuery('table.collection-as-table > tbody > tr > td').on('click', function (e) {
+        if (e.target.tagName != 'TD')
+            return;
+
+        var row = get_ticket_row(e.target);
+        do_preview(row);
+    });
+});
+</script>
+% }
\ No newline at end of file

commit 389cad41a5862373bafc7005d1db3cce28983b55
Author: Brad Embree <brad at bestpractical.com>
Date:   Sun Nov 27 12:02:43 2022 -0800

    Wrap current code in check for RT version 4

diff --git a/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/BeforeResults b/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/BeforeResults
index eeb1162..7ae3d40 100644
--- a/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/BeforeResults
+++ b/html/Callbacks/RT-Extension-PreviewInSearch/Search/Results.html/BeforeResults
@@ -1,3 +1,5 @@
+% if ( RT::Handle::cmp_version($RT::VERSION, '5.0.0') < 0 ) {
+% # RT 4 version
 <style>
 tr.in-preview td { background: #ffb }
 % if ( RT->Config->Get('SideBySidePreview') ) {
@@ -85,6 +87,7 @@ jQuery(function(){
     });
 });
 </script>
+% }
 <%ARGS>
 </%ARGS>
 <%INIT>

-----------------------------------------------------------------------


hooks/post-receive
-- 
RT-Extension-PreviewInSearch


More information about the Bps-public-commit mailing list