diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index 17215e8..18e58f6 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -90,34 +90,14 @@ end end - - #show and edit a phase of the template def admin_show - @phase = Phase.eager_load(:sections).find_by('phases.id = ?', params[:id]) + @phase = Phase.includes(:sections).order(:number).find(params[:id]) authorize @phase @current = Template.current(@phase.template.dmptemplate_id) @edit = (@phase.template.org == current_user.org) && (@phase.template == @current) - #@edit = params[:edit] == "true" ? true : false - #verify if there are any sections if not create one - @sections = @phase.sections - if !@sections.any?() || @sections.count == 0 - @section = @phase.sections.build - @section.phase = @phase - @section.title = '' - @section.number = 1 - @section.published = true - @section.modifiable = true - @section.save - @new_sec = true - end - #verify if section_id has been passed, if so then open that section - if params.has_key?(:section_id) - @open = true - @section_id = params[:section_id].to_i - end if params.has_key?(:question_id) @question_id = params[:question_id].to_i end @@ -131,9 +111,8 @@ partial_path: 'admin_show', phase: @phase, template: @phase.template, - current: @current, edit: @edit, - sections: @sections + current_section: params.has_key?(:section_id) ? params[:section_id].to_i : nil }) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c8ca84..ee6590a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,7 +23,7 @@ # see http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-fullpath for details # --------------------------------------------------------------------------- def isActivePage(path) - return request.fullpath() == path + return request.fullpath.include?(path) end def fingerprinted_asset(name) diff --git a/app/views/phases/_admin_show.html.erb b/app/views/phases/_admin_show.html.erb index 8f800ec..da337a5 100644 --- a/app/views/phases/_admin_show.html.erb +++ b/app/views/phases/_admin_show.html.erb @@ -1,3 +1,4 @@ +<% # locals: { phase, template, edit, current_section } %>