aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-09-01 15:34:45 +0200
committerTeddy Wing2017-09-01 15:38:48 +0200
commitb546fc6ef6d406a041f5a26f5855a02b7c8d1f2c (patch)
tree15ba030010b2a9b6a9c8d930c4d3d89d59980c9f
parent9470a51cfc5fb3fd4d5fde2fb4e12caf3eaaa8eb (diff)
downloadchouette-core-b546fc6ef6d406a041f5a26f5855a02b7c8d1f2c.tar.bz2
TableBuilderHelper#tbody: Use new `Column#link_to` for all column links
Instead of always linking to the `name` and `comment` attributes, allow any column to link to any thing by calling the new `TableBuilderHelper::Column#link_to` method. Because `linkable?`-ness is now determined at the column level, we can get rid of the `#column_is_linkable?` method here. The code is still pretty much "en désordre" as a result of the `overhead` code tornado, but we'll have to deal with that later. (Oh goodness I hope we get to deal with it.)
-rw-r--r--app/helpers/table_builder_helper.rb23
1 files changed, 5 insertions, 18 deletions
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 61812a427..94a7a62e6 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -188,19 +188,10 @@ module TableBuilderHelper
if column.linkable?
path = column.link_to(item)
- bcont << content_tag(:td, link_to(value, path), title: 'Voir')
- next # TODO: temporary for testing, fix all the stuff below
- end
-
- if column_is_linkable?(column)
- # Build a link to the `item`
- polymorph_url = URL.polymorphic_url_parts(
- item,
- referential
- )
+ link = link_to(value, path)
if overhead.empty?
- bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir')
+ bcont << content_tag(:td, link, title: 'Voir')
else
i = columns.index(column)
@@ -209,16 +200,16 @@ module TableBuilderHelper
if (i > 0) && (overhead[i - 1][:width] > 1)
clsArrayAlt = overhead[i - 1][:cls].split
- bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir', class: td_cls(clsArrayAlt))
+ bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArrayAlt))
else
- bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir')
+ bcont << content_tag(:td, link, title: 'Voir')
end
else
clsArray = overhead[columns.index(column)][:cls].split
- bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir', class: td_cls(clsArray))
+ bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArray))
end
end
@@ -340,10 +331,6 @@ module TableBuilderHelper
end
end
- def column_is_linkable?(column)
- column.attribute == 'name' || column.attribute == 'comment'
- end
-
def gear_menu_link(link)
content_tag(
:li,