aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
AgeCommit message (Collapse)Author
2017-07-12StopAreaReferentials#index: Use new table builder helperTeddy Wing
Change "_filters.html.slim" to call `#human_attribute_name` on the model instead of the collection, because the collection decorator doesn't delegate that method, and it's better to call it on the class. Refs #3479
2017-07-12StopAreaReferentials#show: Move header links to decoratorTeddy Wing
On the http://stif-boiv.dev:3000/stop_area_referentials/1/stop_areas/139416 page, move the header links into a decorator to allow us to use them in the table of stop areas on StopAreaReferentials#index. Refs #3479
2017-07-12Networks#index: Use new table builder helper on both networks tablesTeddy Wing
Refs #3479
2017-07-12Networks#show: Move header links into a decoratorTeddy Wing
In order to allow us to use these links in tables of networks via the new table builder, move the link definitions into decorator `#action_links`. This changes both of these types of pages: * http://stif-boiv.dev:3000/referentials/4/networks/118 * http://stif-boiv.dev:3000/line_referentials/1/networks/118 Refs #3479
2017-07-12RoutingConstraintZones#show: Match decorator context from #indexTeddy Wing
Just wrote the `#index` method and saw that the `#show` method's `context` hash contents are a bit verbose. Shorten them to match the `#index` method. These mean the same thing but are a bit cleaner. Refs #3479
2017-07-12RoutingConstraintZones#index: Use new table builder helperTeddy Wing
Render table of `RoutingConstraintZones` using the new table builder. Refs #3479
2017-07-12RoutingConstraintZones#show: Fix breadcrumbTeddy Wing
I had broken the breadcrumb by overriding `#show` here. Add in the `build_breadcrumb` call to make it appear again. Refs #3479
2017-07-12ReferentialLines#show: Render links from ReferentialLineDecoratorTeddy Wing
Leverage our newly created `ReferentialLineDecorator` to render the header links, allowing us to use them both here and in the table of lines on the Referentials#show page. Used the extended decoration syntax to allow us to specify the `ReferentialLineDecorator`, otherwise Draper will infer `LineDecorator`, which is not what we want in this case. Refs #3479
2017-07-12Referentials#show: Use new table builder helperTeddy Wing
Needed to add a new decorator to provide links to this table's gear menu. The links correspond to those in the header on the "referential_lines/show.html.slim" page. Call `#human_attribute_name` on the model directly instead of the collection because the decorated collection doesn't expose that method. Refs #3479
2017-07-12#4015 adjust Tag filter to be strictcedricnjanga
2017-07-12Remove ReferentialLines#indexTeddy Wing
Delete this route and associated template files. Wasn't sure if using `exclude:` in the routes file was the best way to do this, as I'm not sure if there are other routes we want to exclude from here also. I visited the page because I'm migrating templates to the new table builder helper and this one uses table builder. Upon visiting the page, it looked pretty wonky, and after consulting with Jean-Paul and Luc, it turns out this page isn't used any more because the table of `Chouette::Line`s rendered there is now instead displayed on the Referentials#show page, obviating the need for this page. Refs #3479
2017-07-12CompanyDecorator#action_links: Rename `line_referential` context paramTeddy Wing
Rename this to `referential` to be more generic. This is because we could be passing both `Referential`s and `LineReferential`s into this parameter. In `CompaniesController`, we use a `LineReferential` while in `ReferentialCompaniesController` we use `Referential`. Refs #3479
2017-07-12ReferentialCompanies#index: Use new table builder helperTeddy Wing
TODO: Rename `line_referential` context parameter in `CompanyDecorator` to `referential` since the name needs to make sense both for `Referential` and for `LineReferential`. Refs #3479
2017-07-12Companies#index: Use new table builder helperTeddy Wing
Refs #3479
2017-07-11hotfix to open all non standard actions on ApplicationControllerRobert
2017-07-09Refs: #3478@1h; fixes a view error in references#show(format: js)Robert
2017-07-07Fix routing_constraint_zone validation for create refs #3962 @3Luc Donnet
2017-07-07Hotfix user_permission computation in journey_patterns and vehicle_journey ↵Robert
controllers
2017-07-07TimeTables#index: Use new table builder helperTeddy Wing
Additionally convert the `#human_attribute_name` calls to call it on the class because this is more correct and because that method doesn't exist on the decorated collection of `@time_tables`. TODO: There's a bug here where the #show and #edit links don't link correctly, they go to `/referentials/:id` instead of `/referentials/:id/time_tables/:id`. Refs #3479
2017-07-07CalendarsController: Fix breadcrumb on #index & #showTeddy Wing
Apparently I messed up the breadcrumb in these views because I was overriding the `#index` and `#show` methods defined in `BreadcrumbController`, which make these calls to `#build_breadcrumb`. Add them in to restore the breadcrumb links to these pages. Refs #3479
2017-07-07Calendars#index: Use new table builder helperTeddy Wing
Refs #3479
2017-07-07ReferentialLines#show: Use new table builder helperTeddy Wing
Convert the table of `Route`s on this page to use the new table builder helper. This gives us the links from the `RouteDecorator` in the gear menu next to each row in the table. Ended up removing the `route_sp` field from the `RouteDecorator` context because it seems like we can just grab that collection directly from the `Route` object. At first I thought about renaming it because after coming back to this code I thought, 'what does sp mean?'. Then after some investigation, it appears that we don't need to pass it in explicitly. Now, no need to bother with that from the ReferentialLines controller. The RoutesController does create a separate `@route_sp` variable, but this only changes the sort order of the stop points, not the contents of the collection. Thus it seems safe to get them directly from the Route in the decorator. Refs #3479
2017-07-06Conflict resolvedRobert
2017-07-06Lines#index: Use new `table_builder_2`Teddy Wing
Convert the table of Lines to use the new version of the table builder. Update the view with the new calling format of the helper. The controller needs to decorate the `@lines` collection in order to make `#action_links` available to the table builder. Needed to update the "_filters.html.slim" template to call `#human_attribute_name` on the class instead of the collection, because we can't do that on a decorated collection. Refs #3479
2017-07-06Refs:#3478@10h;Robert
Policy Refactoring and Policy Test Completion - All policies (and all permissions) under test. - Common patterns and potential problems identified... - ... and documented in DEVNOTES.md - some simply refactorings
2017-07-05Refs: #3478@1.5h;Robert
- PolicyChecker authorizes(*) all now - Untied ApplicationPolicy#index? from show? - mv access_point_policy.rb to access_point_policy.rb fixing an invisible name curruption (local problem?) * to authorize: to allow (not here), to undergo the process of authorization (here)
2017-07-04Refs: #3478@2h Access correct referential in line_footnotes CtrlRobert
+ ApplicationController provides Pundit's UserContext's referential with `@referential` instead of `current_referential`, (`@referential` is computed from the URL, while `current_referential` was aliased to different methods, **not always** pointing to `Referential` instances) + ApplicationPolicy uses the record's referential in its `referential method` iff it is an instance of `Referential` else it uses the abovely provided referential, locally named `@current_referential` (as it should be named in the Ctrl too) This assures, in combination with the Ctrl Change, that `referential` **always** returns an instance of `Referential`! - TODO: Review my understanding of _Referential Setup_ inside the Ctrls
2017-07-04Fix autocomplete_calendars_path should also return shared calendarXinhui
Refs #3954
2017-07-04Fix workbench#show should keep filtering on sortXinhui
Refs #3871
2017-07-03Workbench#show filtering restore q_for_resultXinhui
2017-07-03Refactoring workbench_controller ransack_statusXinhui
refs #3936
2017-07-03Merge branch 'master' of github.com:AF83/stif-boivLuc Donnet
2017-07-03Fix routing constraint zones edit and new Refs #3953Luc Donnet
2017-07-03Adapt test & controller according to convert_to_timetable fixaf83
2017-06-29Fix RoutingConstraintZone PolicyLuc Donnet
2017-06-28Hotfix fixes: #3793@1hRobert
2017-06-27conflicts resolvedRobert
2017-06-26Fix workbench#show sort with period filterXinhui
Refs #3826
2017-06-23Fix workbench#show filter by associated lines with sortingXinhui
refs #3826
2017-06-23JS for date validationRobert
2017-06-20Refs: #3595@3h; calendars/new Date validationRobert
2017-06-19lines/show.html.erb_spec.rb: Fix specs resulting from `LineDecorator`Teddy Wing
The tests failed because we weren't using a decorated `Chouette::Line` object, but the views now expect decorated lines in order to be able to call the `#action_links` method. Here are our failures: 5) /lines/show should render h1 with the line name Failure/Error: - @line.action_links.each do |link| ActionView::Template::Error: undefined method `action_links' for #<Chouette::Line:0x007fc8cdf0bb88> # ./app/views/lines/show.html.slim:10:in `block in _app_views_lines_show_html_slim___3813514632397395671_70250211127360' # ./app/helpers/newapplication_helper.rb:246:in `block (2 levels) in pageheader' # ./app/helpers/newapplication_helper.rb:244:in `block in pageheader' # ./app/helpers/newapplication_helper.rb:243:in `pageheader' # ./app/views/lines/show.html.slim:2:in `_app_views_lines_show_html_slim___3813514632397395671_70250211127360' # ./spec/views/lines/show.html.erb_spec.rb:16:in `block (2 levels) in <top (required)>' # -e:1:in `<main>' # ------------------ # --- Caused by: --- # NoMethodError: # undefined method `action_links' for #<Chouette::Line:0x007fc8cdf0bb88> # ./app/views/lines/show.html.slim:10:in `block in _app_views_lines_show_html_slim___3813514632397395671_70250211127360' 6) /lines/show should render a link to remove the line Failure/Error: - @line.action_links.each do |link| ActionView::Template::Error: undefined method `action_links' for #<Chouette::Line:0x007fc8cfdaa710> # ./app/views/lines/show.html.slim:10:in `block in _app_views_lines_show_html_slim___3813514632397395671_70250211127360' # ./app/helpers/newapplication_helper.rb:246:in `block (2 levels) in pageheader' # ./app/helpers/newapplication_helper.rb:244:in `block in pageheader' # ./app/helpers/newapplication_helper.rb:243:in `pageheader' # ./app/views/lines/show.html.slim:2:in `_app_views_lines_show_html_slim___3813514632397395671_70250211127360' # ./spec/views/lines/show.html.erb_spec.rb:31:in `block (2 levels) in <top (required)>' # -e:1:in `<main>' # ------------------ # --- Caused by: --- # NoMethodError: # undefined method `action_links' for #<Chouette::Line:0x007fc8cfdaa710> # ./app/views/lines/show.html.slim:10:in `block in _app_views_lines_show_html_slim___3813514632397395671_70250211127360' Update the test to decorate the lines used in them. Turn `current_organisation` into a `context` field on `LineDecorator` because otherwise it's a global variable that comes from wherever that's required in `LineDecorator`. And we'd have to mock `current_organisation` on `line` in the test, which I wasn't keen on. Refs #3479
2017-06-19CalendarsController#show: Wrap `@calendar` assignment in `#show!`Teddy Wing
Don't really know what this is (assuming it comes from 'inherited_resources'), but putting the decoration inside this block seemed to work in the other cases I tried recently (like `LinesController#show`). Refs #3479
2017-06-19Merge remote-tracking branch 'origin/master' into ↵Teddy Wing
3479-refactor-table_builder-helper
2017-06-19TimeTables#show: Render header buttons from #action_linksTeddy Wing
This enables us to reuse these links in other parts of the application. Get the links from `TimeTableDecorator#action_links`. Refs #3479
2017-06-19Calendars#show: Use #action_links to render header buttonsTeddy Wing
To abstract the links and make them reusable in other contexts, render the buttons in the header from `CalendarDecorator#action_links`. Refs #3479
2017-06-19Lines#show: Render header links from #action_linksTeddy Wing
Get the header links from the decorator so we can reuse them instead of defining them directly in the template. Add an option to the `destroy_link_content` Rails helper method to allow us to specify alternate translation keys, giving us different text in the button label. Added this because the template in question uses a different label than the others (usually it's `actions.destroy`). Refs #3479
2017-06-19RoutingConstraintZones#show: Render header links from #action_linksTeddy Wing
Use the `RoutingConstraintZonesDecorator` to render the header links instead of constructing them in the view. This allows us to reuse the links. To be honest, I haven't actually tested this for real. Don't know how to set up an Interdiction de Traffic Local. Refs #3479
2017-06-19Routes#show: Use RouteDecorator#action_links to render header linksTeddy Wing
Instead of defining the header links in the view, get them from our decorator so we can reuse them. Need to wrap `@route` in the decorator in the controller and pass it the necessary context in order for it to be able to properly build links. Move `Chouette::RouteDecorator` to the top level app/decorators/ directory and remove it from the `Chouette` namespace. I had put it there to make it more similar to our model directory layout, but Draper isn't intelligent enough to look in subdirectories of `decorators` when using the `ActiveRecord::Base#decorate` method. Otherwise I suppose I could do `Chouette::RouteDecorator.decorate(@route)`, but that seemed not as clean since it doesn't take advantage of the default behaviour of Draper. Now going to have to do this for the other decorators. Refs #3479
2017-06-19Refs #3791@2h; fixes cas_extra_attributes= and redirects correctly; still ↵Robert
missing flash message