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

Use proper Primer styling and remove debug output

Klaus Zanders7dccb82adae0
diff --git a/app/components/queries/sort_by_component.html.erb b/app/components/queries/sort_by_component.html.erb
index 87738f51732..61371010445 100644
--- a/app/components/queries/sort_by_component.html.erb
+++ b/app/components/queries/sort_by_component.html.erb
@@ -1,5 +1,5 @@
<div data-controller="sort-by-config" data-application-target="dynamic">
- <%= text_field_tag :sortBy, current_orders, data: { "sort-by-config-target" => "sortByField" } %>
+ <%= 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 %>
diff --git a/app/components/queries/sort_by_component.sass b/app/components/queries/sort_by_component.sass
index e88f92813fc..f2b2301c569 100644
--- a/app/components/queries/sort_by_component.sass
+++ b/app/components/queries/sort_by_component.sass
@@ -2,6 +2,7 @@
.op-configure-query-sort-form
display: grid
- grid-template-columns: minmax(0, 100%) 100px
- grid-template-areas: "field field direction"
- grid-gap: 8px
+ grid-template-columns: minmax(0, 100%) 64px
+ grid-template-areas: "field field field direction"
+ grid-gap: 4px
+ padding-bottom: 4px
diff --git a/app/components/queries/sort_by_field_component.html.erb b/app/components/queries/sort_by_field_component.html.erb
index e9593db3d23..ec01dcccd54 100644
--- a/app/components/queries/sort_by_field_component.html.erb
+++ b/app/components/queries/sort_by_field_component.html.erb
@@ -1,6 +1,8 @@
<%= 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 %>
- <%= select_tag 'sort_field', select_options, include_blank: true, form: "none", data: { action: "change->sort-by-config#fieldChanged"} %>
+ <%#- 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"} %>
<% end %>
<% grid.with_area("direction") do %>
<%= render(Primer::Alpha::SegmentedControl.new("aria-label": "Sort order", hide_labels: true)) do |sort_buttons| %>
diff --git a/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts b/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts
index 0133f64512b..bb2736df96e 100644
--- a/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts
@@ -43,7 +43,7 @@ export default class SortByConfigController extends Controller {
declare readonly inputRowContainerTarget:HTMLElement;
connect():void {
- this.inputRowTargets.forEach((row, index) => {
+ this.inputRowTargets.forEach((row) => {
const selectedField = this.getSelectedField(row);
const selectedDirection = this.getSelectedDirection(row);
@@ -54,7 +54,7 @@ export default class SortByConfigController extends Controller {
}
this.displayNewFieldSelectorIfNeeded();
- this.disableOptions();
+ this.disableSelectedFieldsForOtherSelects();
});
}
@@ -89,10 +89,8 @@ export default class SortByConfigController extends Controller {
}
this.displayNewFieldSelectorIfNeeded();
-
- this.disableOptions();
+ this.disableSelectedFieldsForOtherSelects();
this.sortByFieldTarget.value = this.buildSortJson();
- console.log({ visible: this.visibleFieldCount(), order: this.inputRowTargets.map((iRow) => iRow.dataset.index) });
}
displayNewFieldSelectorIfNeeded():void {
@@ -169,12 +167,12 @@ export default class SortByConfigController extends Controller {
}
moveRowToBottom(row:HTMLElement):void {
- const surroundingDiv = row.parentElement as HTMLElement;
+ const surroundingDiv = row.parentElement as HTMLElement; // the row is wrapped in a div
surroundingDiv.remove();
this.inputRowContainerTarget.append(surroundingDiv);
}
- disableOptions():void {
+ disableSelectedFieldsForOtherSelects():void {
this.inputRowTargets.forEach((row) => {
const selectedFieldsInOtherRows = this.getAllSelectedFields(row);
const otherSelect = row.querySelector('select[name="sort_field"]') as HTMLSelectElement;