From 0fad97a7140f28053204598012665e584c456346 Mon Sep 17 00:00:00 2001 From: sunnavy Date: Wed, 3 Apr 2024 17:35:50 -0400 Subject: [PATCH] Re-enable links autocomplete on create pages Previously we accidentally disabled links autocomplete on create pages when adding the "excluding existing links" feature in c0888d6165. The main reason is %exclude_links contained not just exclude ids but also autocomplete flags. As it was set only when exclude ids were not empty, it broke create pages. This commit separates default autocomplete flags from %exclude_links and explicitly add it to all link inputs to make the logic more clear. --- share/html/Elements/AddLinks | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/share/html/Elements/AddLinks b/share/html/Elements/AddLinks index 32cbf9c8fe7..ac8cde57e3b 100644 --- a/share/html/Elements/AddLinks +++ b/share/html/Elements/AddLinks @@ -55,7 +55,7 @@ my $id = ($Object and $Object->id) ? $Object->id : "new"; -my $exclude = qq| data-autocomplete="LinkTargets" data-autocomplete-multiple="1"|; +my $autocomplete = qq|data-autocomplete="LinkTargets" data-autocomplete-multiple="1"|; my @excludes; push @excludes, ( $Object->isa('RT::Asset') ? 'asset:' : '' ) . $id if $id ne 'new'; @@ -98,7 +98,7 @@ foreach my $exclude_type ( keys %exclude_links ) { } } } - $exclude_links{$exclude_type} = $exclude . ' data-autocomplete-exclude="' . join( ' ', @excludes, @ids ) . '"' + $exclude_links{$exclude_type} = 'data-autocomplete-exclude="' . join( ' ', @excludes, @ids ) . '"' if @excludes || @ids; } @@ -120,24 +120,24 @@ foreach my $exclude_type ( keys %exclude_links ) { <&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Depends on'), Relation => 'DependsOn') &> - " <% $exclude_links{Depend} |n%>/> + " <% $autocomplete |n %> <% $exclude_links{Depend} |n%>/> <&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Depended on by'), Relation => 'DependedOnBy') &> - " <% $exclude_links{Depend} |n%>/> + " <% $autocomplete |n %> <% $exclude_links{Depend} |n%>/> <&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Parents'), Relation => 'Parents') &> - " <% $exclude_links{Member} |n%>/> + " <% $autocomplete |n %> <% $exclude_links{Member} |n%>/> <&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Children'), Relation => 'Children') &> - " <% $exclude_links{Member} |n%>/> + " <% $autocomplete |n %> <% $exclude_links{Member} |n%>/> <&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Refers to'), Relation => 'RefersTo') &> - " <% $exclude_links{Refer} |n%>/> + " <% $autocomplete |n %> <% $exclude_links{Refer} |n%>/> <&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Referred to by'), Relation => 'ReferredToBy') &> - " <% $exclude_links{Refer} |n%>/> + " <% $autocomplete |n %> <% $exclude_links{Refer} |n%>/> <& /Elements/EditCustomFields,