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

Add lookbook

Klaus Zanders4586be084d8e
diff --git a/app/components/queries/sort_by_field_component.rb b/app/components/queries/sort_by_field_component.rb
index 51dd7cc9c5a..a482d31078b 100644
--- a/app/components/queries/sort_by_field_component.rb
+++ b/app/components/queries/sort_by_field_component.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-class Queries::SortByFieldComponent < ApplicationComponent
+class Queries::SortByFieldComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
options :order,
:available_orders,
:index
diff --git a/lookbook/previews/queries/sort_by_component_preview.rb b/lookbook/previews/queries/sort_by_component_preview.rb
new file mode 100644
index 00000000000..7d332cba9f7
--- /dev/null
+++ b/lookbook/previews/queries/sort_by_component_preview.rb
@@ -0,0 +1,17 @@
+module Queries
+ class SortByComponentPreview < Lookbook::Preview
+ def default
+ query = ::Queries::Projects::ProjectQuery.new
+ query.order(lft: :asc)
+ query.order(created_at: :desc)
+
+ render SortByComponent.new(
+ query:,
+ selectable_columns: [
+ { id: :lft, name: I18n.t(:label_project_hierarchy) },
+ { id: :created_at, name: I18n.t("attributes.created_at") }
+ ]
+ )
+ end
+ end
+end