diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 385493e..ad698f1 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -54,6 +54,12 @@ @template = Template.new(params[:template]) @template.org_id = current_user.org_id @template.description = params['template-desc'] + @template.published = false + @template.version = 0 + @template.dmptemplate_id = loop do + random = rand 2147483647 + break random unless Template.exists?(dmptemplate_id: random) + end authorize @template if @template.save redirect_to admin_template_template_path(@template), notice: I18n.t('org_admin.templates.created_message') @@ -82,7 +88,7 @@ @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 then + if !@sections.any?() || @sections.count == 0 @section = @phase.sections.build @section.phase = @phase @section.title = '' @@ -93,11 +99,11 @@ @new_sec = true end #verify if section_id has been passed, if so then open that section - if params.has_key?(:section_id) then + if params.has_key?(:section_id) @open = true @section_id = params[:section_id].to_i end - if params.has_key?(:question_id) then + if params.has_key?(:question_id) @question_id = params[:question_id].to_i end end @@ -105,8 +111,9 @@ #preview a phase def admin_previewphase - @template = Template.find(params[:id]) - authorize @template + @phase = Phase.find(params[:id]) + authorize @phase.template + @template = @phase.template end diff --git a/app/models/question.rb b/app/models/question.rb index 7a91897..cd15316 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -28,7 +28,6 @@ :modifiable, :option_comment_display, :as => [:default, :admin] - # EVALUATE CLASS AND INSTANCE METHODS BELOW # # What do they do? do they do it efficiently, and do we need them? @@ -101,11 +100,12 @@ # pulls together guidance from various sources for question guidances = {} theme_ids = question.theme_ids - - GuidanceGroup.where(org_id: org.id).each do |group| - group.guidances.each do |g| - g.themes.where("id IN (?)", theme_ids).each do |gg| - guidances["#{group.name} " + I18n.t('admin.guidance_lowercase_on') + " #{gg.title}"] = g + if theme_ids.present? + GuidanceGroup.where(org_id: org.id).each do |group| + group.guidances.each do |g| + g.themes.where("id IN (?)", theme_ids).each do |gg| + guidances["#{group.name} " + I18n.t('admin.guidance_lowercase_on') + " #{gg.title}"] = g + end end end end diff --git a/app/views/templates/_add_guidance.html.erb b/app/views/templates/_add_guidance.html.erb index de49775..af080d0 100644 --- a/app/views/templates/_add_guidance.html.erb +++ b/app/views/templates/_add_guidance.html.erb @@ -1,93 +1,93 @@
- <%= form_for :guidance, :url => {:action => "admin_create"}, :html => {:id => "new_guidance_form"} do |f| %> - - - - - - - - + + + + + + + + + +
<%= t("org_admin.guidance.text_label") %>
- <%= text_area_tag("guidance-text", "", class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_text_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.text_help_text_html"))%> -
-
-
<%= t("org_admin.guidance.by_theme_or_by_question") %>
- <%= select_tag "g_options", options_for_select([[t("org_admin.guidance.by_themes_label"), 1], - [t("org_admin.guidance.by_question_label"), 2]]) %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_apply_to_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.apply_to_help_text_html"))%> -
-
+ <%= form_for :guidance, url: {action: "admin_create"}, html: {id: "new_guidance_form"} do |f| %> + + + + + + + + - - - - - - - - - -
<%= t("org_admin.guidance.text_label") %> +
+ <%= text_area_tag("guidance-text", "", class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "guidance_text_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.text_help_text_html"))%> +
+
+
<%= t("org_admin.guidance.by_theme_or_by_question") %> +
+ <%= select_tag "g_options", options_for_select([[t("org_admin.guidance.by_themes_label"), 1], + [t("org_admin.guidance.by_question_label"), 2]]) %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "guidance_apply_to_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.apply_to_help_text_html"))%> +
+
- -
<%= t("org_admin.guidance.published") %>
- <%= f.check_box :published , :as => :check_boxes%> -
-
- -
-
<%= t("org_admin.guidance.guidance_group_label") %>
- <%= f.collection_select(:guidance_group_ids, - GuidanceGroup.where("organisation_id = ?", current_user.organisation_id).order("name ASC"), - :id, :name, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => false})%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_group_select_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.guidance_group_select_help_text_html"))%> -
-
- -
- - - -
- <%= t("helpers.submit.save")%> - - <%= link_to t("helpers.submit.cancel"), :back, :class => "btn cancel" %> + +
<%= t("org_admin.guidance.published") %> +
+ <%= f.check_box :published , as: :check_boxes %> +
+
<%= t("org_admin.guidance.guidance_group_label") %> +
+ <%= f.collection_select(:guidance_group_ids, + GuidanceGroup.where(org_id: current_user.org_id).order("name ASC"), + :id, :name, {prompt: false, include_blank: t('helpers.none')}, {multiple: false})%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "guidance_group_select_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.guidance_group_select_help_text_html"))%> +
+
+
+ + + +
+ <%= t("helpers.submit.save")%> + + <%= link_to t("helpers.submit.cancel"), :back, class: "btn cancel" %>
+
+ <%= tinymce content_css: asset_path("application.css") %> + <% end %> +
+ -<%end%> +<% end %> diff --git a/app/views/templates/_admin_nav_tabs.html.erb b/app/views/templates/_admin_nav_tabs.html.erb index a4b8ad8..0134df6 100644 --- a/app/views/templates/_admin_nav_tabs.html.erb +++ b/app/views/templates/_admin_nav_tabs.html.erb @@ -1,7 +1,7 @@ -<%end%> +<% end %> diff --git a/app/views/templates/_edit_template.html.erb b/app/views/templates/_edit_template.html.erb index 10c33ea..3dc7154 100644 --- a/app/views/templates/_edit_template.html.erb +++ b/app/views/templates/_edit_template.html.erb @@ -20,11 +20,11 @@ <%= t('org_admin.templates.published_label') %> - <%if template.published? then%> - <%= f.check_box :published, as: :check_boxes %> - <%else%> + <% if template.published? %> + <%= f.check_box :published, as: :check_boxes %> + <% else %> <%= t('org_admin.templates.cannot_publish')%> - <%end%> + <% end %> @@ -49,4 +49,4 @@
-<%end%> \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/app/views/templates/_edit_version.html.erb b/app/views/templates/_edit_version.html.erb deleted file mode 100644 index 416fdb7..0000000 --- a/app/views/templates/_edit_version.html.erb +++ /dev/null @@ -1,47 +0,0 @@ - - - -<%= form_for(version, :url => admin_updateversion_dmptemplate_path(version, :edit => edit, :phase => phase), :html => { :method => :put}) do |f| %> - -

