diff options
| author | Teddy Wing | 2017-06-12 18:59:23 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-12 18:59:23 +0200 | 
| commit | 07ed048cd2f2231fa26345a94c725363344ee77b (patch) | |
| tree | 472445c9931d139629516e312a9daa640bc16843 /app/controllers/referentials_controller.rb | |
| parent | 53c68600f1e3f80d2765fe41ed3a451c17eeabea (diff) | |
| download | chouette-core-07ed048cd2f2231fa26345a94c725363344ee77b.tar.bz2 | |
referentials/show.html.slim: Extract header buttons to a decorator
Add a new `ReferentialDecorator` that we can use to define the links
that appear as buttons in the header of the `/referentials/:id` page.
The idea is that these links will take the place of the existing view
code and in the view, we'll instead loop over the links provided by the
decorator and render them as buttons.
I decided to do it this way because there's a requirement that the links
in the gear menu in tables show the same links that appear in the header
of the page. So the Workbenches#show page would show a table of
referentials, and their gear menu links should ostensibly be the same as
the header links in the Referentials#show page.
My goal was to abstract links, and try to separate them from the
presentation layer. Still having trouble with this though. I created a
new `Link` class to represent a link. We can then use this in the
template to create a `link_to`. It becomes messy, though, when we want
to put other elements inside a certain link, as evidenced by the
`:delete` link. Don't like how that's done, but still working out the
best approach to make it cleaner.
Refs #3479
Diffstat (limited to 'app/controllers/referentials_controller.rb')
| -rw-r--r-- | app/controllers/referentials_controller.rb | 2 | 
1 files changed, 2 insertions, 0 deletions
| diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index c65e6552c..50b2e47c6 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -26,6 +26,8 @@ class ReferentialsController < BreadcrumbController    def show      resource.switch      show! do |format| +      @referential = ReferentialDecorator.new(@referential) +        format.json {          render :json => { :lines_count => resource.lines.count,                 :networks_count => resource.networks.count, | 
