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 -%> +

<%= _('Phase details') %>

+

<%= _('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%> +
+ <%= f.label(:title, _('Title') ,class: 'col-md-2 control-label') %> +
+ <%= f.text_field(:title, class: 'col-md-10 form-control', 'aria-required': false) %> +
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Title'), placement: 'top', 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') } %> +
+
+
+ <%= f.label(:number, _('Order of display'), class: 'col-md-2 control-label') %> +
+ <%= f.number_field(:number, in: 1..5, class: 'form-control', 'aria-required': false) %> +
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Order of display'), placement: 'top', title: _('This allows you to order the phases of your template.') } %> +
+
+
+ <%= f.label(:description, _('Description'), class: 'col-md-2 control-label') %> +
+ <%= text_area_tag('phase-desc', '', class: 'tinymce') %> +
+
+ <%= render partial: '/shared/popover', locals: { aria_label: _('Description'), placement: 'top', title: _('More information: Phase descriptions'), content: _("Enter a basic description. This will be presented to users on the 'Admin Plan' tab, above the summary of the sections and questions which they will be asked to answer.") } %> +
+
+
+ <%= f.button(_('Save'), class: "btn btn-default", type: "submit") %> + <%= link_to(_('Cancel'), admin_template_template_path(@template), { class: "btn btn-default", role: "button" }) %> +
+<% end %> \ No newline at end of file diff --git a/app/views/phases/_admin_show.html.erb b/app/views/phases/_admin_show.html.erb new file mode 100644 index 0000000..8f800ec --- /dev/null +++ b/app/views/phases/_admin_show.html.erb @@ -0,0 +1,59 @@ +

<%= _('Phase details')%>