- <%= t('org_admin.templates.version_details_label')%> -

-
- -
- - - - - - - - - - - - - - - -
<%= t('org_admin.templates.title_label') %><%= f.text_field :title, :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %>
<%= t('org_admin.templates.desc_label') %>
- <%= text_area_tag("version-desc", version.description, class: "tinymce") %> -
-
- <%= link_to( image_tag('help_button.png'), '#', :class => 'version_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.versions.desc_help_text_html'))%> -
-
<%= t('org_admin.templates.published_label') %><%= f.check_box :published, :as => :check_boxes %>
- -
- -
- <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <%= link_to t('helpers.submit.cancel'), admin_phase_dmptemplate_path(phase), :class => 'btn cancel' %> -
-
- -<%end%> - - - \ No newline at end of file diff --git a/app/views/templates/_guidance_display.html.erb b/app/views/templates/_guidance_display.html.erb index d0276d9..d43793a 100644 --- a/app/views/templates/_guidance_display.html.erb +++ b/app/views/templates/_guidance_display.html.erb @@ -2,7 +2,7 @@
- <% if !question.guidance.nil? && question.guidance != "" then %> + <% if !question.guidance.nil? && question.guidance != "" %>
diff --git a/app/views/templates/_option_fields.html.erb b/app/views/templates/_option_fields.html.erb index 21f3e80..5182510 100644 --- a/app/views/templates/_option_fields.html.erb +++ b/app/views/templates/_option_fields.html.erb @@ -1,7 +1,7 @@ - <%= f.number_field :number,:in => 1..20, :class => "number_field option"%> - <%= f.text_field :text, :as => :string, :class => "small_text_field" %> - <%= f.check_box :is_default %> - <%= f.hidden_field :_destroy %><%= t('org_admin.remove_option_label') %> + <%= f.number_field :number, in: 1..20, class: "number_field option"%> + <%= f.text_field :text, as: :string, class: "small_text_field" %> + <%= f.check_box :is_default %> + <%= f.hidden_field :_destroy %><%= t('org_admin.remove_option_label') %> diff --git a/app/views/templates/_preview_question.html.erb b/app/views/templates/_preview_question.html.erb index fa75e30..37d3fb1 100644 --- a/app/views/templates/_preview_question.html.erb +++ b/app/views/templates/_preview_question.html.erb @@ -1,124 +1,124 @@
- - - <% q_format = question.question_format%> -
-
- - <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") then%> - <% options = question.options.order("number") %> - - - <% if q_format.title == t("helpers.checkbox") then %> - <%if !options.nil? then %> -
- -
    - <% options.each do |op|%> -
  1. - <%end%> -
