aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-10-25 11:55:02 +0200
committerRobert2017-10-25 11:55:02 +0200
commit9bfd7674868c858742e9dd39ab2f572b9f60b410 (patch)
tree8debd0a4fd1a28562a21956a10db685437c8ba26
parentefe056fb645f0380e594f57ad058409194f3becd (diff)
downloadchouette-core-0000-enhanced-table-builder.tar.bz2
-rw-r--r--app/helpers/table_builder_helper.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 95f53a90d..37f01ce0d 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -83,17 +83,21 @@ module TableBuilderHelper
cls: '',
# A set of content, over the th line...
- overhead: []
+ overhead: [],
+
+ # Possibility to override the result of collection.model
+ model: nil
+
)
content_tag :table,
- thead(collection, columns, sortable, selectable, links.any?, overhead) +
+ thead(collection, columns, sortable, selectable, links.any?, overhead, model || collection.model) +
tbody(collection, columns, selectable, links, overhead),
class: cls
end
private
- def thead(collection, columns, sortable, selectable, has_links, overhead)
+ def thead(collection, columns, sortable, selectable, has_links, overhead, model )
content_tag :thead do
# Inserts overhead content if any specified
over_head = ''
@@ -121,7 +125,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -137,7 +141,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -147,7 +151,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -160,7 +164,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -299,14 +303,14 @@ module TableBuilderHelper
def build_column_header(
column,
table_is_sortable,
- collection_model,
+ model,
params,
sort_on,
sort_direction
)
if !table_is_sortable || !column.sortable
- return column.header_label(collection_model)
+ return column.header_label(model)
end
direction =
@@ -331,7 +335,7 @@ module TableBuilderHelper
arrow_icons = content_tag :span, arrow_up + arrow_down, class: 'orderers'
(
- column.header_label(collection_model) +
+ column.header_label(model) +
arrow_icons
).html_safe
end