+
+
+ <% if phase.modifiable && edit %> + + <% end %> +
+
+
+
+
+ <%= render partial: "phases/show_phase", locals: { phase: phase, edit: edit } %> +
+
+
+ +
+
+
+ <% sections.order('number ASC').each do |section| %> +
+ +
" class="panel-collapse collapse" role="tabpanel" aria-labelledby="<%= "headingSection#{section.id}" %>"> +
+ <% if edit && section.modifiable %> + <%= render partial: 'sections/edit_section', locals: { section: section, edit: edit, phase: phase } %> + <% else %> + <%= render partial: 'sections/show_section', locals: { section: section } %> + <% end %> +
+
+
+ <% end %> +
+ <% if edit || template.customization_of.present? %> +
+
+
+ <%= link_to(_('Add Section'), '#', { class: "btn btn-default section_new_link", role: "button" }) %> +
+
+
+ +
+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/phases/_edit_phase.html.erb b/app/views/phases/_edit_phase.html.erb index 5c0673e..4b0c392 100644 --- a/app/views/phases/_edit_phase.html.erb +++ b/app/views/phases/_edit_phase.html.erb @@ -1,45 +1,33 @@ - - -<%= form_for(phase, url: admin_update_phase_path(phase.id), html: { method: :put}) do |f| %> - -
- <%= raw _("

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") %> -
- -
-
-
- - -
- <%= f.submit _('Save'), class: 'btn btn-primary', role: 'button' %> - <%= link_to _('Cancel'), admin_show_phase_path(phase), class: 'btn cancel', role: 'button' %> -
- +<%= form_for :phase, { url: admin_update_phase_path(phase.id), html: { method: :put, class: 'form-horizontal' }} do |f| %> +
+ <%= f.label(:title, _('Title') ,class: 'col-md-2 control-label') %> +
+ <%= f.text_field(:title, class: 'col-md-10 form-control', 'aria-required': false) %> +
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Title'), placement: 'top', 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') } %> +
+
+
+ <%= f.label(:number, _('Order of display'), class: 'col-md-2 control-label') %> +
+ <%= f.number_field(:number, in: 1..5, class: 'form-control', 'aria-required': false) %> +
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Order of display'), placement: 'top', title: _('This allows you to order the phases of your template.') } %> +
+
+
+ <%= f.label(:description, _('Description'), class: 'col-md-2 control-label') %> +
+ <%= text_area_tag('phase-desc', phase.description, class: 'tinymce') %> +
+
+ <%= render partial: '/shared/popover', locals: { aria_label: _('Description'), placement: 'top', title: _('More information: Phase descriptions'), content: _("Enter a basic description. This will be presented to users on the 'Admin Plan' tab, above the summary of the sections and questions which they will be asked to answer.") } %> +
+
+
+ <%= f.button(_('Save'), class: "btn btn-default", type: "submit") %> + <%= link_to _('Cancel'), '#', class: 'btn btn-default phase_show_link', role: 'button' %> +
<% end %> \ No newline at end of file diff --git a/app/views/phases/_show_phase.html b/app/views/phases/_show_phase.html deleted file mode 100644 index b6acb5c..0000000 --- a/app/views/phases/_show_phase.html +++ /dev/null @@ -1,27 +0,0 @@ - - - -<% if @phase.template.org.not_funder %> -
- <%= raw _('

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.

')%> -

-<% end %> - -
-
- - - - - - - - - - - - - - -
<%= _('Title') %><%= @phase.title %>
<%= _('Order of display') %><%= @phase.number %>
<%= _('Description') %><%= raw @phase.description %>
-
diff --git a/app/views/phases/_show_phase.html.erb b/app/views/phases/_show_phase.html.erb new file mode 100644 index 0000000..fc09972 --- /dev/null +++ b/app/views/phases/_show_phase.html.erb @@ -0,0 +1,15 @@ +
+
<%= _('Title') %>
+
<%= phase.title %>
+
<%= _('Order of display') %>
+
<%= phase.number %>
+
<%= _('Description') %>
+
<%= raw phase.description %>
+
+<% if phase.modifiable && edit %> +
+ <%= link_to(_('Edit phase details'), '#', { class: "btn btn-default phase_edit_link", role: "button" }) %> +
+<% end %> + + diff --git a/app/views/phases/admin_add.html.erb b/app/views/phases/admin_add.html.erb deleted file mode 100644 index d62164b..0000000 --- a/app/views/phases/admin_add.html.erb +++ /dev/null @@ -1,70 +0,0 @@ -<%- model_class = Phase -%> - -
-
-

<%= @template.title %>

-
-
- -
-
-
- - <%= render partial: "templates/admin_nav_tabs", locals: {template: @template, active: "add_plan"} %> - -
- -
- -
-

<%= _('Phase details')%>

- - -
-
- -

- <%= _('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%> - -
-
- <%= f.label :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') %> -
-
- <%= f.label _('Order of display'), for: :number %> - <%= f.number_field :number, in: 1..5, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: _('This allows you to order the phases of your template.') %> -
-
- <%= f.label :description %> - <%= text_area_tag("phase-desc","" , class: "tinymce") %> - -
- -
-
-
 
- <%= f.submit _('Save'), class: "btn btn-primary" %> - <%= link_to _('Cancel'), admin_template_template_path(@template), class: "btn cancel" %> -
-
- <% end %> -
-
- -
-
- -
-
-
-
\ No newline at end of file diff --git a/app/views/phases/admin_show.html.erb b/app/views/phases/admin_show.html.erb deleted file mode 100644 index 5b92583..0000000 --- a/app/views/phases/admin_show.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -
-
-

<%= @phase.template.title %>

-
-
- -
-
-
- - <%= render partial: "templates/admin_nav_tabs", locals: {template: @phase.template, active: @phase.id, edit: @edit, current: @current} %> - -
- -
- -
-

<%= _('Phase details')%>

- - -
-
- - -
- <%= render partial: "phases/show_phase", locals: {phase: @phase}%> -
- <% if @phase.modifiable && @edit %> - - <% end %> -
-
- - - <% @sections.order("number ASC").each do |section| %> -

<%= section.title %>

-
- <% if @edit && section.modifiable %> - <%= render partial: 'sections/edit_section', locals: {section: section, edit: @edit, phase: @phase} %> - <% else %> - <%= render partial: 'sections/show_section', locals: {section: section}%> - <% end %> -
- <% end %> - - <% if @edit || @phase.template.customization_of.present? %> -

<%= _('Add section') %>

- - - <% end %> -
-
-
-
-
-
diff --git a/app/views/questions/_add_question.html.erb b/app/views/questions/_add_question.html.erb index 6903424..b4cb2e3 100644 --- a/app/views/questions/_add_question.html.erb +++ b/app/views/questions/_add_question.html.erb @@ -171,9 +171,9 @@
<%= hidden_field_tag :section_id, section.id, class: "section_id" %> - <%= f.submit _('Save'), class: "btn btn-primary new_question_save_button", role:'button' %> + <%= f.submit _('Save'), class: "btn btn-default", role:'button' %> <%= hidden_field_tag :section_id, section.id, class: "section_id_new" %> - <%= link_to _('Cancel'), '#', class: "btn cancel cancel_add_new_question", role: 'button' %> + <%= link_to _('Cancel'), '#', class: "btn btn-default new_question_cancel", role: 'button' %>
diff --git a/app/views/sections/_add_section.html.erb b/app/views/sections/_add_section.html.erb index 36f17fa..ebed50f 100644 --- a/app/views/sections/_add_section.html.erb +++ b/app/views/sections/_add_section.html.erb @@ -1,57 +1,40 @@ - -<% @new_section = Section.new %> -<% @new_section.number = phase.sections.count + 1 %> - - -<%= form_for @new_section, url: admin_create_section_path do |f| %> +<% new_section = Section.new %> +<% new_section.number = phase.sections.count + 1 %> +<%= form_for new_section, { url: admin_create_section_path, html: { class: 'form-horizontal' }} do |f| %> <%= f.hidden_field :phase_id, value: phase.id %> - -
-
-
-
- - <%= f.text_field :title, as: :string, class: "text_field", placeholder: _('New section title')%> +
+
+

+
+ <%= f.text_field(:title, { class: 'form-control', 'aria-required': false, placeholder: _('Enter a title for the section') } ) %>
- - -

- +
+
-
-
- - - - - - - - - -
<%= _('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") %> -
- -
- -
- <%= f.submit _('Save'), class: "btn btn-primary", role:"button" %> - <%= link_to _('Cancel'), "#", id: "", class: "btn cancel", role:"button" %> +
+
+ <%= f.label(:number, _('Order of display'), class: 'col-md-2 control-label') %> +
+ <%= f.number_field(:number, in: 1..15, class: 'form-control', 'aria-required': false) %>
-
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Order of display'), placement: 'top', title: _('This allows you to order sections.') } %> +
+
+
+ <%= f.label(:description, _('Description'), class: 'col-md-2 control-label') %> +
+ <%= text_area_tag('section-desc', '', class: 'tinymce') %> +
+
+ <%= render partial: '/shared/popover', locals: { aria_label: _('Description'), placement: 'top', title: _('More information: Section descriptions'), content: _("Enter a basic description. This could be a summary of what is covered in the section or instructions on how to answer. This text will be displayed in the coloured banner once a section is opened to edit.") } %> +
+
+
+ <%= f.button(_('Save'), class: "btn btn-default", type: "submit") %> + <%= link_to(_('Cancel'), '#', { class: "btn btn-default section_new_cancel", role: "button" }) %>
-<% end %> - - +<% end %> \ No newline at end of file diff --git a/app/views/sections/_edit_section.html.erb b/app/views/sections/_edit_section.html.erb index 0856f6f..38d02f6 100644 --- a/app/views/sections/_edit_section.html.erb +++ b/app/views/sections/_edit_section.html.erb @@ -1,75 +1,73 @@ - - -

<%= _('Section details') %>

-
- <%= form_for(section, url: admin_update_section_path(section, phase: phase, edit: edit), html: { method: :put, class: 'roadmap-form bordered'}) do |s| %> -
-
- <%= s.label :title %> - <%= s.text_field :title, as: :string, class: 'input-large', placeholder: _('New section title') %> -
-
- <%= s.label _('Order of display'), for: :number %> - <%= s.number_field :number, in: 1..15, class: "input-small has-tooltip", 'data-toggle' => "tooltip", 'title' => _('This allows you to order sections.') %> -
- <%= s.label :description %> - <%= text_area_tag("section-desc-#{section.id}", section.description , class: "tinymce") %> -
- " aria-label="<%= _('More information: Section descriptions') %>"> - +
+
+

<%= _('Section details') %>

+
+
+
+
+ <%= form_for(section, url: admin_update_section_path(section, phase: phase), html: { method: :put, class: 'form-horizontal'}) do |f| %> +
+ <%= f.label(:title, _('Title'), { class: 'col-md-2 control-label' }) %> +
+ <%= f.text_field(:title, { class: 'form-control', 'aria-required': false, placeholder: _('Enter a title for the section') } ) %> +
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Title'), placement: 'top', title: _('Enter a title for the section') } %>
- -
-
-
 
- <%= s.submit _('Save'), class: 'btn btn-primary', role:'button' %> - <% if section.modifiable %> - <%= link_to _('Delete'), admin_destroy_section_path(section_id: section.id), - confirm: _("You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?") % { :section_title => section.title }, method: :delete, class: "btn btn-primary", role:'button'%> - <% end %> - <%= link_to _('Cancel'), :back, class: 'btn cancel', role:'button' %> +
+ <%= f.label(:number, _('Order of display'), class: 'col-md-2 control-label') %> +
+ <%= f.number_field(:number, in: 1..15, class: 'form-control', 'aria-required': false) %> +
+
+ <%= render partial: '/shared/tooltip', locals: { aria_label: _('Order of display'), placement: 'top', title: _('This allows you to order sections.') } %> +
-
- <% end %> +
+ <%= f.label(:description, _('Description'), class: 'col-md-2 control-label') %> +
+ <%= text_area_tag('section-desc', section.description, class: 'tinymce') %> +
+
+ <%= render partial: '/shared/popover', locals: { aria_label: _('Description'), placement: 'top', title: _('More information: Section descriptions'), content: _("Enter a basic description. This could be a summary of what is covered in the section or instructions on how to answer. This text will be displayed in the coloured banner once a section is opened to edit.") } %> +
+
+
+ <%= f.button(_('Save'), class: "btn btn-default", type: "submit") %> + <%= link_to _('Delete'), admin_destroy_section_path(section_id: section.id), + confirm: _("You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?") % { :section_title => section.title }, method: :delete, class: "btn btn-default", role:'button' %> +
+ <% end %> +
- -

<%= _('Questions') %>

-<% @questions = section.questions.order("number")%> -<% if @questions.length > 0 %> - <% @questions.each do |question| %> -
-
"> - - <%= render partial: 'questions/show_question', locals: {question: question} %> -
- - -
- <% end %> -<% end %> - - -<% if section.modifiable %> - -