-
- <%end%> - - <% elsif q_format.title == t("helpers.multi_select_box") then %> - <%if !options.nil? then %> - - - <%end%> - - <% elsif q_format.title == t("helpers.radio_buttons") then%> - <%if !options.nil? then %> -
- -
    - <% options.each do |op|%> -
  1. - <%end%> -
-
- <%end%> - - <% elsif q_format.title == t("helpers.dropdown") then%> - <%if !options.nil? then %> - - - <%end%> - <% end %> - - - <% suggested_answer = question.suggested_answers.find_by_organisation_id(current_user.organisation_id) %> - <% if !suggested_answer.nil? && suggested_answer.text != "" then %> -
- - <% if suggested_answer.is_example? then %> - <%= t("org_admin.questions.example_answer_label")%> - <%else%> - <%= t("org_admin.questions.suggested_answer_label")%> - <%end%> - -
-

- <%= raw suggested_answer.text %> -

-
-
- <% end %> - -
- - <% else %> - - - <% suggested_answer = question.suggested_answers.find_by_organisation_id(current_user.organisation_id) %> - <% if !suggested_answer.nil? && suggested_answer.text != "" then %> -
- - <% if suggested_answer.is_example? then %> - <%= t("org_admin.questions.example_answer_label")%> - <%else%> - <%= t("org_admin.questions.suggested_answer_label")%> - <%end%> - -
-

- <%= raw suggested_answer.text %> -

-
-
- <% end %> - - <% end %> - - - - - <% if q_format.title == t("helpers.text_field") then %> - - - <%elsif q_format.title == t("helpers.text_area") then%> - - <%end%> -
- - <%= link_to t("helpers.save"), "#", :class => "btn btn-primary", :onclick => "event.preventDefault();" %> - - <%= t("helpers.notanswered") %> - -
-
-
- + + <% q_format = question.question_format%> +
+
+ + <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") %> + <% options = question.question_options.order("number") %> + + + <% if q_format.title == t("helpers.checkbox") %> + <%if !options.nil? %> +
+ +
    + <% options.each do |op|%> +
  1. + <% end %> +
+
+ <% end %> + + <% elsif q_format.title == t("helpers.multi_select_box") %> + <% if !options.nil? %> + + + <% end %> + + <% elsif q_format.title == t("helpers.radio_buttons") %> + <% if !options.nil? %> +
+ +
    + <% options.each do |op|%> +
  1. + <% end %> +
