aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorTeddy Wing2017-06-09 14:45:36 +0200
committerTeddy Wing2017-06-09 15:26:44 +0200
commit74e02b7666efda81344728c3f7a27039db96f830 (patch)
tree1d69991ccbd78a23badf78322e30880224251eed /app/helpers
parent913cdad28b20ade05cccf262b096b02db2e0ab93 (diff)
downloadchouette-core-74e02b7666efda81344728c3f7a27039db96f830.tar.bz2
TableBuilderHelper: Move thead & tbody sections to their own methods
Make new private methods for the <thead> and <tbody> element builders. This just splits out the work in `table_builder_2` into smaller pieces, to begin to make them more manageable. Refs #3479
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/table_builder_helper.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 2296af8c7..0a32e528c 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -16,8 +16,17 @@ module TableBuilderHelper
# TODO: add `linked_column` or some such attribute that defines which column should be linked and what method to call to get it
)
- # TODO: Maybe move this to a private method
- head = content_tag :thead do
+
+ content_tag :table,
+ thead(collection, columns, selectable, links) +
+ tbody(collection, columns, selectable, links),
+ class: cls
+ end
+
+ private
+
+ def thead(collection, columns, selectable, links)
+ content_tag :thead do
content_tag :tr do
hcont = []
@@ -43,9 +52,11 @@ module TableBuilderHelper
hcont.join.html_safe
end
end
+ end
+ def tbody(collection, columns, selectable, links)
# TODO: refactor
- body = content_tag :tbody do
+ content_tag :tbody do
collection.collect do |item|
content_tag :tr do
@@ -99,12 +110,8 @@ module TableBuilderHelper
end
end.join.html_safe
end
-
- content_tag :table, head + body, class: cls
end
- private
-
# TODO: `def build_link[s]`
def links_builder(item, actions)
trigger = content_tag :div, class: 'btn dropdown-toggle', data: { toggle: 'dropdown' } do