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

Fix layout, add texts and correct styling

Klaus Zanders6e9a7b260450
diff --git a/app/components/queries/sort_by_component.html.erb b/app/components/queries/sort_by_component.html.erb
index 61371010445..f114d3d4be8 100644
--- a/app/components/queries/sort_by_component.html.erb
+++ b/app/components/queries/sort_by_component.html.erb
@@ -1,8 +1,10 @@
+<%= render(Primer::Beta::Heading.new(tag: :h5)) { I18n.t('queries.configure_view.sort_by.automatic.heading') } %>
+<%= render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { I18n.t('queries.configure_view.sort_by.automatic.description', plural: queried_model_name.plural) } %>
<div data-controller="sort-by-config" data-application-target="dynamic">
<%= hidden_field_tag :sortBy, current_orders, data: { "sort-by-config-target" => "sortByField" } %>
<%= render(Primer::OpenProject::FlexLayout.new(data: { "sort-by-config-target" => "inputRowContainer" })) do |layout| %>
<% order_limit.times do |i| %>
- <% layout.with_row do %>
+ <% layout.with_row(mt: 3) do %>
<%= render(Queries::SortByFieldComponent.new(order: query.orders[i], available_orders:, index: i)) %>
<% end %>
<% end %>
diff --git a/app/components/queries/sort_by_component.rb b/app/components/queries/sort_by_component.rb
index f0baaca4b2e..ec442d5d0ed 100644
--- a/app/components/queries/sort_by_component.rb
+++ b/app/components/queries/sort_by_component.rb
@@ -40,6 +40,10 @@ class Queries::SortByComponent < ApplicationComponent
3
end
+ def queried_model_name
+ query.class.model.model_name
+ end
+
def available_orders
@available_orders ||= begin
all_order_keys = ::Queries::Register.orders[query.class]&.map(&:key)
diff --git a/app/components/queries/sort_by_component.sass b/app/components/queries/sort_by_component.sass
index f2b2301c569..7c84fe86937 100644
--- a/app/components/queries/sort_by_component.sass
+++ b/app/components/queries/sort_by_component.sass
@@ -1,8 +1,7 @@
@import 'helpers'
-.op-configure-query-sort-form
- display: grid
- grid-template-columns: minmax(0, 100%) 64px
- grid-template-areas: "field field field direction"
- grid-gap: 4px
- padding-bottom: 4px
+.op-configure-query-sort-field
+ flex: 1
+
+.op-configure-query-sort-direction
+ flex: 0 0 64px
diff --git a/app/components/queries/sort_by_field_component.html.erb b/app/components/queries/sort_by_field_component.html.erb
index ec01dcccd54..2f57f726327 100644
--- a/app/components/queries/sort_by_field_component.html.erb
+++ b/app/components/queries/sort_by_field_component.html.erb
@@ -1,11 +1,11 @@
-<%= render(Primer::OpenProject::GridLayout.new(css_class: "op-configure-query-sort-form", tag: :div, data: { "sort-by-config-target" => "inputRow", "index" => index })) do |grid| %>
- <% grid.with_area("field") do %>
+<%= render(Primer::OpenProject::FlexLayout.new(data: { "sort-by-config-target" => "inputRow" })) do |flex| %>
+ <% flex.with_column(class: "op-configure-query-sort-field") do %>
<%#- We are just using the classes of the primer component here, because when using the primer component, we cannot detach the input element from the form %>
<%#- The form="none" adds the input to a nonexistant form (as we do not have one with the ID="none" and thus the fields to not get appended to the query string %>
- <%= select_tag 'sort_field', select_options, include_blank: true, form: "none", class: "FormControl-select FormControl-medium", data: { action: "change->sort-by-config#fieldChanged"} %>
+ <%= select_tag 'sort_field', select_options, include_blank: true, form: "none", class: "FormControl-select FormControl-medium FormControl--fullWidth", data: { action: "change->sort-by-config#fieldChanged"} %>
<% end %>
- <% grid.with_area("direction") do %>
- <%= render(Primer::Alpha::SegmentedControl.new("aria-label": "Sort order", hide_labels: true)) do |sort_buttons| %>
+ <% flex.with_column(class: "op-configure-query-sort-direction") do %>
+ <%= render(Primer::Alpha::SegmentedControl.new("aria-label": "Sort order", hide_labels: true, ml: 3)) do |sort_buttons| %>
<%#- The segmented control actions need to be included here as well as they do the visual styling of the currently selected option, just setting our action would remove their action %>
<% sort_buttons.with_item(icon: "sort-asc", label: "sort ascending", selected: order_asc?, data: { direction: 'asc', action: "click:segmented-control#select click->sort-by-config#fieldChanged"}) %>
<% sort_buttons.with_item(icon: "sort-desc", label: "sort descending", selected: order_desc?, data: { direction: 'desc', action: "click:segmented-control#select click->sort-by-config#fieldChanged"}) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f618308d51f..cdf14fbe90f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -3465,6 +3465,10 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
input_label: "Add columns"
input_placeholder: "Select a column"
drag_area_label: "Manage and reorder columns"
+ sort_by:
+ automatic:
+ heading: "Automatic"
+ description: "Order the %{plural} by one or more sorting criteria. You will lose the previous sorting."
top_menu:
additional_resources: "Additional resources"