+
+ <% end %> + + <% elsif q_format.title == t("helpers.dropdown") %> + <% if !options.nil? %> + + + <% end %> + <% end %> + + + <% suggested_answer = question.suggested_answers.find_by(org_id: current_user.org_id) %> + <% if !suggested_answer.blank? %> +
+ + <% if suggested_answer.is_example? %> + <%= t("org_admin.questions.example_answer_label")%> + <% else %> + <%= t("org_admin.questions.suggested_answer_label")%> + <% end %> + +
+

+ <%= raw suggested_answer.text %> +

+
+
+ <% end %> + +
+ + <% else %> + + + <% suggested_answer = question.suggested_answers.find_by(org_id: current_user.org_id) %> + <% if !suggested_answer.blank? %> +
+ + <% if suggested_answer.is_example? %> + <%= t("org_admin.questions.example_answer_label")%> + <% else %> + <%= t("org_admin.questions.suggested_answer_label")%> + <% end %> + +
+

+ <%= raw suggested_answer.text %> +

+
+
+ <% end %> + + <% end %> + + + + + <% if q_format.title == t("helpers.text_field") %> + + + <%elsif q_format.title == t("helpers.text_area") %> + + <%end%> +
+ + <%= link_to t("helpers.save"), "#", class: "btn btn-primary", onclick: "event.preventDefault();" %> + + <%= t("helpers.notanswered") %> + +
+
+
+ + -<%= render :partial => "guidance_display", locals: {question: question}%> +<%= render partial: "guidance_display", locals: {question: question}%> diff --git a/app/views/templates/_show_phase.html.erb b/app/views/templates/_show_phase.html.erb index c00c71e..f110902 100644 --- a/app/views/templates/_show_phase.html.erb +++ b/app/views/templates/_show_phase.html.erb @@ -1,37 +1,37 @@

- <%= t('org_admin.templates.phase_details_label')%> + <%= t('org_admin.templates.phase_details_label')%> - - <% if @phase.modifiable %> -
- <%= link_to t("org_admin.templates.edit_phase_details_label"), '#', class: "btn btn-primary", id: "edit_phase_button"%> -
- <% end %> + + <% if @phase.modifiable %> +
+ <%= link_to t("org_admin.templates.edit_phase_details_label"), '#', class: "btn btn-primary", id: "edit_phase_button"%> +
+ <% end %>

<% if @phase.template.org.not_funder %> -
- <%= raw t('org_admin.templates.phase_details_text_html')%> -
+
+ <%= raw t('org_admin.templates.phase_details_text_html')%> +
<% end %>
- - - - - - - - - - - - + + + + + + + + + + + +
<%= t('org_admin.templates.title_label') %><%= @phase.title %>
<%= t('org_admin.templates.phase_order_label') %><%= @phase.number %>
<%= t('org_admin.templates.desc_label') %><%= raw @phase.description %>
<%= t('org_admin.templates.title_label') %><%= @phase.title %>
<%= t('org_admin.templates.phase_order_label') %><%= @phase.number %>
<%= t('org_admin.templates.desc_label') %><%= raw @phase.description %>
diff --git a/app/views/templates/_show_phases_sections.html.erb b/app/views/templates/_show_phases_sections.html.erb index 2ef08fd..63f5a08 100644 --- a/app/views/templates/_show_phases_sections.html.erb +++ b/app/views/templates/_show_phases_sections.html.erb @@ -11,22 +11,22 @@
- <% if phase.sections.length > 0 then %> + <% if phase.sections.length > 0 %> <%= link_to t("helpers.preview"), admin_previewphase_template_path(phase), class: 'btn btn-primary'%> <% end %> - <% if !phase.template.published? then%> - <%= link_to t("helpers.submit.delete"), admin_destroyphase_template_path(:phase_id => phase.id), + <% if !phase.template.published? %> + <%= link_to t("helpers.submit.delete"), admin_destroyphase_template_path(phase_id: phase.id), confirm: t("org_admin.templates.phase_delete_message", phase_title: phase.title ), method: :delete, class: "btn btn-primary"%> <% end %> - <% if phase.template.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder") then%> + <% if !phase.modifiable %> <% b_label = t('org_admin.templates.view_phase_label')%> <% else %> <% b_label = t('org_admin.templates.edit_phase_label')%> <% end %> - <%= link_to b_label, admin_phase_template_path(phase), class: "btn btn-primary" %> + <%= link_to b_label, admin_phase_template_path(id: phase.id, edit: (b_label == t('org_admin.templates.edit_phase_label'))), class: "btn btn-primary" %>
- <% if phase.sections.any? then %> + <% if phase.sections.any? %> diff --git a/app/views/templates/_show_question.html.erb b/app/views/templates/_show_question.html.erb index 6ac50fc..122c44f 100644 --- a/app/views/templates/_show_question.html.erb +++ b/app/views/templates/_show_question.html.erb @@ -51,7 +51,7 @@ @@ -14,6 +14,6 @@
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("org_admin.questions.edit_suggested_answer_button"), '# ', :class => "btn btn-primary edit_form_for_suggested_answer"%> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to t("org_admin.questions.edit_suggested_answer_button"), '# ', class: "btn btn-primary edit_form_for_suggested_answer"%>
diff --git a/app/views/templates/_show_version.html.erb b/app/views/templates/_show_version.html.erb deleted file mode 100644 index 3e1456e..0000000 --- a/app/views/templates/_show_version.html.erb +++ /dev/null @@ -1,42 +0,0 @@ - - - -

