diff options
| author | Teddy Wing | 2017-09-01 15:14:45 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-09-01 15:14:45 +0200 |
| commit | 9470a51cfc5fb3fd4d5fde2fb4e12caf3eaaa8eb (patch) | |
| tree | a0544de6bb1e0dee28dae7d4e9d5b4efca7bf852 | |
| parent | 7f85e8bbb15ec4063dad8b080e61d690b77dead7 (diff) | |
| download | chouette-core-9470a51cfc5fb3fd4d5fde2fb4e12caf3eaaa8eb.tar.bz2 | |
TableBuilderHelper: Test out column-specific `#link_to`
Testing out the new `TableBuilderHelper::Column#link_to` method to
provide the link needed to go to the row object's #show page.
Seems to work in this context, which is promising!
| -rw-r--r-- | app/helpers/table_builder_helper.rb | 6 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index f15019458..61812a427 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -186,6 +186,12 @@ module TableBuilderHelper columns.each do |column| value = column.value(item) + 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( diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 8d924b360..bb54f07cb 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -27,7 +27,10 @@ [ \ TableBuilderHelper::Column.new( \ key: :name, \ - attribute: 'name' \ + attribute: 'name', \ + link_to: lambda do |referential| \ + referential_path(referential) \ + end \ ), \ TableBuilderHelper::Column.new( \ key: :status, \ |
