diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index 6275b15..e3980fd 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -125,6 +125,15 @@ else @original_org = @phase.template.org end + render('/templates/container', + locals: { + partial_path: 'admin_show', + phase: @phase, + template: @phase.template, + current: @current, + edit: @edit, + sections: @sections + }) end @@ -143,6 +152,11 @@ @phase.template = @template authorize @phase @phase.number = @template.phases.count + 1 + render('/templates/container', + locals: { + partial_path: 'admin_add', + template: @template + }) end @@ -157,11 +171,11 @@ @phase.template.dirty = true @phase.template.save! - redirect_to admin_show_phase_path(id: @phase.id, edit: 'true'), notice: success_message(_('phase'), _('created')) + redirect_to admin_show_phase_path(id: @phase.id), notice: success_message(_('phase'), _('created')) else flash[:alert] = failed_create_error(@phase, _('phase')) @template = @phase.template - render "admin_add" + redirect_to admin_template_template_path(id: @phase.template_id) end end @@ -191,7 +205,7 @@ else @original_org = @phase.template.org end - render 'admin_show' + redirect_to admin_show_phase_path(@phase) end end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 19faddc..54a8887 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -24,7 +24,7 @@ guidance = Annotation.new({question_id: @question.id, org_id: current_user.org_id, text: params[:guidance], type: Annotation.types[:guidance]}) guidance.save end - redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id, edit: 'true'), notice: success_message(_('question'), _('created')) + redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id), notice: success_message(_('question'), _('created')) else @edit = (@question.section.phase.template.org == current_user.org) @open = true @@ -40,7 +40,7 @@ else @original_org = @phase.template.org end - render template: 'phases/admin_show' + redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id) end rescue ActionController::ParameterMissing => e flash[:alert] = e.message @@ -83,7 +83,7 @@ @phase.template.dirty = true @phase.template.save! - redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, edit: 'true'), notice: success_message(_('question'), _('saved')) + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id), notice: success_message(_('question'), _('saved')) else @edit = (@phase.template.org == current_user.org) @open = true @@ -97,7 +97,7 @@ else @original_org = @phase.template.org end - render template: 'phases/admin_show' + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id) end end @@ -111,9 +111,9 @@ @phase.template.dirty = true @phase.template.save! - redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: success_message(_('question'), _('deleted')) + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id), notice: success_message(_('question'), _('deleted')) else - redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, edit: 'true'), alert: failed_destroy_error(@question, 'question') + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id), alert: failed_destroy_error(@question, 'question') end end diff --git a/app/controllers/sections_controller.rb b/app/controllers/sections_controller.rb index de81908..20b105e 100644 --- a/app/controllers/sections_controller.rb +++ b/app/controllers/sections_controller.rb @@ -14,7 +14,7 @@ @section.phase.template.save! redirect_to admin_show_phase_path(id: @section.phase_id, - :section_id => @section.id, edit: 'true'), notice: success_message(_('section'), _('created')) + :section_id => @section.id), notice: success_message(_('section'), _('created')) else @edit = (@phase.template.org == current_user.org) @open = true @@ -27,7 +27,7 @@ else @original_org = @phase.template.org end - render template: 'phases/admin_show' + redirect_to admin_show_phase_path(id: @phase.id) end end @@ -36,13 +36,13 @@ def admin_update @section = Section.includes(phase: :template).find(params[:id]) authorize @section - @section.description = params["section-desc-#{params[:id]}"] + @section.description = params["section-desc"] @phase = @section.phase if @section.update_attributes(params[:section]) @section.phase.template.dirty = true @section.phase.template.save! - redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id , edit: 'true'), notice: success_message(_('section'), _('saved')) + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id), notice: success_message(_('section'), _('saved')) else @edit = (@phase.template.org == current_user.org) @open = true @@ -55,7 +55,7 @@ else @original_org = @phase.template.org end - render template: 'phases/admin_show' + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id) end end @@ -70,7 +70,7 @@ @phase.template.dirty = true @phase.template.save! - redirect_to admin_show_phase_path(id: @phase.id, edit: 'true' ), notice: success_message(_('section'), _('deleted')) + redirect_to admin_show_phase_path(id: @phase.id), notice: success_message(_('section'), _('deleted')) else @edit = (@phase.template.org == current_user.org) @open = true diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 696a8de..2077949 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -230,7 +230,14 @@ end # once the correct template has been generated, we convert it to hash - @hash = @template.to_hash + @template_hash = @template.to_hash + render('container', + locals: { + partial_path: 'admin_template', + template: @template, + current: @current, + template_hash: @template_hash + }) end @@ -260,8 +267,7 @@ flash[:alert] = failed_update_error(@template, _('template')) end - @hash = @template.to_hash - render 'admin_template' + redirect_to action: 'admin_template', id: params[:id] end end diff --git a/app/views/layouts/_es5_scripts.html.erb b/app/views/layouts/_es5_scripts.html.erb index 6045c17..bf3d268 100644 --- a/app/views/layouts/_es5_scripts.html.erb +++ b/app/views/layouts/_es5_scripts.html.erb @@ -22,7 +22,7 @@ - <%= javascript_include_tag 'dmproadmap/accordions.js' %> + <%#= javascript_include_tag 'dmproadmap/accordions.js' %> <%= javascript_include_tag 'dmproadmap/admin.js' %> <%= javascript_include_tag 'dmproadmap/forms.js' %> <%= javascript_include_tag 'dmproadmap/utils.js' %> diff --git a/app/views/phases/_admin_add.html.erb b/app/views/phases/_admin_add.html.erb new file mode 100644 index 0000000..5d60ffd --- /dev/null +++ b/app/views/phases/_admin_add.html.erb @@ -0,0 +1,37 @@ +<%- model_class = Phase -%> +
<%= _('When you create a new phase for your template, a version will automatically be created. Once you complete the form below you will be provided with options to create sections and questions.') %>
+<%= form_for :phase, { url: admin_create_phase_path, html: { class: 'form-horizontal' }} do |f| %> + <%= f.hidden_field :template_id, value: @template.id%> +Here you set the title that users will see. If you intend to have multiple phases for you DMP, this should be clear in the title and description.
")%> -| <%= _('Title') %> | -<%= f.text_field :title, - as: :string, - class: 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => _('Enter a title for the phase e.g. intial DMP, full DMP... This is what users will see in the tabs when completing a plan. If you only have one phase, call it something generic e.g. Glasgow DMP') %> | -
| <%= _('Order of display') %> | -<%= f.number_field :number, in: 0..5, class: "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => _('This allows you to order the phases of your template.') %> | -
| <%= _('Description') %> | -
-
- <%= text_area_tag("phase-desc", phase.description, class: "tinymce") %>
-
-
-
- |
-
Here you set the title that users will see. If you intend to have multiple phases for you DMP, this should be clear in the title and description.
')%> -| <%= _('Title') %> | -<%= @phase.title %> | -
| <%= _('Order of display') %> | -<%= @phase.number %> | -
| <%= _('Description') %> | -<%= raw @phase.description %> | -
- <%= _('When you create a new phase for your template, a version will automatically be created. Once you complete the form below you will be provided with options to create sections and questions.') %>
- <%= form_for :phase, {url: admin_create_phase_path, html: {class: "roadmap-form"}} do |f| %> - <%= f.hidden_field :template_id, value: @template.id%> - - - <% end %> -| <%= _('Order of display') %> | -- <% range = @phase.template.customization_of.present? ? 0..15 : 1..15 %> - <%= f.number_field :number, in: range, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: _('This allows you to order sections.') %> - | -
| <%= _('Description') %> | -
-
- <%= text_area_tag("section-desc", "" , class: "tinymce") %>
-
-
- |
-