Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Update list filter strategy to use the second value from the allowed_values

Dombi Attila290a31256f76
diff --git a/app/components/filter/filter_component.rb b/app/components/filter/filter_component.rb
index 755fb17fd5a..dff5ad3a70b 100644
--- a/app/components/filter/filter_component.rb
+++ b/app/components/filter/filter_component.rb
@@ -81,13 +81,16 @@ module 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)
diff --git a/app/models/queries/filters/strategies/list.rb b/app/models/queries/filters/strategies/list.rb
index 6476b0984fe..dc5415ea95c 100644
--- a/app/models/queries/filters/strategies/list.rb
+++ b/app/models/queries/filters/strategies/list.rb
@@ -52,11 +52,11 @@ module Queries::Filters::Strategies
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
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
index 921ef7563e4..a46c860ca18 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
@@ -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>
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.sass b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.sass
index e9fc8981b34..b8022bb7747 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.sass
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.sass
@@ -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)