- <%= t('org_admin.templates.version_details_label')%> -

-
- -
<%= q_format.title %>
<% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") %> - <% if question.question_option_comment_display == true %> + <% if question.option_comment_display == true %> <%= t("org_admin.questions.option_comment_display")%> <% else %> <%= t("org_admin.questions.option_comment_hide")%> @@ -107,40 +107,35 @@ <% suggested_answer = question.get_suggested_answer(current_user.org_id) %> <% if !suggested_answer.nil? && suggested_answer.text != "" %>
- <%= render :partial => 'show_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %> + <%= render partial: 'show_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %>
- <% end %> - - - - <% end %>
- <% if (@edit == 'true' && question.modifiable) %> + <% if (@edit && question.modifiable) %>
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("org_admin.questions.question_edit_button"), '# ', :class => "btn btn-primary edit_question_button"%> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to t("org_admin.questions.question_edit_button"), '# ', class: "btn btn-primary edit_question_button"%> <% if !question.section.published? %> - <%= link_to t("org_admin.questions.question_delete_button"), admin_destroyquestion_template_path(:question_id => question.id), - :confirm => t("org_admin.questions.delete_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> + <%= link_to t("org_admin.questions.question_delete_button"), admin_destroyquestion_template_path(question_id: question.id), + confirm: t("org_admin.questions.delete_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> <% end %>
- <% elsif @edit == 'false' && question.modifiable %> + <% elsif !@edit && question.modifiable %> <% suggested_answer = question.get_suggested_answer(current_user.org_id) %> <% if suggested_answer.nil? %>
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("org_admin.questions.suggested_or_example_answer_button"), '# ', :class => "btn btn-primary add_suggested_answer_button"%> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to t("org_admin.questions.suggested_or_example_answer_button"), '# ', class: "btn btn-primary add_suggested_answer_button"%>
<% end %> @@ -150,4 +145,4 @@ -<%= render :partial => 'guidance_display', locals: {question: question}%> +<%= render partial: 'guidance_display', locals: {question: question}%> diff --git a/app/views/templates/_show_section.html.erb b/app/views/templates/_show_section.html.erb index 1dbf719..128728e 100644 --- a/app/views/templates/_show_section.html.erb +++ b/app/views/templates/_show_section.html.erb @@ -1,43 +1,41 @@ -<%if @open && @section_id == section.id then%> - <% toggle = 'accordion-body section-collapse in collapse'%> -<%else%> - <% toggle = 'accordion-body collapse section-collapse' %> -<%end%> +<% if @open && @section_id == section.id %> + <% toggle = 'accordion-body section-collapse in collapse'%> +<% else %> + <% toggle = 'accordion-body collapse section-collapse' %> +<% end %>
-
- -
- <% if section.title == '' then%> - <%= t('org_admin.templates.new_section')%> - <%else%> - <%= section.title %> - <%end%> -
- - -
+ -
-
- <%= raw section.description %> -
-
- <% section.questions.order("number").each do |question| %> - <% last_question_id = section.questions.order("number DESC").first.id %> - -
- - <%= render :partial => 'show_question', locals: {question: question}%> -
+
+
+ <%= raw section.description %> +
+
+ <% last_question_id = section.questions.order("number DESC").first.id %> + <% section.questions.order("number").each do |question| %> +
+ + <%= render partial: 'show_question', locals: {question: question}%> +
- <% if last_question_id == question.id then %> -
- <% else %> -
- <% end %> - - <%end%> -
-
+ <% if last_question_id == question.id %> +
+ <% else %> +
+ <% end %> + <% end %> +
+
diff --git a/app/views/templates/_show_suggested_answer.html.erb b/app/views/templates/_show_suggested_answer.html.erb index 888dd45..c760bc9 100644 --- a/app/views/templates/_show_suggested_answer.html.erb +++ b/app/views/templates/_show_suggested_answer.html.erb @@ -4,9 +4,9 @@
<% if suggested_answer.is_example? then %> <%= t('org_admin.questions.example_answer_label')%> - <%else%> + <% else %> <%= t('org_admin.questions.suggested_answer_label')%> - <%end%> + <% end %> <%= raw suggested_answer.text %>
- - - - - <% if version.description != "" then%> - - - - - <%end%> - - - - - - - - - - - - -
<%= t('org_admin.templates.title_label') %><%= version.title %>
<%= t('org_admin.templates.desc_label') %><%= raw version.description %>
<%= t('org_admin.templates.published_label') %><%= version.published %>
<%= t('org_admin.templates.created') %> - <%= l version.created_at.to_date, :formats => :short %> -
<%= t('org_admin.templates.last_updated') %> - <%= l version.updated_at.to_date, :formats => :short %> -
-
- - - - - diff --git a/app/views/templates/_versions_table.html.erb b/app/views/templates/_versions_table.html.erb deleted file mode 100644 index e51dbfe..0000000 --- a/app/views/templates/_versions_table.html.erb +++ /dev/null @@ -1,73 +0,0 @@ -<%if !phase.versions.nil? then %> -
-

<%= t('org_admin.templates.versions_label')%>

-

- <%= t('org_admin.versions.versions_text_html')%> -

- - - - - - - - - - - - - - <% phase.versions.each do |v|%> - - - - - - - - - - - - - <%end%> - -
<%= t('org_admin.templates.title_label')%><%= t('org_admin.templates.published_label')%><%= t('org_admin.templates.created')%><%= t('org_admin.templates.last_updated') %><%= t('org_admin.templates.actions') %>
- <%= v.title %> - - <%= v.published %> - - <%= l v.created_at.to_date, :formats => :short %> - - <%= l v.updated_at.to_date, :formats => :short %> - - <%= link_to t("helpers.view"), admin_phase_dmptemplate_path( :version_id => v.id, :id => phase.id , :edit => 'false'), :class => "dmp_table_link"%> - <% if v.published? then%> - - <%= t('org_admin.versions.edit_label')%> - - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> - <%else%> - <%= link_to t("org_admin.versions.edit_label"), admin_phase_dmptemplate_path(phase, :version_id => v.id, :edit => 'true'), :class => "dmp_table_link" %> - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> - <%#= link_to t("helpers.submit.delete"), admin_destroyversion_dmptemplate_path(:version_id => v.id, :phase => phase , :edit => 'false'), - :confirm => t("org_admin.versions.delete_message", :version_title => v.title ), :method => :delete, :class => "dmp_table_link"%> - <%end%> -
-
- - - -<%end%> diff --git a/app/views/templates/admin_addphase.html.erb b/app/views/templates/admin_addphase.html.erb index 65a3e6c..02c62ad 100644 --- a/app/views/templates/admin_addphase.html.erb +++ b/app/views/templates/admin_addphase.html.erb @@ -43,7 +43,7 @@ <%= t("org_admin.templates.phase_order_label") %> - <%= f.number_field :number, in: 1..5, class: "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.phase_number_help_text") %> + <%= f.number_field :number, in: 1..5, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: t("org_admin.templates.phase_number_help_text") %> <%= t("org_admin.templates.desc_label") %> @@ -67,7 +67,7 @@
<%end%> -
+
diff --git a/app/views/templates/admin_new.html.erb b/app/views/templates/admin_new.html.erb index 61566b7..0fdf7cc 100644 --- a/app/views/templates/admin_new.html.erb +++ b/app/views/templates/admin_new.html.erb @@ -21,7 +21,7 @@ <%= t("org_admin.templates.title_label") %> <%= f.text_field :title, as: :string, - class: "text_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.title_help_text") %> + class: "text_field has-tooltip", "data-toggle" => "tooltip", title: t("org_admin.templates.title_help_text") %> <%= t("org_admin.templates.desc_label") %> diff --git a/app/views/templates/admin_phase.html.erb b/app/views/templates/admin_phase.html.erb index 067ce1b..575e86a 100644 --- a/app/views/templates/admin_phase.html.erb +++ b/app/views/templates/admin_phase.html.erb @@ -9,8 +9,8 @@
<%= link_to t("org_admin.templates.view_all_templates"), - admin_index_template_path, - class: 'btn btn-primary' %> + admin_index_template_path, + class: 'btn btn-primary' %>
@@ -23,11 +23,11 @@
- +
- +
<%= render partial: "show_phase", locals: {phase: @phase}%>
diff --git a/app/views/templates/admin_previewphase.html.erb b/app/views/templates/admin_previewphase.html.erb index 12c2507..58de962 100644 --- a/app/views/templates/admin_previewphase.html.erb +++ b/app/views/templates/admin_previewphase.html.erb @@ -2,63 +2,58 @@ <%= stylesheet_link_tag "admin" %>

