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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Handle displayed status completely in JS
Klaus Zanders4717be30d7cc
diff --git a/app/components/queries/sort_by_field_component.html.erb b/app/components/queries/sort_by_field_component.html.erbindex 30c76006684..5fe3cf8a58d 100644--- a/app/components/queries/sort_by_field_component.html.erb+++ b/app/components/queries/sort_by_field_component.html.erb@@ -1,10 +1,11 @@-<%= render(Primer::OpenProject::GridLayout.new(css_class: "op-configure-query-sort-form", tag: :div, data: { "sort-by-config-target" => "inputRow"}, style: (display? ? "" : "display:none;"))) do |grid| %>+<%= render(Primer::OpenProject::GridLayout.new(css_class: "op-configure-query-sort-form", tag: :div, data: { "sort-by-config-target" => "inputRow"})) 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"} %><% end %><% grid.with_area("direction") do %><%= render(Primer::Alpha::SegmentedControl.new("aria-label": "Sort order", hide_labels: true)) do |sort_buttons| %>- <% 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"}) %>+ <%#- 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"}) %><% end %><% end %>diff --git a/app/components/queries/sort_by_field_component.rb b/app/components/queries/sort_by_field_component.rbindex 309c73d55b8..51dd7cc9c5a 100644--- a/app/components/queries/sort_by_field_component.rb+++ b/app/components/queries/sort_by_field_component.rb@@ -40,10 +40,6 @@ class Queries::SortByFieldComponent < ApplicationComponent)end- def display?- active? || index == 0- end-def active?order.present? && available_orders.any? { |o| order.attribute.to_sym == o[:id] }enddiff --git a/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts b/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.tsindex 733166162b3..a471a1fef2c 100644--- a/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts@@ -40,14 +40,7 @@ export default class SortByConfigController extends Controller {declare readonly sortByFieldTarget:HTMLInputElement;declare readonly inputRowTargets:HTMLElement[];- connect():void {- console.log('Hello, we are connected!');- console.log(`Current value of the field: ${this.sortByFieldTarget.value}`);- console.log(`Visible rows: ${this.visibleFieldCount()}`);- console.log(this.inputRowTargets);- console.log(this.buildSortJson());- this.setDirection(this.inputRowTargets[0], 'desc');-}+ connect():void { }buildSortJson():string {const filters = this.inputRowTargets.map((row) => {@@ -63,6 +56,23 @@ fieldChanged(event:Event):void {const target = event.target as HTMLElement;const row = target.closest('.op-configure-query-sort-form') as HTMLElement;+ const selectedField = this.getSelectedField(row);+ const getSelectedDirection = this.getSelectedDirection(row);++ if (!selectedField) {+ // we have deselected the field, so we need to unset the direction, remove the row and move it to the end of the list+ // const lastRow = this.inputRowTargets[this.inputRowTargets.length - 1];++ this.unsetDirection(row);++ // Unless we are the first row, hide the rows+ if (row !== this.inputRowTargets[0]) { this.hideRow(row); }+ } else if (!getSelectedDirection) {+ // if we have selected a field but no direction, we default to ascending+ this.setDirection(row, 'asc');+ }++ // this.disableOptionInOtherSelects(row);this.sortByFieldTarget.value = this.buildSortJson();}@@ -103,4 +113,25 @@ fieldChanged(event:Event):void {}});}++ showRow(row:HTMLElement):void {+ row.style.display = '';+ }++ hideRow(row:HTMLElement):void {+ row.style.display = 'none';+ }++ disableOptionInOtherSelects(row:HTMLElement):void {+ const selectedField = this.getSelectedField(row);++ this.inputRowTargets.forEach((otherRow) => {+ if (otherRow !== row) {+ const otherSelect = otherRow.querySelector('select[name="sort_field"]') as HTMLSelectElement;+ otherSelect.querySelectorAll('option').forEach((option) => {+ option.disabled = option.value === selectedField;+ });+ }+ });+ }}