Skip to content

Commit

Permalink
Update list filter strategy to use the second value from the allowed_…
Browse files Browse the repository at this point in the history
…values
  • Loading branch information
dombesz committed Feb 24, 2025
1 parent 90f6673 commit fafcb12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
11 changes: 7 additions & 4 deletions app/components/filter/filter_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ def additional_filter_attributes(filter)
end

def custom_field_list_autocomplete_options(filter)
items = if filter.custom_field.version?
filter.allowed_values.map { |name, id, project_name| { name:, id:, project_name: } }
options = if filter.custom_field.version?
{
items: filter.allowed_values.map { |name, id, project_name| { name:, id:, project_name: } },
groupBy: "project_name"
}
else
filter.allowed_values.map { |name, id| { name:, id: } }
{ items: filter.allowed_values.map { |name, id| { name:, id: } } }
end

autocomplete_options.merge(items:, model: filter.values)
autocomplete_options.merge(options).merge(model: filter.values)
end

def list_autocomplete_options(filter)
Expand Down
4 changes: 2 additions & 2 deletions app/models/queries/filters/strategies/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def validate
end

def valid_values!
filter.values &= (allowed_values.map(&:last).map(&:to_s) + ["-1"])
filter.values &= (allowed_values.map(&:second).map(&:to_s) + ["-1"])
end

def non_valid_values?
(values.reject(&:blank?) & (allowed_values.map(&:last).map(&:to_s) + ["-1"])) != values.reject(&:blank?)
(values.reject(&:blank?) & (allowed_values.map(&:second).map(&:to_s) + ["-1"])) != values.reject(&:blank?)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@
class="op-autocompleter__option-principal-email"
*ngIf="item.email"
[ngOptionHighlight]="search">{{ item.email }}</span>
<span
class="op-autocompleter__option-project-name"
*ngIf="item.project_name"
[ngOptionHighlight]="search">({{ item.project_name }})</span>
</ng-container>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@
text-overflow: ellipsis

&__option-principal-email
&__option-project-name
color: var(--fgColor-muted)
font-size: var(--font-size-small)
margin-left: var(--stack-gap-condensed)

@media screen and (max-width: $breakpoint-sm)
&__option-principal-email
&__option-project-name
display: block
margin-left: 0
margin-top: var(--control-xsmall-gap)
Expand Down

0 comments on commit fafcb12

Please sign in to comment.