[Rt-commit] rt branch 5.0/edit-config-search created. rt-5.0.3-226-ga1d295d3f3

BPS Git Server git at git.bestpractical.com
Tue Jan 10 18:53:11 UTC 2023


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".

The branch, 5.0/edit-config-search has been created
        at  a1d295d3f32029a87345100af18100d37993cc2f (commit)

- Log -----------------------------------------------------------------
commit a1d295d3f32029a87345100af18100d37993cc2f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 11 00:10:43 2023 +0800

    Add search functionality for config edit page

diff --git a/share/html/Admin/Tools/Config/Elements/Option b/share/html/Admin/Tools/Config/Elements/Option
index 4b45cda453..0e2a4b2665 100644
--- a/share/html/Admin/Tools/Config/Elements/Option
+++ b/share/html/Admin/Tools/Config/Elements/Option
@@ -128,7 +128,7 @@ elsif ($widget eq '/Widgets/Form/Select') {
         %$args,
     );
 }
-my $row_start = qq{<div class="widget form-row">
+my $row_start = qq{<div class="widget form-row" id="form-box-@{[ lc $name ]}">
   <div class="label col-4">
     <span data-toggle="tooltip" data-placement="top" data-original-title="$args->{Tooltip}">
       <a href="$doc_url" target="_blank">$name</a>
diff --git a/share/html/Admin/Tools/EditConfig.html b/share/html/Admin/Tools/EditConfig.html
index 4f70dd254b..9ab9dc05c1 100644
--- a/share/html/Admin/Tools/EditConfig.html
+++ b/share/html/Admin/Tools/EditConfig.html
@@ -60,6 +60,20 @@ my $active_context = {
     subsection => CSSClass( $ARGS{subsection} || $options->[0]->{Content}->[0]->{Content}->[0]->{Name}) ,
 };
 
+my @option_list;
+for my $tab ( @$options ) {
+    for my $section ( @{$tab->{Content}} ) {
+        for my $subsection ( @{$section->{Content}} ) {
+            for my $name ( map { $_->{Name} } @{$subsection->{Content}} ) {
+                my $meta = RT->Config->Meta( $name );
+                next if $meta->{Invisible} || $meta->{Deprecated} || $meta->{Obfuscate};
+                push @option_list, $name;
+            }
+        }
+    }
+}
+ at option_list = sort { lc $a cmp lc $b } @option_list;
+
 my @results;
 
 if (delete $ARGS{Update}) {
@@ -174,6 +188,9 @@ my $nav_type='tab'; # 'tab' or 'pill'
       <a class="nav-link <% $active %>" id="<% $nav_id %>" data-toggle="<% $nav_type %>" href="#<% $content_id %>" role="<% $nav_type %>" aria-controls="<% $content_id %>" aria-selected="<% $aria_selected %>"><% $tab_name %></a>
     </li>
 % }
+    <li class="nav-item ml-1">
+      <input class="form-control option-search" placeholder="<&|/l&>Search</&>..." type="search" />
+    </li>
   </ul>
   <div class="tab-content" id="content-all" >
 % foreach my $tab ( @$options) {
@@ -189,3 +206,76 @@ my $nav_type='tab'; # 'tab' or 'pill'
   </div><!-- content-all -->
 </div><!-- titlebox-content -->
 </div><!-- configuration -->
+
+<script type="text/javascript">
+
+jQuery(function() {
+
+    // navs are not long, here we use modified id as hash to not scroll page for better user experiences.
+    jQuery('div.configuration a.nav-link[data-toggle=tab]').on('show.bs.tab', function(e) {
+        // Find the active subnav
+        var target =
+            jQuery(jQuery(e.target).attr('href')).find('a.nav-link.active[data-toggle=pill]').get(0) || e.target;
+        window.location.hash = target.id.replace(/^nav-/, '');
+    });
+
+    jQuery('div.configuration a.nav-link[data-toggle=pill]').on('show.bs.tab', function(e) {
+        window.location.hash = e.target.id.replace(/^nav-/, '');
+    });
+
+    var show_option = function(option) {
+        if ( option.match(/^#form-box/) ) {
+            var pane_id = jQuery(option).closest('div.tab-pane').attr('id');
+
+            if ( pane_id ) {
+                var parts = pane_id.split(/-/, 3); // e.g. content-System-Outgoing_mail
+
+                if ( parts.length === 3 ) {
+                    if ( jQuery(option).is(':visible') ) {
+                        window.location.hash = ''; // Make sure hash is refreshed
+                        window.location.hash = option;
+                    }
+                    else {
+                        jQuery('#nav-' + parts[1]).tab('show');
+                        jQuery('#nav-' + parts[1] + '-' + parts[2]).tab('show');
+                        var interval;
+                        interval = setInterval(function () {
+                            if ( jQuery(option).is(':visible') ) {
+                                window.location.hash = option;
+                                clearInterval(interval);
+                            }
+                        }, 10);
+                    }
+                }
+            }
+        }
+        else {
+            option = option.replace(/^#/, '');
+            var parts = option.split(/-/, 2); // e.g. System or System-Database_connection
+            jQuery('#nav-' + parts[0]).tab('show');
+            if ( parts.length === 2 ) {
+                jQuery('#nav-' + option).tab('show');
+            }
+        }
+
+        return false;
+    };
+
+    var options = <% JSON(\@option_list) |n %>;
+    jQuery('input.option-search').autocomplete({ source: options, select: function(event, ui) {
+        jQuery('input.option-search').val('');
+        var option = ui.item.value;
+        if ( option === 'CustomDateRanges' ) {
+            show_option('#Features-Custom_Date_Ranges');
+        }
+        else {
+            show_option('#form-box-' + option.toLowerCase());
+        }
+        return false;
+    } });
+
+    if ( window.location.hash ) {
+        show_option(window.location.hash);
+    }
+});
+</script>

commit 32f3367484bb5f47843fb47757f1d8f970d789ab
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jan 10 06:22:00 2023 +0800

    Show config name as label and description as tooltip on config edit page
    
    Previously some configs were labelled with description like "Use
    autocomplete to find owners?" instead of the name "AutocompleteOwners",
    which was inconsistent.
    
    Note that we do use descriptions as labels on user prefs page.

diff --git a/share/html/Admin/Tools/Config/Elements/Option b/share/html/Admin/Tools/Config/Elements/Option
index 02237e79df..4b45cda453 100644
--- a/share/html/Admin/Tools/Config/Elements/Option
+++ b/share/html/Admin/Tools/Config/Elements/Option
@@ -106,7 +106,9 @@ else {
     $current_file_value = $current_value;
 }
 
-my $args   = $meta->{'WidgetArguments'} || {};
+my $args = { %{ $meta->{'WidgetArguments'} || {} } };
+$args->{Tooltip} = delete $args->{Description} // '';
+
 if ($widget eq '/Widgets/Form/Boolean') {
     %$args = (
         RadioStyle => 1,
@@ -127,7 +129,11 @@ elsif ($widget eq '/Widgets/Form/Select') {
     );
 }
 my $row_start = qq{<div class="widget form-row">
-  <div class="label col-4"><a href="$doc_url" target="_blank">$name</a></div>
+  <div class="label col-4">
+    <span data-toggle="tooltip" data-placement="top" data-original-title="$args->{Tooltip}">
+      <a href="$doc_url" target="_blank">$name</a>
+    </span>
+  </div>
   <div class="value col-8">
 };
 my $row_end = qq{</div></div>};
diff --git a/share/html/Widgets/FinalizeWidgetArguments b/share/html/Widgets/FinalizeWidgetArguments
index a2d4b4d22e..402d82d9e7 100644
--- a/share/html/Widgets/FinalizeWidgetArguments
+++ b/share/html/Widgets/FinalizeWidgetArguments
@@ -51,6 +51,7 @@
     %args = (%args, %{ $args{Callback}->() }) if $args{Callback};
     $args{'Description'} = loc( $args{'Description'} ) if $args{'Description'};
     $args{'Hints'} = loc( $args{'Hints'} ) if $args{'Hints'};
+    $args{'Tooltip'} = loc( $args{'Tooltip'} ) if $args{'Tooltip'};
     if ( $args{'ValuesLabel'} ) {
         my %labels;
         $labels{$_} = loc( $args{'ValuesLabel'}->{$_} )
diff --git a/share/html/Widgets/Form/Boolean b/share/html/Widgets/Form/Boolean
index 4a8e7294ca..85b8852762 100644
--- a/share/html/Widgets/Form/Boolean
+++ b/share/html/Widgets/Form/Boolean
@@ -50,11 +50,13 @@ see docs/extending/using_forms_widgets.pod
 </%DOC>
 <div id="form-box-<% lc $Name %>" class="widget form-row boolean">
   <div class="label col-<% $LabelCols %>">
+    <span data-toggle="tooltip" data-placement="top" data-original-title="<% $Tooltip %>">
 % if( $LabelLink ) {
     <a href="<% $LabelLink %>" target="_blank"><% $Description %></a>
 % } else {
     <% $Description %>
 % }
+    </span>
   </div>
   <div class="value col-<% $ValueCols %>">
     <& SELF:InputOnly, %ARGS &>
@@ -72,6 +74,7 @@ $LabelLink    => ''
 $LabelCols    => 3
 $ValueCols    => 9
 $CloseRowDiv  => 1
+$Tooltip      => ''
 </%ARGS>
 
 <%METHOD InputOnly>
diff --git a/share/html/Widgets/Form/Integer b/share/html/Widgets/Form/Integer
index 73bb7b95f5..72a33078b6 100644
--- a/share/html/Widgets/Form/Integer
+++ b/share/html/Widgets/Form/Integer
@@ -50,11 +50,13 @@ see docs/extending/using_forms_widgets.pod
 </%DOC>
 <div id="form-box-<% lc $Name %>" class="widget form-row">
   <div class="label col-<% $LabelCols %>">
+    <span data-toggle="tooltip" data-placement="top" data-original-title="<% $Tooltip %>">
 % if( $LabelLink ) {
     <a href="<% $LabelLink %>" target="_blank"><% $Description %></a>
 % } else {
     <% $Description %>
 % }
+    </span>
   </div>
   <div class="value col-<% $ValueCols %>">
     <& SELF:InputOnly, %ARGS &>
@@ -85,6 +87,7 @@ $LabelLink      => ''
 $LabelCols      => 3
 $ValueCols      => 9
 $CloseRowDiv    => 1
+$Tooltip        => ''
 </%ARGS>
 
 <%METHOD InputOnly>
diff --git a/share/html/Widgets/Form/MultilineString b/share/html/Widgets/Form/MultilineString
index b7cae5b108..fa451bfec6 100644
--- a/share/html/Widgets/Form/MultilineString
+++ b/share/html/Widgets/Form/MultilineString
@@ -50,11 +50,13 @@ see docs/extending/using_forms_widgets.pod
 </%DOC>
 <div id="form-box-<% lc $Name %>" class="widget form-row <% $Class %>">
   <div class="label col-<% $LabelCols %>">
+    <span data-toggle="tooltip" data-placement="top" data-original-title="<% $Tooltip %>">
 % if( $LabelLink ) {
     <a href="<% $LabelLink %>" target="_blank"><% $Description %></a>
 % } else {
     <% $Description %>
 % }
+    </span>
   </div>
   <div class="value col-<% $ValueCols %>"><& SELF:InputOnly, %ARGS &>
 % if ( $Default ) {
@@ -81,6 +83,7 @@ $LabelLink      => ''
 $LabelCols      => 3
 $ValueCols      => 9
 $CloseRowDiv    => 1
+$Tooltip        => ''
 </%ARGS>
 
 <%METHOD InputOnly>
diff --git a/share/html/Widgets/Form/Select b/share/html/Widgets/Form/Select
index d846aed02c..7dc55c3c8a 100644
--- a/share/html/Widgets/Form/Select
+++ b/share/html/Widgets/Form/Select
@@ -50,11 +50,13 @@ see docs/extending/using_forms_widgets.pod
 </%DOC>
 <div id="form-box-<% lc $Name %>" class="widget form-row">
   <div class="label col-<% $LabelCols %>">
+    <span data-toggle="tooltip" data-placement="top" data-original-title="<% $Tooltip %>">
 % if( $LabelLink ) {
     <a href="<% $LabelLink %>" target="_blank"><% $Description %></a>
 % } else {
     <% $Description %>
 % }
+    </span>
   </div>
   <div class="value col-<% $ValueCols %>">
     <& SELF:InputOnly, %ARGS &>
@@ -71,6 +73,7 @@ $LabelLink        => ''
 $LabelCols        => 3
 $ValueCols        => 9
 $CloseRowDiv      => 1
+$Tooltip          => ''
 </%ARGS>
 
 <%METHOD InputOnly>
diff --git a/share/html/Widgets/Form/String b/share/html/Widgets/Form/String
index 5a83b6a2f1..aaf0ea5075 100644
--- a/share/html/Widgets/Form/String
+++ b/share/html/Widgets/Form/String
@@ -50,11 +50,13 @@ see docs/extending/using_forms_widgets.pod
 </%DOC>
 <div id="form-box-<% lc $Name %>" class="widget form-row">
   <div class="label col-<% $LabelCols %>">
+    <span data-toggle="tooltip" data-placement="top" data-original-title="<% $Tooltip %>">
 % if( $LabelLink ) {
     <a href="<% $LabelLink %>" target="_blank"><% $Description %></a>
 % } else {
     <% $Description // '' %>
 % }
+    </span>
   </div>
   <div class="value col-<% $ValueCols %>">
     <& SELF:InputOnly, %ARGS &>
@@ -81,6 +83,7 @@ $LabelLink      => '',
 $LabelCols      => 3
 $ValueCols      => 9
 $CloseRowDiv    => 1
+$Tooltip        => ''
 </%ARGS>
 
 <%METHOD InputOnly>

commit 859e592695ad6213433292788ce76dfea781b052
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jan 10 06:19:19 2023 +0800

    Clean up duplicated widget arguments
    
    $args already contains $meta->{'WidgetArguments'}

diff --git a/share/html/Admin/Tools/Config/Elements/Option b/share/html/Admin/Tools/Config/Elements/Option
index af06242fd3..02237e79df 100644
--- a/share/html/Admin/Tools/Config/Elements/Option
+++ b/share/html/Admin/Tools/Config/Elements/Option
@@ -169,9 +169,7 @@ my $row_end = qq{</div></div>};
     LabelCols    => 4,
     ValueCols    => 6,
     CloseRowDiv  => 0, # this doesn't have affect CustomDateRange
-    %$args,
-    %{ $m->comp('/Widgets/FinalizeWidgetArguments', WidgetArguments =>
-            $meta->{'WidgetArguments'} ) },
+    %{ $m->comp('/Widgets/FinalizeWidgetArguments', WidgetArguments => $args ) },
   &>
 % if ( $name ne 'CustomDateRanges' ) {
     <div class="col-2 file-config mt-1">

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list