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 method to allow skipping columns

Klaus Zanders7b6c28292b11
diff --git a/app/components/table_component.rb b/app/components/table_component.rb
index fd5d0ba28d0..e88c9db9593 100644
--- a/app/components/table_component.rb
+++ b/app/components/table_component.rb
@@ -31,8 +31,8 @@
##
# Abstract view component. Subclass this for a concrete table.
class TableComponent < ApplicationComponent
- def initialize(rows: [], **options)
- super(rows, **options)
+ def initialize(rows: [], **)
+ super(rows, **)
end
class << self
@@ -107,7 +107,7 @@ class TableComponent < ApplicationComponent
end
def sortable_columns_correlation
- sortable_columns.to_h { [_1.to_s, _1.to_s] }
+ sortable_columns.to_h { [it.to_s, it.to_s] }
.with_indifferent_access
end
@@ -153,20 +153,18 @@ class TableComponent < ApplicationComponent
model
end
- def row_class
- self.class.row_class
- end
+ delegate :row_class, to: :class
def container_class
nil
end
def columns
- self.class.columns
+ self.class.columns.reject { skip_column?(it) }
end
def sortable_columns
- self.class.sortable_columns
+ self.class.sortable_columns.reject { skip_column?(it) }
end
def render_collection(rows)
@@ -193,6 +191,10 @@ class TableComponent < ApplicationComponent
true
end
+ def skip_column?(_column)
+ false
+ end
+
def sortable_column?(column)
sortable? && sortable_columns.include?(column.to_sym)
end