[Rt-commit] rt branch, 4.4/disabled-cf-sortorder, repushed
? sunnavy
sunnavy at bestpractical.com
Wed Mar 7 13:07:08 EST 2018
The branch 4.4/disabled-cf-sortorder was deleted and repushed:
was a1cc40c9267e3df1d4eef5590b3540d8db924532
now 48d30c08367b88c78f9e1b97d2a7b955ba69ff33
1: 64addf7b6 = 1: 64addf7b6 Test showing incorrect sort order on re-enabled CF
2: 9e4e31abc = 2: 9e4e31abc Reset ObjectCustomField sort order when re-enabling a Custom Field
3: a1cc40c92 ! 3: 48d30c083 update ObjectCustomField sort order only if necessary when re-enabling a Custom Field
@@ -16,8 +16,24 @@
- $ocf->SetSortOrder($sort);
- RT::Logger->debug("Set Sort Order to $sort for Object Custom Field " . $ocf->Id);
+ my $last_object = $ocf->LastSibling || $ocf;
++
+ # no need to update if it's already the last one.
-+ if ( $ocf->id != $last_object->id || $last_object->IsSortOrderShared ) {
++ my $need_update;
++ if ( $ocf->id != $last_object->id ) {
++ $need_update = 1;
++ }
++ else {
++
++ # can't use IsSortOrderShared because it always returns 0 for
++ # global cfs no matter if SortOrder is shared or not
++
++ my $neighbors = $last_object->Neighbors;
++ $neighbors->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $last_object->id );
++ $neighbors->Limit( FIELD => 'SortOrder', VALUE => $last_object->SortOrder );
++ $need_update = 1 if $neighbors->Count;
++ }
++
++ if ( $need_update ) {
+ my $sort = $last_object->SortOrder + 1;
+ my ( $status, $msg ) = $ocf->SetSortOrder( $sort );
+ if ( $status ) {
More information about the rt-commit
mailing list