[Rt-commit] rt branch 4.4/cfv-order-by-category created. rt-4.4.5-23-g65b1b00099

BPS Git Server git at git.bestpractical.com
Wed Jan 26 21:22:27 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".

The branch, 4.4/cfv-order-by-category has been created
        at  65b1b00099da62d52f5bb9ffe1419c6468024f9d (commit)

- Log -----------------------------------------------------------------
commit 65b1b00099da62d52f5bb9ffe1419c6468024f9d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 26 00:42:53 2022 +0800

    Update tests for the default order change of custom field values

diff --git a/t/customfields/combo_cascade.t b/t/customfields/combo_cascade.t
index fba2fac868..4278bc8240 100644
--- a/t/customfields/combo_cascade.t
+++ b/t/customfields/combo_cascade.t
@@ -19,15 +19,15 @@ works($id,$msg);
 
 sub add_works {
     works(
-        $cf->AddValue(Name => $_[0], Description => $_[0], Category => $_[1])
+        $cf->AddValue(Name => $_[0], Description => $_[0], Category => $_[1], SortOrder => $_[2])
     );
 };
 
-add_works('value1', '1. Category A');
-add_works('value2');
-add_works('value3', '1.1. A-sub one');
-add_works('value4', '1.2. A-sub two');
-add_works('value5', '');
+add_works('value1', '1. Category A', 1);
+add_works('value2', '', 2);
+add_works('value3', '1.1. A-sub one', 3);
+add_works('value4', '1.2. A-sub two', 4);
+add_works('value5', '', 5);
 
 my $cfv = $cf->Values->First;
 is($cfv->Category, '1. Category A');

commit 96400627db3e0d39e355692eb26491c6c2462770
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jan 25 21:28:01 2022 +0800

    Group custom field values by category
    
    Categories are shown as optgroup labels, previously the select input
    could look like:
    
        Bar
          1 bar
        Foo
          1 foo
        Bar
          2 bar
        Foo
          2 foo
    
    With this commit, the UI is like:
    
        Bar
          1 bar
          2 bar
        Foo
          1 foo
          2 foo
    
    It's more compact and less confusing.
    
    This change also gets around the limitation that current cascaded.js
    doesn't support multiple optgroups sharing the same label(only the first
    one is shown).

diff --git a/lib/RT/CustomFieldValues.pm b/lib/RT/CustomFieldValues.pm
index 73cee9e0d9..e1855f68e9 100644
--- a/lib/RT/CustomFieldValues.pm
+++ b/lib/RT/CustomFieldValues.pm
@@ -65,6 +65,9 @@ sub _Init {
          { ALIAS => 'main',
            FIELD => 'SortOrder',
            ORDER => 'ASC' },
+         { ALIAS => 'main',
+           FIELD => 'Category',
+           ORDER => 'ASC' },
          { ALIAS => 'main',
            FIELD => 'Name',
            ORDER => 'ASC' },
diff --git a/lib/RT/CustomFieldValues/External.pm b/lib/RT/CustomFieldValues/External.pm
index 8c449409da..f2c095d5b8 100644
--- a/lib/RT/CustomFieldValues/External.pm
+++ b/lib/RT/CustomFieldValues/External.pm
@@ -209,7 +209,7 @@ sub _SortValues {
 
     no warnings 'uninitialized';
 
-    return sort { $a->{sortorder} <=> $b->{sortorder} || lc($a->{name}) cmp lc($b->{name}) }
+    return sort { $a->{sortorder} <=> $b->{sortorder} || lc($a->{category}) cmp lc($b->{category}) || lc($a->{name}) cmp lc($b->{name}) }
                @items;
 }
 

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list