From 26d3971892dbeacffba678a3dd9593095da14b29 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 12 Jun 2017 16:58:25 +0200 Subject: ReferentialsController#show: Fix whitespace Method was indented by three spaces. Should be two. Refs #3479 --- app/controllers/referentials_controller.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 437444f29..c65e6552c 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -24,19 +24,19 @@ class ReferentialsController < BreadcrumbController end def show - resource.switch - show! do |format| - format.json { - render :json => { :lines_count => resource.lines.count, - :networks_count => resource.networks.count, - :vehicle_journeys_count => resource.vehicle_journeys.count + resource.vehicle_journey_frequencies.count, - :time_tables_count => resource.time_tables.count, - :referential_id => resource.id} - } - format.html { build_breadcrumb :show} - end - - @reflines = lines_collection.paginate(page: params[:page], per_page: 10) + resource.switch + show! do |format| + format.json { + render :json => { :lines_count => resource.lines.count, + :networks_count => resource.networks.count, + :vehicle_journeys_count => resource.vehicle_journeys.count + resource.vehicle_journey_frequencies.count, + :time_tables_count => resource.time_tables.count, + :referential_id => resource.id} + } + format.html { build_breadcrumb :show} + end + + @reflines = lines_collection.paginate(page: params[:page], per_page: 10) end def edit -- cgit v1.2.3 From 07ed048cd2f2231fa26345a94c725363344ee77b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 12 Jun 2017 18:59:23 +0200 Subject: 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 --- app/controllers/referentials_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers/referentials_controller.rb') 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, -- cgit v1.2.3 From 83d4edea80186c933ea83797f9fa49e24ec07fd4 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 14 Jun 2017 19:10:59 +0200 Subject: ReferentialsController#show: Use short syntax to decorate @referential I hadn't used this syntax before because I think I had tried: @referential.decorate without the assignment. Of course it didn't work at the time, but I didn't notice so I switched to this syntax which did work. Use the shorter one because it's a bit cleaner. Refs #3479 --- app/controllers/referentials_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 50b2e47c6..e95670241 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -26,7 +26,7 @@ class ReferentialsController < BreadcrumbController def show resource.switch show! do |format| - @referential = ReferentialDecorator.new(@referential) + @referential = @referential.decorate format.json { render :json => { :lines_count => resource.lines.count, -- cgit v1.2.3