diff options
| author | Luc Donnet | 2017-09-05 16:16:19 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-09-05 16:16:19 +0200 |
| commit | 86ec0eb16ec8e0586d1de850942a09cfc65a88f8 (patch) | |
| tree | 639d31db0678b6688feabaf2f70807d0c7a506cb /app | |
| parent | 505a05e07dd418f4da1502790d87b71925f1f5f6 (diff) | |
| parent | b78fff38f57f532e33c418e2bac0ff5948d4f7b4 (diff) | |
| download | chouette-core-86ec0eb16ec8e0586d1de850942a09cfc65a88f8.tar.bz2 | |
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/application_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/autocomplete_time_tables_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 9 | ||||
| -rw-r--r-- | app/decorators/referential_decorator.rb | 2 | ||||
| -rw-r--r-- | app/views/workbenches/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 2 |
7 files changed, 14 insertions, 9 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 47b54039c..cc1c30703 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -34,7 +34,8 @@ class ApplicationController < ActionController::Base helper_method :current_organisation def current_functional_scope - JSON.parse(current_organisation.sso_attributes["functional_scope"]) if current_organisation + functional_scope = current_organisation.sso_attributes.try(:[], "functional_scope") if current_organisation + JSON.parse(functional_scope) if functional_scope end helper_method :current_functional_scope diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb index 375928aeb..d0cd94e26 100644 --- a/app/controllers/autocomplete_time_tables_controller.rb +++ b/app/controllers/autocomplete_time_tables_controller.rb @@ -9,7 +9,7 @@ class AutocompleteTimeTablesController < InheritedResources::Base end def referential - @referential ||= current_organisation.referentials.find params[:referential_id] + @referential ||= Referential.find params[:referential_id] end protected diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index a6dfaf2b6..bd0544a74 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -10,7 +10,6 @@ class ReferentialsController < BreadcrumbController if params[:from] source_referential = Referential.find(params[:from]) @referential = Referential.new_from(source_referential, current_functional_scope) - @referential.workbench_id = current_organisation.workbenches.first.id end new! do @@ -26,7 +25,7 @@ class ReferentialsController < BreadcrumbController def show resource.switch show! do |format| - @referential = @referential.decorate + @referential = @referential.decorate(context: { workbench_id: params[:workbench_id] } ) @reflines = lines_collection.paginate(page: params[:page], per_page: 10) @reflines = ModelDecorator.decorate( @reflines, diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 19af28a98..bae3fcff2 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -20,8 +20,13 @@ class WorkbenchesController < BreadcrumbController @q_for_form = scope.ransack(params[:q]) @q_for_result = scope.ransack(ransack_params) @wbench_refs = sort_result(@q_for_result.result).paginate(page: params[:page], per_page: 30) - @wbench_refs = ModelDecorator.decorate(@wbench_refs, with: ReferentialDecorator) - + @wbench_refs = ModelDecorator.decorate( + @wbench_refs, + with: ReferentialDecorator, + context: { + workbench_id: params[:id] + } + ) show! do build_breadcrumb :show end diff --git a/app/decorators/referential_decorator.rb b/app/decorators/referential_decorator.rb index ccb47a654..4e9c242fd 100644 --- a/app/decorators/referential_decorator.rb +++ b/app/decorators/referential_decorator.rb @@ -13,7 +13,7 @@ class ReferentialDecorator < Draper::Decorator if policy.clone? links << Link.new( content: h.t('actions.clone'), - href: h.new_referential_path(from: object.id) + href: h.new_referential_path(from: object.id, workbench_id: context[:workbench_id]) ) end if policy.archive? diff --git a/app/views/workbenches/index.html.slim b/app/views/workbenches/index.html.slim index d57f579ff..eece51bca 100644 --- a/app/views/workbenches/index.html.slim +++ b/app/views/workbenches/index.html.slim @@ -41,7 +41,7 @@ - if @referentials.any? .list-group - @referentials.each_with_index do |referential, i| - = link_to referential.name, referential_path(referential), class: 'list-group-item' if i < 6 + = link_to referential.name, referential_path(referential, workbench_id: referential.workbench_id), class: 'list-group-item' if i < 6 - else .panel-body diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index bb54f07cb..80451ec34 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -29,7 +29,7 @@ key: :name, \ attribute: 'name', \ link_to: lambda do |referential| \ - referential_path(referential) \ + referential_path(referential, workbench_id: referential.workbench_id) \ end \ ), \ TableBuilderHelper::Column.new( \ |