- <%= @version.phase.dmptemplate.title %> - -
- <%= link_to t("org_admin.templates.back_to_edit_phase_label"), - admin_phase_dmptemplate_path(:id => @version.phase_id, :version_id => @version.id, :edit => "true"), - :class => 'btn btn-primary' %> - <%= link_to t("org_admin.templates.view_all_templates"), - admin_index_dmptemplate_path, - :class => 'btn btn-primary' %> -
+ <%= @template.title %> + +
+ <%= link_to t("org_admin.templates.back_to_edit_phase_label"), + admin_phase_template_path(id: @phase.id, edit: "true"), + class: 'btn btn-primary' %> + <%= link_to t("org_admin.templates.view_all_templates"), + admin_index_template_path, + class: 'btn btn-primary' %> +

-<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @version.phase.dmptemplate, active: @version.phase_id} %> +<%= render partial: "admin_nav_tabs", locals: {template: @template, active: @phase.id} %>
\ No newline at end of file +
+ <% sections = @phase.sections %> + <% sections.order(:number).each do |section| %> +
+ +
+
+ <%= raw section.description %> +
+
+ <% last_question_id = section.questions.order("number DESC").first.id%> + + <% section.questions.order("number").each do |question| %> + + <%= render partial: 'preview_question', locals: {question: question}%> + <% if last_question_id == question.id then %> +
+ <% else %> +
+ <% end %> + + <% end %> +
+
+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/templates/admin_template.html.erb b/app/views/templates/admin_template.html.erb index b8d0506..fec8cc3 100644 --- a/app/views/templates/admin_template.html.erb +++ b/app/views/templates/admin_template.html.erb @@ -7,7 +7,7 @@
<%= link_to t("org_admin.templates.view_all_templates"), admin_index_template_path, - :class => 'btn btn-primary' %> + class: 'btn btn-primary' %>