diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index b65f33f..fa8aa75 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -9,10 +9,10 @@ CHECKBOX = QuestionFormat.where(title: "Check box").first.id DROPDOWN = QuestionFormat.where(title: "Dropdown").first.id MULTI = QuestionFormat.where(title: "Multi select box").first.id - + # GET /plans/PLANID/phases/PHASEID/edit def edit - + @textarea = TEXTAREA @textfield = TEXTFIELD @radio = RADIO @@ -36,8 +36,8 @@ end end - - + + # GET /plans/PLANID/phases/PHASEID/status.json def status @plan = Plan.find(params[:plan_id]) @@ -52,4 +52,88 @@ end + + #show and edit a phase of the template + def admin_show + @phase = Phase.find(params[:id]) + authorize @phase + @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 + end + + + #preview a phase + def admin_preview + @phase = Phase.find(params[:id]) + authorize @phase + @template = @phase.template + end + + + #add a new phase to a passed template + def admin_add + @template = Template.find(params[:id]) + @phase = Phase.new + phase.template = @template + authorize @phase + @phase.number = @template.phases.count + 1 + end + + + #create a phase + def admin_create + @phase = Phase.new(params[:phase]) + authorize @phase + @phase.description = params["phase-desc"] + @phase.modifiable = true + if @phase.save + redirect_to admin_show_phase_path(id: @phase.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') + else + render action: "admin_show" + end + end + + + #update a phase of a template + def admin_update + @phase = Phase.find(params[:id]) + authorize @phase + @phase.description = params["phase-desc"] + if @phase.update_attributes(params[:phase]) + redirect_to admin_show_phase_path(@phase), notice: I18n.t('org_admin.templates.updated_message') + else + render action: "admin_show" + end + end + + #delete a phase + def admin_destroy + @phase = Phase.find(params[:phase_id]) + authorize @phase + @template = @phase.template + @phase.destroy + redirect_to admin_template_template_path(@template), notice: I18n.t('org_admin.templates.destroyed_message') + end + + + end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb new file mode 100644 index 0000000..d150bff --- /dev/null +++ b/app/controllers/questions_controller.rb @@ -0,0 +1,43 @@ +class QuestionsController < ApplicationController + respond_to :html + after_action :verify_authorized + + #create a question + def admin_create + @question = Question.new(params[:question]) + authorize @question + @question.guidance = params["new-question-guidance"] + @question.default_value = params["new-question-default-value"] + if @question.save! + redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') + else + render action: "phases/admin_show" + end + end + + #update a question of a template + def admin_update + @question = Question.find(params[:id]) + authorize @question + @question.guidance = params["question-guidance-#{params[:id]}"] + @question.default_value = params["question-default-value-#{params[:id]}"] + @section = @question.section + @phase = @section.phase + if @question.update_attributes(params[:question]) + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, edit: 'true'), notice: I18n.t('org_admin.templates.updated_message') + else + render action: "phases/admin_show" + end + end + + #delete question + def admin_destroy + @question = Question.find(params[:question_id]) + authorize @question + @section = @question.section + @phase = @section.phase + @question.destroy + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: I18n.t('org_admin.templates.destroyed_message') + end + +end \ No newline at end of file diff --git a/app/controllers/sections_controller.rb b/app/controllers/sections_controller.rb new file mode 100644 index 0000000..42a65a4 --- /dev/null +++ b/app/controllers/sections_controller.rb @@ -0,0 +1,46 @@ +class SectionsController < ApplicationController + respond_to :html + after_action :verify_authorized + + #create a section + def admin_create + @section = Section.new(params[:section]) + authorize @section + @section.description = params["section-desc"] + @section.modifiable = true + @phase = section.phase + if @section.save + redirect_to admin_show_phase_template_path(id: @section.phase_id, + :section_id => @section.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') + else + render action: "phases/admin_show" + end + end + + + #update a section of a template + def admin_update + @section = Section.includes(phase: :template).find(params[:id]) + authorize @section + @section.description = params["section-desc-#{params[:id]}"] + @phase = @section.phase + if @section.update_attributes(params[:section]) + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id , edit: 'true'), notice: I18n.t('org_admin.templates.updated_message') + else + render action: "phases/admin_show" + end + end + + + #delete a section and questions + def admin_destroy + @section = Section.includes(phase: :template).find(params[:section_id]) + authorize @section + @phase = @section.phase + @section.destroy + redirect_to admin_show_phase_path(id: @phase.id, edit: 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') + end + + + +end \ No newline at end of file diff --git a/app/controllers/suggested_answers_controller.rb b/app/controllers/suggested_answers_controller.rb new file mode 100644 index 0000000..a42e289 --- /dev/null +++ b/app/controllers/suggested_answers_controller.rb @@ -0,0 +1,42 @@ +class SuggestedAnswersController < ApplicationController + respond_to :html + after_action :verify_authorized + + #create suggested answers + def admin_create + @suggested_answer = SuggestedAnswer.new(params[:suggested_answer]) + authorize @suggested_answer + if @suggested_answer.save + redirect_to admin_show_phase_path(id: @suggested_answer.question.section.phase_id, section_id: @suggested_answer.question.section_id, question_id: @suggested_answer.question.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') + else + render action: "phases/admin_show" + end + end + + + #update a suggested answer of a template + def admin_update + @suggested_answer = SuggestedAnswer.includes(question: { section: {phase: :template}}).find(params[:id]) + authorize @suggested_answer.question.section.phase.template + @question = @suggested_answer + @section = @question.section + @phase = @section.phase + if @suggested_answer.update_attributes(params[:suggested_answer]) + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, edit: 'true'), notice: I18n.t('org_admin.templates.updated_message') + else + render action: "phases/admin_show" + end + end + + #delete a suggested answer + def admin_destroy + @suggested_answer = SuggestedAnswer.includes(question: { section: {phase: :template}}).find(params[:id]) + authorize @suggested_answer + @question = @suggested_answer.question + @section = @question.section + @phase = @section.phase + @suggested_answer.destroy + redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: I18n.t('org_admin.templates.destroyed_message') + end + +end \ No newline at end of file diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 50f3c60..8f2d4df 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -192,7 +192,7 @@ break random unless Template.exists?(dmptemplate_id: random) end authorize @template - if @template.save + if @template.save! redirect_to admin_template_template_path(@template), notice: I18n.t('org_admin.templates.created_message') else render action: "admin_new" @@ -215,207 +215,4 @@ @templates = Template.where(dmptemplate_id: @template.dmptemplate_id).order(:version) end - - - # PHASES - - #show and edit a phase of the template - def admin_phase - @phase = Phase.find(params[:id]) - authorize @phase.template - @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 - end - - - #preview a phase - def admin_previewphase - @phase = Phase.find(params[:id]) - authorize @phase.template - @template = @phase.template - end - - - #add a new phase to a template - def admin_addphase - @template = Template.find(params[:id]) - @phase = Phase.new - authorize @template - @phase.number = @template.phases.count + 1 - end - - - #create a phase - def admin_createphase - @phase = Phase.new(params[:phase]) - authorize @phase.template - @phase.description = params["phase-desc"] - @phase.modifiable = true - if @phase.save - redirect_to admin_phase_template_path(id: @phase.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') - else - render action: "admin_phase" - end - end - - - #update a phase of a template - def admin_updatephase - @phase = Phase.find(params[:id]) - authorize @phase.template - @phase.description = params["phase-desc"] - if @phase.update_attributes(params[:phase]) - redirect_to admin_phase_template_path(@phase), notice: I18n.t('org_admin.templates.updated_message') - else - render action: "admin_phase" - end - end - - #delete a phase - def admin_destroyphase - @phase = Phase.find(params[:phase_id]) - authorize @phase.template - @template = @phase.template - @phase.destroy - redirect_to admin_template_template_path(@template), notice: I18n.t('org_admin.templates.destroyed_message') - end - -# SECTIONS - #create a section - def admin_createsection - @section = Section.new(params[:section]) - authorize @section.phase.template - @section.description = params["section-desc"] - @section.modifiable = true - if @section.save - redirect_to admin_phase_template_path(id: @section.phase_id, - :section_id => @section.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') - else - render action: "admin_phase" - end - end - - - #update a section of a template - def admin_updatesection - @section = Section.find(params[:id]) - authorize @section.phase.template - @section.description = params["section-desc-#{params[:id]}"] - @phase = @section.phase - if @section.update_attributes(params[:section]) - redirect_to admin_phase_template_path(id: @phase.id, section_id: @section.id , edit: 'true'), notice: I18n.t('org_admin.templates.updated_message') - else - render action: "admin_phase" - end - end - - - #delete a section and questions - def admin_destroysection - @section = Section.find(params[:section_id]) - authorize @section.phase.template - @phase = @section.phase - @section.destroy - redirect_to admin_phase_template_path(id: @phase.id, edit: 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') - end - - -# QUESTIONS - - #create a question - def admin_createquestion - @question = Question.new(params[:question]) - authorize @question.section.phase.template - @question.guidance = params["new-question-guidance"] - @question.default_value = params["new-question-default-value"] - if @question.save! - redirect_to admin_phase_template_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') - else - render action: "admin_phase" - end - end - - #update a question of a template - def admin_updatequestion - @question = Question.find(params[:id]) - authorize @question.section.phase.template - @question.guidance = params["question-guidance-#{params[:id]}"] - @question.default_value = params["question-default-value-#{params[:id]}"] - @section = @question.section - @phase = @section.phase - if @question.update_attributes(params[:question]) - redirect_to admin_phase_template_path(id: @phase.id, section_id: @section.id, question_id: @question.id, edit: 'true'), notice: I18n.t('org_admin.templates.updated_message') - else - render action: "admin_phase" - end - end - - #delete question - def admin_destroyquestion - @question = Question.find(params[:question_id]) - authorize @question.section.phase.template - @section = @question.section - @phase = @section.phase - @question.destroy - redirect_to admin_phase_template_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: I18n.t('org_admin.templates.destroyed_message') - end - - - #SUGGESTED ANSWERS - #create suggested answers - def admin_createsuggestedanswer - @suggested_answer = SuggestedAnswer.new(params[:suggested_answer]) - authorize @suggested_answer.question.section.phase.template - if @suggested_answer.save - redirect_to admin_phase_template_path(id: @suggested_answer.question.section.phase_id, section_id: @suggested_answer.question.section_id, question_id: @suggested_answer.question.id, edit: 'true'), notice: I18n.t('org_admin.templates.created_message') - else - render action: "admin_phase" - end - end - - - #update a suggested answer of a template - def admin_updatesuggestedanswer - @suggested_answer = SuggestedAnswer.find(params[:id]) - authorize @suggested_answer.question.section.phase.template - @question = @suggested_answer.question - @section = @question.section - @phase = @section.phase - if @suggested_answer.update_attributes(params[:suggested_answer]) - redirect_to admin_phase_template_path(id: @phase.id, section_id: @section.id, question_id: @question.id, edit: 'true'), notice: I18n.t('org_admin.templates.updated_message') - else - render action: "admin_phase" - end - end - - #delete a suggested answer - def admin_destroysuggestedanswer - @suggested_answer = SuggestedAnswer.find(params[:suggested_answer]) - authorize @suggested_answer.question.section.phase.template - @question = @suggested_answer.question - @section = @question.section - @phase = @section.phase - @suggested_answer.destroy - redirect_to admin_phase_template_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: I18n.t('org_admin.templates.destroyed_message') - end - end \ No newline at end of file diff --git a/app/policies/phase_policy.rb b/app/policies/phase_policy.rb new file mode 100644 index 0000000..5d43a7e --- /dev/null +++ b/app/policies/phase_policy.rb @@ -0,0 +1,40 @@ +class PhasePolicy < ApplicationPolicy + attr_reader :user, :phase + + def initialize(user, phase) + raise Pundit::NotAuthorizedError, "must be logged in" unless user + @user = user + @phase = phase + end + + ## + # Users can modify phases if: + # - They can modify templates + # - The template which they are modifying belongs to their org + ## + + def admin_show? + user.can_modify_templates? && (phase.template.org_id == user.org_id) + end + + def admin_preview? + user.can_modify_templates? && (phase.template.org_id == user.org_id) + end + + def admin_update? + user.can_modify_templates? && (phase.template.org_id == user.org_id) + end + + def admin_add? + user.can_modify_templates? && (phase.template.org_id == user.org_id) + end + + def admin_create? + user.can_modify_templates? && (phase.template.org_id == user.org_id) + end + + def admin_destroy? + user.can_modify_templates? && (phase.template.org_id == user.org_id) + end + +end \ No newline at end of file diff --git a/app/policies/question_policy.rb b/app/policies/question_policy.rb new file mode 100644 index 0000000..5ea487c --- /dev/null +++ b/app/policies/question_policy.rb @@ -0,0 +1,28 @@ +class QuestionPolicy < ApplicationPolicy + attr_reader :user, :question + + def initialize(user, question) + raise Pundit::NotAuthorizedError, "must be logged in" unless user + @user = user + @question = question + end + + ## + # Users can modify questions if: + # - They can modify templates + # - The template which they are modifying belongs to their org + ## + + def admin_create? + user.can_modify_templates? && (question.section.phase.template.org_id == user.org_id) + end + + def admin_update? + user.can_modify_templates? && (question.section.phase.template.org_id == user.org_id) + end + + def admin_destroy? + user.can_modify_templates? && (question.section.phase.template.org_id == user.org_id) + end + +end \ No newline at end of file diff --git a/app/policies/section_policy.rb b/app/policies/section_policy.rb new file mode 100644 index 0000000..6effdbe --- /dev/null +++ b/app/policies/section_policy.rb @@ -0,0 +1,28 @@ +class SectionPolicy < ApplicationPolicy + attr_reader :user, :section + + def initialize(user, section) + raise Pundit::NotAuthorizedError, "must be logged in" unless user + @user = user + @section = section + end + + ## + # Users can modify sections if: + # - They can modify templates + # - The template which they are modifying belongs to their org + ## + + def admin_create? + user.can_modify_templates? && (section.phase.template.org_id == user.org_id) + end + + def admin_update? + user.can_modify_templates? && (section.phase.template.org_id == user.org_id) + end + + def admin_destroy? + user.can_modify_templates? && (section.phase.template.org_id == user.org_id) + end + +end \ No newline at end of file diff --git a/app/policies/suggested_answer_policy.rb b/app/policies/suggested_answer_policy.rb new file mode 100644 index 0000000..e6cd49c --- /dev/null +++ b/app/policies/suggested_answer_policy.rb @@ -0,0 +1,28 @@ +class SuggestedAnswerPolicy < ApplicationPolicy + attr_reader :user, :suggested_answer + + def initialize(user, suggested_answer) + raise Pundit::NotAuthorizedError, "must be logged in" unless user + @user = user + @suggested_answer = suggested_answer + end + + ## + # Users can modify suggested answers if: + # - They can modify templates + # - The template which they are modifying belongs to their org + ## + + def admin_create? + user.can_modify_templates? && (suggested_answer.question.section.phase.template.org_id == user.org_id) + end + + def admin_update? + user.can_modify_templates? && (suggested_answer.question.section.phase.template.org_id == user.org_id) + end + + def admin_destroy? + user.can_modify_templates? && (suggested_answer.question.section.phase.template.org_id == user.org_id) + end + +end \ No newline at end of file diff --git a/app/policies/template_policy.rb b/app/policies/template_policy.rb index 1fd64f5..41e1f7c 100644 --- a/app/policies/template_policy.rb +++ b/app/policies/template_policy.rb @@ -7,6 +7,12 @@ @template = template end + ## + # Users can modify templates if: + # - They can modify templates + # - The template which they are modifying belongs to their org + ## + def admin_index? user.can_modify_templates? end @@ -35,89 +41,6 @@ user.can_modify_templates? && (template.org_id == user.org_id) end - def admin_phase? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_previewphase? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_addphase? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_createphase? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_updatephase? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroyphase? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_updateversion? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_cloneversion? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroyversion? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_createsection? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_updatesection? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroysection? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_createquestion? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_updatequestion? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroyquestion? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_createsuggestedanswer? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_updatesuggestedanswer? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroysuggestedanswer? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_createguidance? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_updateguidance? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroyguidance? - user.can_modify_templates? && (template.org_id == user.org_id) - end class Scope < Scope def resolve diff --git a/app/views/guidances/_add_guidance.html.erb b/app/views/guidances/_add_guidance.html.erb new file mode 100644 index 0000000..af080d0 --- /dev/null +++ b/app/views/guidances/_add_guidance.html.erb @@ -0,0 +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"))%> +
+
+ + +
<%= 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 %> +
+ + + + + \ No newline at end of file diff --git a/app/views/guidances/_edit_guidance.html.erb b/app/views/guidances/_edit_guidance.html.erb new file mode 100644 index 0000000..d784e1f --- /dev/null +++ b/app/views/guidances/_edit_guidance.html.erb @@ -0,0 +1,26 @@ + +<%= form_for(suggested_answer, url: admin_update_suggested_answer_path(suggested_answer), html: { method: :put}) do |f| %> + <%= f.hidden_field :org_id, value: current_user.org_id %> + + + + + + +
<%= t("org_admin.questions.suggested_or_example_answer_label")%> +
    +
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= f.text_area :text, rows: 5 %>
  • +
+
+
+ + +
+ <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> + <%= link_to t("helpers.submit.delete"), admin_destroy_suggested_answer_path(id: suggested_answer.id), + confirm: t("org_admin.questions.delete_suggested_answer_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to t("helpers.submit.cancel"), "#", class: "btn cancel cancel_edit_suggested_answer" %> +
+<%end%> diff --git a/app/views/guidances/_guidance_display.html.erb b/app/views/guidances/_guidance_display.html.erb new file mode 100644 index 0000000..9a0755a --- /dev/null +++ b/app/views/guidances/_guidance_display.html.erb @@ -0,0 +1,36 @@ + + +
+
+ <% if !question.guidance.nil? && question.guidance != "" %> + + <% end %> + + <% question.guidance_for_org(current_user.org).each_pair do |title,guidance| %> +
+ +
+
<%= raw guidance.text %>
+
+
+ <% 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 new file mode 100644 index 0000000..e8debf7 --- /dev/null +++ b/app/views/phases/_edit_phase.html.erb @@ -0,0 +1,45 @@ + + +<%= form_for(phase, url: admin_update_phase_path(phase.id), html: { method: :put}) do |f| %> + +

+ <%= t('org_admin.templates.phase_details_label')%> +

+
+ <%= raw t('org_admin.templates.phase_details_text_html')%> +
+
+
+ + + + + + + + + + + + + + +
<%= 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.phase_order_label') %><%= f.number_field :number, in: 0..5, class: "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_number_help_text') %>
<%= t('org_admin.templates.desc_label') %> +
+ <%= text_area_tag("phase-desc", phase.description, class: "tinymce") %> +
+
+ <%= link_to( image_tag('help_button.png'), '#', class: 'phase_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.phase_desc_help_text_html'))%> +
+
+
+ + +
+ <%= f.submit t('helpers.submit.save'), class: 'btn btn-primary' %> + <%= link_to t('helpers.submit.cancel'), admin_show_phase_path(phase), class: 'btn cancel' %> +
+ +<% end %> \ No newline at end of file diff --git a/app/views/phases/_show_phase.html.erb b/app/views/phases/_show_phase.html.erb new file mode 100644 index 0000000..f110902 --- /dev/null +++ b/app/views/phases/_show_phase.html.erb @@ -0,0 +1,37 @@ + + +

+ <%= 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.template.org.not_funder %> +
+ <%= 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 %>
+
diff --git a/app/views/phases/admin_add.html.erb b/app/views/phases/admin_add.html.erb new file mode 100644 index 0000000..489eb4d --- /dev/null +++ b/app/views/phases/admin_add.html.erb @@ -0,0 +1,75 @@ +<%- model_class = Phase -%> +<%= stylesheet_link_tag "admin" %> +<% javascript "admin.js" %> + +

+ <%= @template.title %> + +
+ <%= link_to t("org_admin.templates.view_all_templates"), + admin_index_template_path, + class: "btn btn-primary" %> +
+

+ +
+ + +<%= render partial: "templates/admin_nav_tabs", locals: {template: @template, active: "add_plan"} %> + + +
+
+ + +
+
+ + + <%= form_for :phase, url: { admin_create_phase_path} do |f| %> +

+ <%= t("org_admin.templates.phase_details_label")%> +

+ <%= raw t("org_admin.templates.phase_new_text_html")%> +
+
+ <%= f.hidden_field :template_id, value: @template.id%> + + + + + + + + + + + + + +
<%= 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.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") %>
<%= t("org_admin.templates.desc_label") %> +
+ <%= text_area_tag("phase-desc","" , class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "phase_desc_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.templates.phase_desc_help_text_html"))%> +
+
+
+
+ + +
+ <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), admin_template_template_path(@template), class: "btn cancel" %> +
+ + <%end%> +
+
+
+
+ +<%= tinymce content_css: asset_path("application.css") %> \ No newline at end of file diff --git a/app/views/phases/admin_preview.html.erb b/app/views/phases/admin_preview.html.erb new file mode 100644 index 0000000..63b0f9a --- /dev/null +++ b/app/views/phases/admin_preview.html.erb @@ -0,0 +1,59 @@ +<%- model_class = Phase -%> +<%= stylesheet_link_tag "admin" %> + +

+ <%= @template.title %> + +
+ <%= link_to t("org_admin.templates.back_to_edit_phase_label"), + admin_show_phase_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: "templates/admin_nav_tabs", locals: {template: @template, active: @phase.id} %> + + +
+
+ <% 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: 'question/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/phases/admin_show.html.erb b/app/views/phases/admin_show.html.erb new file mode 100644 index 0000000..f00abdb --- /dev/null +++ b/app/views/phases/admin_show.html.erb @@ -0,0 +1,69 @@ +<%- model_class = Phase -%> +<%= stylesheet_link_tag "admin" %> +<% javascript 'admin.js' %> + +<%= tinymce content_css: asset_path('application.css') %> + +

+ <%= @phase.template.title %> + +
+ <%= link_to t("org_admin.templates.view_all_templates"), + admin_index_template_path, + class: 'btn btn-primary' %> +
+

+ +
+ + +<%= render partial: "templates/admin_nav_tabs", locals: {template: @phase.template, active: @phase.id} %> + + +
+
+ + +
+
+ + +
+ <%= render partial: "show_phase", locals: {phase: @phase}%> +
+ <% if @phase.modifiable && @edit %> + + <% end %> +
+
+ + + <% @sections.order("number ASC").each do |section| %> + <% 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? %> + + + + +
+
+ <%= link_to t('org_admin.add_section_label'),'#', id: 'add_section_button', class: 'btn btn-primary' %> +
+
+<% end %> + + diff --git a/app/views/question_options/_option_fields.html.erb b/app/views/question_options/_option_fields.html.erb new file mode 100644 index 0000000..5182510 --- /dev/null +++ b/app/views/question_options/_option_fields.html.erb @@ -0,0 +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') %> + diff --git a/app/views/questions/_add_question.html.erb b/app/views/questions/_add_question.html.erb new file mode 100644 index 0000000..b47c5d8 --- /dev/null +++ b/app/views/questions/_add_question.html.erb @@ -0,0 +1,182 @@ + + +<% @new_question = Question.new %> +<% @new_question.number = section.questions.count + 1 %> + + +<%= form_for @new_question, url: admin_create_question_path , html: {id: "new_question_#{section.id}"} do |f| %> + <%= f.hidden_field :section_id, value: section.id %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, in: 1..50, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: t("org_admin.questions.number_help_text") %> + +
+
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, rows: "5", id: "new_question_text_#{section.id}" %> +
+
<%= t("org_admin.questions.answer_format_label")%><%= f.hidden_field :section_id, value: section.id, class: "section_id" %> +
+
+ <%= f.select :question_format_id, + options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, QuestionFormat.find_by_title(t("helpers.text_area")).id), + {}, id: "new-select-format-#{section.id}"%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "question_format_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> +
+ +
+
+ + +
+ + +
+ + +
+ +
+
+
+
<%= t("org_admin.questions.suggested_or_example_answer_label")%> +
+ <% suggested_answer = @new_question.suggested_answers.build %> + <%= f.fields_for :suggested_answers, suggested_answer do |s|%> + <%= s.hidden_field :org_id, value: current_user.org_id %> +
    +
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= s.text_area :text, rows: 5 %>
  • +
+ <% end %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "suggested_answer_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> +
+
+
+ +
<%= t("org_admin.questions.guidance_label")%> +
+ <%= text_area_tag("new-question-guidance", "", class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "question_guidance_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> +
+
+
+
<%= t("org_admin.questions.themes_label")%> +
+ <%= f.collection_select(:theme_ids, + Theme.all.order("title"), + :id, :title, {prompt: false, include_blank: t('helpers.none')}, {multiple: true})%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "question_themes_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> +
+ + +
+
+ + +
+ <%= hidden_field_tag :section_id, section.id, class: "section_id" %> + <%= f.submit t("helpers.submit.save"), class: "btn btn-primary new_question_save_button" %> + <%= hidden_field_tag :section_id, section.id, class: "section_id_new" %> + <%= link_to t("helpers.submit.cancel"), '#', class: "btn cancel cancel_add_new_question" %> +
+
+ +<% end %> + diff --git a/app/views/questions/_edit_question.html.erb b/app/views/questions/_edit_question.html.erb new file mode 100644 index 0000000..890d774 --- /dev/null +++ b/app/views/questions/_edit_question.html.erb @@ -0,0 +1,174 @@ + + +<%= form_for(question, url: admin_update_question_path(question), html: { method: :put}) do |f| %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, in: 1..50, class: "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %> +
+
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, rows: "5" %> +
+
<%= t("org_admin.questions.answer_format_label")%>
+
+ <%= f.hidden_field :id,{ class: "quest_id" } %> + <%= f.select :question_format_id, + options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, question.question_format_id), + {}, id: "#{question.id}-select-format"%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "question_format_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> +
+ +
+ + + +
+ + +
+ + +
+ +
+
+
+
<%= t("org_admin.questions.suggested_or_example_answer_label")%>
+ <% suggested_answer = question.suggested_answers.find_by_org_id(current_user.org.id) %> + <% if suggested_answer.nil? %> + <% suggested_answer = question.suggested_answers.build %> + <% end %> + <%= f.fields_for :suggested_answers, suggested_answer do |s|%> + <%= s.hidden_field :org_id, value: current_user.org.id %> +
    +
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= s.text_area :text, rows: 5 %> +
  • +
+ <% end %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "suggested_answer_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> +
+
+
+
<%= t("org_admin.questions.guidance_label")%>
+ <%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "question_guidance_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> +
+
+
+
<%= t("org_admin.questions.themes_label")%>
+ <%= f.collection_select(:theme_ids, + Theme.all.order("title"), + :id, :title, {prompt: false, include_blank: "None"}, {multiple: true})%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "question_themes_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> +
+
+
+ +
+ <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> + <% if !question.section.phase.template.published? %> + <%= link_to t("helpers.submit.delete"), admin_destroy_question_path(question_id: question.id), + confirm: t("org_admin.questions.delete_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> + <% end %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to t("helpers.submit.cancel"), "#", class: "btn cancel cancel_edit_question" %> +
+
+ + + +<%= render partial: "guidances/guidance_display", locals: {question: question} %> +<% end %> diff --git a/app/views/questions/_preview_question.html.erb b/app/views/questions/_preview_question.html.erb new file mode 100644 index 0000000..a7424e4 --- /dev/null +++ b/app/views/questions/_preview_question.html.erb @@ -0,0 +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") %> + <% 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: "guidances/guidance_display", locals: {question: question}%> diff --git a/app/views/questions/_show_question.html.erb b/app/views/questions/_show_question.html.erb new file mode 100644 index 0000000..c35b492 --- /dev/null +++ b/app/views/questions/_show_question.html.erb @@ -0,0 +1,148 @@ + + +
+ + + + + + + + + + + + + + <% if q_format.title == t("helpers.text_field") || q_format.title == t("helpers.text_area") %> + <% if !question.default_value.nil? %> + + + + + <% end %> + <% end %> + + + + + + + + <% if question.section.phase.template.org.org_type != constant("organisation_types.funder") %> + <% suggested_answer = question.get_suggested_answer(current_user.org_id) %> + <% if !suggested_answer.nil? && suggested_answer.text != "" %> + + + + + <% end %> + <% end %> + + <% if !question.guidance.nil? %> + + + + + <% end %> + + <% themes_q = question.themes %> + <% if !themes_q.nil? %> + + + + + <% end %> +
<%= t('org_admin.questions.question_number_label')%><%= question.number %>
<%= t('org_admin.questions.question_text_label')%><%= raw question.text %> +
+
+ <% 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") %> +
    + <% if question.question_options.is_a? QuestionOption %> +
  • - <%= question.question_options.text %>
  • + <% else %> + <% if !question.question_options.to_a.nil? %> + <% question.question_options.to_a.sort_by{|op| op['number']}.each do |o| %> +
  • - <%= o.text %>
  • + <% end %> + <% end %> + <% end %> +
+ <% end %> +
+
<%= t('org_admin.questions.default_value_label')%><%= raw question.default_value %>
<%= t('org_admin.questions.answer_format_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.option_comment_display == true %> + <%= t("org_admin.questions.option_comment_display")%> + <% else %> + <%= t("org_admin.questions.option_comment_hide")%> + <% end %> + <% end %> +
+
+ <% 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 %>
<%= t('org_admin.questions.guidance_label')%><%= raw question.guidance %>
<%= t('org_admin.questions.themes_label')%><% i = 1%> + <% themes_q.each do |t|%> + <%= t.title %> + <% if themes_q.count > i %> + , + <% i +=1 %> + <% end %> + <% end %> +
+
+ + <% if !question.modifiable %> + <% suggested_answer = question.get_suggested_answer(current_user.org_id) %> + <% if !suggested_answer.nil? && suggested_answer.text != "" %> +
+ <%= render partial: 'suggested_answers/show_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %> +
+ + <% end %> + + <% end %> + +
+ + <% if (@edit && question.section.modifiable) || question.section.phase.template.customization_of.present? %> +
+ <%= 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_destroy_question_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 && 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"%> +
+
+ <% end %> + <% end %> +
+
+ + + +<%= render partial: 'guidances/guidance_display', locals: {question: question}%> diff --git a/app/views/sections/_add_section.html.erb b/app/views/sections/_add_section.html.erb new file mode 100644 index 0000000..ba916ec --- /dev/null +++ b/app/views/sections/_add_section.html.erb @@ -0,0 +1,54 @@ + + +<% @new_section = Section.new %> +<% @new_section.number = phase.sections.count + 1 %> + + +<%= form_for @new_section, url: admin_create_section_path do |f| %> + <%= f.hidden_field :phase_id, value: phase.id %> + +
+
+
+
+ + <%= f.text_field :title, as: :string, class: "text_field", placeholder: t("org_admin.templates.section_title_placeholder")%> +
+ + +
+ +
+
+
+ + + + + + + + + +
<%= t("org_admin.templates.phase_order_label") %> + <%= f.number_field :number, in: 1..15, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: t("org_admin.templates.section_number_help_text") %> +
<%= t("org_admin.templates.desc_label") %> +
+ <%= text_area_tag("section-desc", "" , class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", class: "section_desc_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.templates.section_desc_help_text_html"))%> +
+
+ +
+ <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), "#", id: "", class: "btn cancel" %> +
+
+
+
+
+<% end %> + + diff --git a/app/views/sections/_edit_section.html.erb b/app/views/sections/_edit_section.html.erb new file mode 100644 index 0000000..3e9e0ab --- /dev/null +++ b/app/views/sections/_edit_section.html.erb @@ -0,0 +1,116 @@ + + + +<%= form_for(section, url: admin_update_section_path(section, phase: phase, edit: edit), html: { method: :put}) do |s| %> + <% if @open && @section_id == section.id then%> + <% toggle = 'accordion-body section-collapse in collapse'%> + <% else %> + <% toggle = 'accordion-body collapse section-collapse' %> + <% end %> + + <% if @new_sec %> + <% toggle = 'accordion-body section-collapse in collapse'%> + <% end %> + +
+
+
+
+ <%= s.text_field :title, as: :string, class: 'text_field', placeholder: t('org_admin.templates.section_title_placeholder') %> + +
+
+ +
+ + +
+
+ + + + + + + + + +
<%= t('org_admin.templates.phase_order_label') %><%= s.number_field :number, in: 1..15, class: "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.section_number_help_text') %>
<%= t('org_admin.templates.desc_label') %> +
+ <%= text_area_tag("section-desc-#{section.id}", section.description , class: "tinymce") %> +
+
+ <%= link_to( image_tag('help_button.png'), '#', class: 'section_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.section_desc_help_text_html'))%> +
+
+ +
+ <%= s.submit t('helpers.submit.save'), class: 'btn btn-primary' %> + <% if section.modifiable %> + <%= link_to t("helpers.submit.delete"), admin_destroy_section_path(section_id: section.id), + confirm: t("org_admin.templates.section_delete_message", section_title: section.title ), method: :delete, class: "btn btn-primary"%> + <% end %> + <%= link_to t('helpers.submit.cancel'), :back, class: 'btn cancel' %> +
+<% end %> +
+ <% @questions = section.questions.order("number")%> + <% if @questions.length > 0 %> + <% question_left = @questions.length %> + <% @questions.each do |question| %> +
+
"> + + <%= render partial: 'questions/show_question', locals: {question: question} %> +
+ + +
+ + <% if question_left.to_i > 1 %> +
+ <% else %> +
+ <% end %> + <% question_left = question_left - 1 %> + + <% end %> + <% end %> + + + <% if section.modifiable %> + + <% if @questions.length != 0 %> +
+ <% end%> + + + + +
+
+ <%= hidden_field_tag :section_id, section.id, class: "section_id" %> + <%= link_to t("org_admin.add_question_label"), '#', class: "btn btn-primary add_question_button" %> +
+
+ <% end %> + +
+
+
+
diff --git a/app/views/sections/_show_section.html.erb b/app/views/sections/_show_section.html.erb new file mode 100644 index 0000000..179aede --- /dev/null +++ b/app/views/sections/_show_section.html.erb @@ -0,0 +1,53 @@ + +<% 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 = section.questions.order("number") %> + <% if section_questions.present? %> + <% last_question_id = section_questions.last.id %> + <% section_questions.each do |question| %> +
+ +
"> + + <%= render partial: 'questions/show_question', locals: {question: question} %> +
+ <% if section.phase.template.customization_of.present? %> + + <% end %> +
+ + <% if last_question_id == question.id %> +
+ <% else %> +
+ <% end %> + <% end %> + <% end %> +
+
+
diff --git a/app/views/suggested_answers/_add_suggested_answer.html.erb b/app/views/suggested_answers/_add_suggested_answer.html.erb new file mode 100644 index 0000000..80a3067 --- /dev/null +++ b/app/views/suggested_answers/_add_suggested_answer.html.erb @@ -0,0 +1,25 @@ + +<%= form_for :suggested_answer, url: admin_create_suggested_answer_path do |f| %> + <%= f.hidden_field :org_id, value: current_user.org_id %> + <%= f.hidden_field :question_id, value: question.id %> + + + + + + +
<%= t("org_admin.questions.suggested_or_example_answer_label")%> +
    +
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= f.text_area :text, rows: 5 %> +
  • +
+
+
+ + +
+ <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), "#", id: "cancel_suugested_answer", class: "btn cancel" %> +
+<%end%> diff --git a/app/views/suggested_answers/_edit_suggested_answer.html.erb b/app/views/suggested_answers/_edit_suggested_answer.html.erb new file mode 100644 index 0000000..d6685ed --- /dev/null +++ b/app/views/suggested_answers/_edit_suggested_answer.html.erb @@ -0,0 +1,26 @@ + +<%= form_for(suggested_answer, url: admin_update_suggested_answer_path(suggested_answer), html: { method: :put}) do |f| %> + <%= f.hidden_field :org_id, value: current_user.org_id %> + + + + + + +
<%= t('org_admin.questions.suggested_or_example_answer_label')%> +
    +
  • <%= f.select :is_example, {t('org_admin.questions.example_answer_label') => true, t('org_admin.questions.suggested_answer_label') => false} %>
  • +
  • <%= f.text_area :text, rows: 5 %>
  • +
+
+
+ + +
+ <%= f.submit t('helpers.submit.save'), class: 'btn btn-primary' %> + <%= link_to t("helpers.submit.delete"), admin_destroy_suggested_answer_path(id: suggested_answer.id), + confirm: t("org_admin.questions.delete_suggested_answer_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to t('helpers.submit.cancel'), '#', class: 'btn cancel cancel_edit_suggested_answer' %> +
+<% end %> diff --git a/app/views/suggested_answers/_show_suggested_answer.html.erb b/app/views/suggested_answers/_show_suggested_answer.html.erb new file mode 100644 index 0000000..c760bc9 --- /dev/null +++ b/app/views/suggested_answers/_show_suggested_answer.html.erb @@ -0,0 +1,19 @@ + + + + + + +
+ <% 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 %>
+
+ +
+ <%= 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/_add_guidance.html.erb b/app/views/templates/_add_guidance.html.erb deleted file mode 100644 index af080d0..0000000 --- a/app/views/templates/_add_guidance.html.erb +++ /dev/null @@ -1,93 +0,0 @@ - -
- <%= 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(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 %> -
- - - - - \ No newline at end of file diff --git a/app/views/templates/_add_question.html.erb b/app/views/templates/_add_question.html.erb deleted file mode 100644 index 62232bd..0000000 --- a/app/views/templates/_add_question.html.erb +++ /dev/null @@ -1,182 +0,0 @@ - - -<% @new_question = Question.new %> -<% @new_question.number = section.questions.count + 1 %> - - -<%= form_for @new_question, url: {action: "admin_createquestion"}, html: {id: "new_question_#{section.id}"} do |f| %> - <%= f.hidden_field :section_id, value: section.id %> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, in: 1..50, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: t("org_admin.questions.number_help_text") %> - -
-
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, rows: "5", id: "new_question_text_#{section.id}" %> -
-
<%= t("org_admin.questions.answer_format_label")%><%= f.hidden_field :section_id, value: section.id, class: "section_id" %> -
-
- <%= f.select :question_format_id, - options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, QuestionFormat.find_by_title(t("helpers.text_area")).id), - {}, id: "new-select-format-#{section.id}"%> -
-
- <%= link_to( image_tag("help_button.png"), "#", class: "question_format_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> -
- -
-
- - -
- - -
- - -
- -
-
-
-
<%= t("org_admin.questions.suggested_or_example_answer_label")%> -
- <% suggested_answer = @new_question.suggested_answers.build %> - <%= f.fields_for :suggested_answers, suggested_answer do |s|%> - <%= s.hidden_field :org_id, value: current_user.org_id %> -
    -
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • -
  • <%= s.text_area :text, rows: 5 %>
  • -
- <% end %> -
-
- <%= link_to( image_tag("help_button.png"), "#", class: "suggested_answer_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> -
-
-
- -
<%= t("org_admin.questions.guidance_label")%> -
- <%= text_area_tag("new-question-guidance", "", class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", class: "question_guidance_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> -
-
-
-
<%= t("org_admin.questions.themes_label")%> -
- <%= f.collection_select(:theme_ids, - Theme.all.order("title"), - :id, :title, {prompt: false, include_blank: t('helpers.none')}, {multiple: true})%> -
-
- <%= link_to( image_tag("help_button.png"), "#", class: "question_themes_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> -
- - -
-
- - -
- <%= hidden_field_tag :section_id, section.id, class: "section_id" %> - <%= f.submit t("helpers.submit.save"), class: "btn btn-primary new_question_save_button" %> - <%= hidden_field_tag :section_id, section.id, class: "section_id_new" %> - <%= link_to t("helpers.submit.cancel"), '#', class: "btn cancel cancel_add_new_question" %> -
-
- -<% end %> - diff --git a/app/views/templates/_add_section.html.erb b/app/views/templates/_add_section.html.erb deleted file mode 100644 index 94343b1..0000000 --- a/app/views/templates/_add_section.html.erb +++ /dev/null @@ -1,54 +0,0 @@ - - -<% @new_section = Section.new %> -<% @new_section.number = phase.sections.count + 1 %> - - -<%= form_for @new_section, url: {action: "admin_createsection"} do |f| %> - <%= f.hidden_field :phase_id, value: phase.id %> - -
-
-
-
- - <%= f.text_field :title, as: :string, class: "text_field", placeholder: t("org_admin.templates.section_title_placeholder")%> -
- - -
- -
-
-
- - - - - - - - - -
<%= t("org_admin.templates.phase_order_label") %> - <%= f.number_field :number, in: 1..15, class: "number_field has-tooltip", "data-toggle" => "tooltip", title: t("org_admin.templates.section_number_help_text") %> -
<%= t("org_admin.templates.desc_label") %> -
- <%= text_area_tag("section-desc", "" , class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", class: "section_desc_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.templates.section_desc_help_text_html"))%> -
-
- -
- <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), "#", id: "", class: "btn cancel" %> -
-
-
-
-
-<% end %> - - diff --git a/app/views/templates/_add_suggested_answer.html.erb b/app/views/templates/_add_suggested_answer.html.erb deleted file mode 100644 index 8969086..0000000 --- a/app/views/templates/_add_suggested_answer.html.erb +++ /dev/null @@ -1,25 +0,0 @@ - -<%= form_for :suggested_answer, url: {action: "admin_createsuggestedanswer"} do |f| %> - <%= f.hidden_field :org_id, value: current_user.org_id %> - <%= f.hidden_field :question_id, value: question.id %> - - - - - - -
<%= t("org_admin.questions.suggested_or_example_answer_label")%> -
    -
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • -
  • <%= f.text_area :text, rows: 5 %> -
  • -
-
-
- - -
- <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), "#", id: "cancel_suugested_answer", class: "btn cancel" %> -
-<%end%> diff --git a/app/views/templates/_admin_nav_tabs.html.erb b/app/views/templates/_admin_nav_tabs.html.erb index d876bd2..41eac67 100644 --- a/app/views/templates/_admin_nav_tabs.html.erb +++ b/app/views/templates/_admin_nav_tabs.html.erb @@ -15,7 +15,7 @@ <% else %>
  • <% end %> - <%= link_to phase.title, admin_phase_template_path(phase.id) %> + <%= link_to phase.title, admin_show_phase_path(phase.id) %>
  • <% end %> @@ -25,7 +25,7 @@ <% else %>
  • <% end %> - <%= link_to t('org_admin.templates.add_phase_label'), admin_addphase_template_path(template) %> + <%= link_to t('org_admin.templates.add_phase_label'), admin_add_phase_path(template) %>
  • <%end%> diff --git a/app/views/templates/_edit_annotations.html.erb b/app/views/templates/_edit_annotations.html.erb index 108c19d..58ef200 100644 --- a/app/views/templates/_edit_annotations.html.erb +++ b/app/views/templates/_edit_annotations.html.erb @@ -6,7 +6,7 @@ **Copyright: Digital Curation Centre and University of California Curation Center --> -<%= form_for(question, url: admin_updatequestion_template_path(question), html: { method: :put}) do |f| %> +<%= form_for(question, url: admin_update_question_path(question), html: { method: :put}) do |f| %>
    <%= f.hidden_field :id,{ class: "quest_id" } %> @@ -88,7 +88,7 @@
    <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> <% if !question.section.phase.template.published? %> - <%= link_to t("helpers.submit.delete"), admin_destroyquestion_template_path(question_id: question.id), + <%= link_to t("helpers.submit.delete"), admin_destroy_question_path(question_id: question.id), confirm: t("org_admin.questions.delete_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> <% end %> <%= hidden_field_tag :question_id, question.id, class: "question_id" %> @@ -98,5 +98,5 @@ -<%= render partial: "guidance_display", locals: {question: question} %> +<%= render partial: "guidances/guidance_display", locals: {question: question} %> <% end %> diff --git a/app/views/templates/_edit_guidance.html.erb b/app/views/templates/_edit_guidance.html.erb deleted file mode 100644 index e351d51..0000000 --- a/app/views/templates/_edit_guidance.html.erb +++ /dev/null @@ -1,26 +0,0 @@ - -<%= form_for(suggested_answer, url: admin_updatesuggestedanswer_template_path(suggested_answer), html: { method: :put}) do |f| %> - <%= f.hidden_field :org_id, value: current_user.org_id %> - -
    - - - - -
    <%= t("org_admin.questions.suggested_or_example_answer_label")%> -
      -
    • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
    • -
    • <%= f.text_area :text, rows: 5 %>
    • -
    -
    -
    - - -
    - <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> - <%= link_to t("helpers.submit.delete"), admin_destroysuggestedanswer_template_path(suggested_answer: suggested_answer.id), - confirm: t("org_admin.questions.delete_suggested_answer_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> - <%= hidden_field_tag :question_id, question.id, class: "question_id" %> - <%= link_to t("helpers.submit.cancel"), "#", class: "btn cancel cancel_edit_suggested_answer" %> -
    -<%end%> diff --git a/app/views/templates/_edit_phase.html.erb b/app/views/templates/_edit_phase.html.erb deleted file mode 100644 index ace20c9..0000000 --- a/app/views/templates/_edit_phase.html.erb +++ /dev/null @@ -1,45 +0,0 @@ - - -<%= form_for(phase, url: admin_updatephase_template_path(phase.id), html: { method: :put}) do |f| %> - -

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

    -
    - <%= raw t('org_admin.templates.phase_details_text_html')%> -
    -
    -
    - - - - - - - - - - - - - - -
    <%= 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.phase_order_label') %><%= f.number_field :number, in: 0..5, class: "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_number_help_text') %>
    <%= t('org_admin.templates.desc_label') %> -
    - <%= text_area_tag("phase-desc", phase.description, class: "tinymce") %> -
    -
    - <%= link_to( image_tag('help_button.png'), '#', class: 'phase_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.phase_desc_help_text_html'))%> -
    -
    -
    - - -
    - <%= f.submit t('helpers.submit.save'), class: 'btn btn-primary' %> - <%= link_to t('helpers.submit.cancel'), admin_phase_template_path(phase), class: 'btn cancel' %> -
    - -<% end %> \ No newline at end of file diff --git a/app/views/templates/_edit_question.html.erb b/app/views/templates/_edit_question.html.erb deleted file mode 100644 index 8ea1271..0000000 --- a/app/views/templates/_edit_question.html.erb +++ /dev/null @@ -1,174 +0,0 @@ - - -<%= form_for(question, url: admin_updatequestion_template_path(question), html: { method: :put}) do |f| %> -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    <%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, in: 1..50, class: "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %> -
    -
    <%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, rows: "5" %> -
    -
    <%= t("org_admin.questions.answer_format_label")%>
    -
    - <%= f.hidden_field :id,{ class: "quest_id" } %> - <%= f.select :question_format_id, - options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, question.question_format_id), - {}, id: "#{question.id}-select-format"%> -
    -
    - <%= link_to( image_tag("help_button.png"), "#", class: "question_format_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> -
    - -
    - - - -
    - - -
    - - -
    - -
    -
    -
    -
    <%= t("org_admin.questions.suggested_or_example_answer_label")%>
    - <% suggested_answer = question.suggested_answers.find_by_org_id(current_user.org.id) %> - <% if suggested_answer.nil? %> - <% suggested_answer = question.suggested_answers.build %> - <% end %> - <%= f.fields_for :suggested_answers, suggested_answer do |s|%> - <%= s.hidden_field :org_id, value: current_user.org.id %> -
      -
    • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
    • -
    • <%= s.text_area :text, rows: 5 %> -
    • -
    - <% end %> -
    -
    - <%= link_to( image_tag("help_button.png"), "#", class: "suggested_answer_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> -
    -
    -
    -
    <%= t("org_admin.questions.guidance_label")%>
    - <%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %> -
    -
    - <%= link_to( image_tag("help_button.png"), "#", class: "question_guidance_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> -
    -
    -
    -
    <%= t("org_admin.questions.themes_label")%>
    - <%= f.collection_select(:theme_ids, - Theme.all.order("title"), - :id, :title, {prompt: false, include_blank: "None"}, {multiple: true})%> -
    -
    - <%= link_to( image_tag("help_button.png"), "#", class: "question_themes_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> -
    -
    -
    - -
    - <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> - <% if !question.section.phase.template.published? %> - <%= link_to t("helpers.submit.delete"), 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 %> - <%= hidden_field_tag :question_id, question.id, class: "question_id" %> - <%= link_to t("helpers.submit.cancel"), "#", class: "btn cancel cancel_edit_question" %> -
    -
    - - - -<%= render partial: "guidance_display", locals: {question: question} %> -<% end %> diff --git a/app/views/templates/_edit_section.html.erb b/app/views/templates/_edit_section.html.erb deleted file mode 100644 index eb4abed..0000000 --- a/app/views/templates/_edit_section.html.erb +++ /dev/null @@ -1,116 +0,0 @@ - - - -<%= form_for(section, url: admin_updatesection_template_path(section, phase: phase, edit: edit), html: { method: :put}) do |s| %> - <% if @open && @section_id == section.id then%> - <% toggle = 'accordion-body section-collapse in collapse'%> - <% else %> - <% toggle = 'accordion-body collapse section-collapse' %> - <% end %> - - <% if @new_sec %> - <% toggle = 'accordion-body section-collapse in collapse'%> - <% end %> - -
    -
    -
    -
    - <%= s.text_field :title, as: :string, class: 'text_field', placeholder: t('org_admin.templates.section_title_placeholder') %> - -
    -
    - -
    - - -
    -
    - - - - - - - - - -
    <%= t('org_admin.templates.phase_order_label') %><%= s.number_field :number, in: 1..15, class: "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.section_number_help_text') %>
    <%= t('org_admin.templates.desc_label') %> -
    - <%= text_area_tag("section-desc-#{section.id}", section.description , class: "tinymce") %> -
    -
    - <%= link_to( image_tag('help_button.png'), '#', class: 'section_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.section_desc_help_text_html'))%> -
    -
    - -
    - <%= s.submit t('helpers.submit.save'), class: 'btn btn-primary' %> - <% if section.modifiable %> - <%= link_to t("helpers.submit.delete"), admin_destroysection_template_path(section_id: section.id), - confirm: t("org_admin.templates.section_delete_message", section_title: section.title ), method: :delete, class: "btn btn-primary"%> - <% end %> - <%= link_to t('helpers.submit.cancel'), :back, class: 'btn cancel' %> -
    -<% end %> -
    - <% @questions = section.questions.order("number")%> - <% if @questions.length > 0 %> - <% question_left = @questions.length %> - <% @questions.each do |question| %> -
    -
    "> - - <%= render partial: 'show_question', locals: {question: question} %> -
    - - -
    - - <% if question_left.to_i > 1 %> -
    - <% else %> -
    - <% end %> - <% question_left = question_left - 1 %> - - <% end %> - <% end %> - - - <% if section.modifiable %> - - <% if @questions.length != 0 %> -
    - <% end%> - - - - -
    -
    - <%= hidden_field_tag :section_id, section.id, class: "section_id" %> - <%= link_to t("org_admin.add_question_label"), '#', class: "btn btn-primary add_question_button" %> -
    -
    - <% end %> - -
    -
    -
    -
    diff --git a/app/views/templates/_edit_suggested_answer.html.erb b/app/views/templates/_edit_suggested_answer.html.erb deleted file mode 100644 index fe20950..0000000 --- a/app/views/templates/_edit_suggested_answer.html.erb +++ /dev/null @@ -1,26 +0,0 @@ - -<%= form_for(suggested_answer, url: admin_updatesuggestedanswer_template_path(suggested_answer), html: { method: :put}) do |f| %> - <%= f.hidden_field :org_id, value: current_user.org_id %> - - - - - - -
    <%= t('org_admin.questions.suggested_or_example_answer_label')%> -
      -
    • <%= f.select :is_example, {t('org_admin.questions.example_answer_label') => true, t('org_admin.questions.suggested_answer_label') => false} %>
    • -
    • <%= f.text_area :text, rows: 5 %>
    • -
    -
    -
    - - -
    - <%= f.submit t('helpers.submit.save'), class: 'btn btn-primary' %> - <%= link_to t("helpers.submit.delete"), admin_destroysuggestedanswer_template_path(suggested_answer: suggested_answer.id), - confirm: t("org_admin.questions.delete_suggested_answer_message", question_text: question.text ), method: :delete, class: "btn btn-primary"%> - <%= hidden_field_tag :question_id, question.id, class: "question_id" %> - <%= link_to t('helpers.submit.cancel'), '#', class: 'btn cancel cancel_edit_suggested_answer' %> -
    -<% end %> diff --git a/app/views/templates/_guidance_display.html.erb b/app/views/templates/_guidance_display.html.erb deleted file mode 100644 index 9a0755a..0000000 --- a/app/views/templates/_guidance_display.html.erb +++ /dev/null @@ -1,36 +0,0 @@ - - -
    -
    - <% if !question.guidance.nil? && question.guidance != "" %> - - <% end %> - - <% question.guidance_for_org(current_user.org).each_pair do |title,guidance| %> -
    - -
    -
    <%= raw guidance.text %>
    -
    -
    - <% end %> -
    - -
    \ No newline at end of file diff --git a/app/views/templates/_option_fields.html.erb b/app/views/templates/_option_fields.html.erb deleted file mode 100644 index 5182510..0000000 --- a/app/views/templates/_option_fields.html.erb +++ /dev/null @@ -1,7 +0,0 @@ - - - <%= 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 deleted file mode 100644 index 37d3fb1..0000000 --- a/app/views/templates/_preview_question.html.erb +++ /dev/null @@ -1,124 +0,0 @@ - - -
    - - - <% 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}%> diff --git a/app/views/templates/_show_phase.html.erb b/app/views/templates/_show_phase.html.erb deleted file mode 100644 index f110902..0000000 --- a/app/views/templates/_show_phase.html.erb +++ /dev/null @@ -1,37 +0,0 @@ - - -

    - <%= 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.template.org.not_funder %> -
    - <%= 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 %>
    -
    diff --git a/app/views/templates/_show_phases_sections.html.erb b/app/views/templates/_show_phases_sections.html.erb index 606aabb..33f29df 100644 --- a/app/views/templates/_show_phases_sections.html.erb +++ b/app/views/templates/_show_phases_sections.html.erb @@ -12,10 +12,10 @@ <% if phase.sections.length > 0 %> - <%= link_to t("helpers.preview"), admin_previewphase_template_path(id: phase.id), class: 'btn btn-primary'%> + <%= link_to t("helpers.preview"), admin_preview_phase_path(id: phase.id), class: 'btn btn-primary'%> <% end %> <% if !phase.template.published? %> - <%= link_to t("helpers.submit.delete"), admin_destroyphase_template_path(phase_id: phase.id), + <%= link_to t("helpers.submit.delete"), admin_destroy_phase_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.modifiable %> @@ -23,7 +23,7 @@ <% else %> <% b_label = t('org_admin.templates.edit_phase_label')%> <% end %> - <%= 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" %> + <%= link_to b_label, admin_show_phase_path(id: phase.id, edit: (b_label == t('org_admin.templates.edit_phase_label'))), class: "btn btn-primary" %>
    <% if phase.sections.any? %> diff --git a/app/views/templates/_show_question.html.erb b/app/views/templates/_show_question.html.erb deleted file mode 100644 index 8d8579c..0000000 --- a/app/views/templates/_show_question.html.erb +++ /dev/null @@ -1,148 +0,0 @@ - - -
    - - - - - - - - - - - - - - <% if q_format.title == t("helpers.text_field") || q_format.title == t("helpers.text_area") %> - <% if !question.default_value.nil? %> - - - - - <% end %> - <% end %> - - - - - - - - <% if question.section.phase.template.org.org_type != constant("organisation_types.funder") %> - <% suggested_answer = question.get_suggested_answer(current_user.org_id) %> - <% if !suggested_answer.nil? && suggested_answer.text != "" %> - - - - - <% end %> - <% end %> - - <% if !question.guidance.nil? %> - - - - - <% end %> - - <% themes_q = question.themes %> - <% if !themes_q.nil? %> - - - - - <% end %> -
    <%= t('org_admin.questions.question_number_label')%><%= question.number %>
    <%= t('org_admin.questions.question_text_label')%><%= raw question.text %> -
    -
    - <% 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") %> -
      - <% if question.question_options.is_a? QuestionOption %> -
    • - <%= question.question_options.text %>
    • - <% else %> - <% if !question.question_options.to_a.nil? %> - <% question.question_options.to_a.sort_by{|op| op['number']}.each do |o| %> -
    • - <%= o.text %>
    • - <% end %> - <% end %> - <% end %> -
    - <% end %> -
    -
    <%= t('org_admin.questions.default_value_label')%><%= raw question.default_value %>
    <%= t('org_admin.questions.answer_format_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.option_comment_display == true %> - <%= t("org_admin.questions.option_comment_display")%> - <% else %> - <%= t("org_admin.questions.option_comment_hide")%> - <% end %> - <% end %> -
    -
    - <% 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 %>
    <%= t('org_admin.questions.guidance_label')%><%= raw question.guidance %>
    <%= t('org_admin.questions.themes_label')%><% i = 1%> - <% themes_q.each do |t|%> - <%= t.title %> - <% if themes_q.count > i %> - , - <% i +=1 %> - <% end %> - <% end %> -
    -
    - - <% if !question.modifiable %> - <% 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} %> -
    - - <% end %> - - <% end %> - -
    - - <% if (@edit && question.section.modifiable) || question.section.phase.template.customization_of.present? %> -
    - <%= 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"%> - <% end %> -
    - <% 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"%> -
    -
    - <% end %> - <% end %> -
    -
    - - - -<%= 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 deleted file mode 100644 index 1544b83..0000000 --- a/app/views/templates/_show_section.html.erb +++ /dev/null @@ -1,53 +0,0 @@ - -<% 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 = section.questions.order("number") %> - <% if section_questions.present? %> - <% last_question_id = section_questions.last.id %> - <% section_questions.each do |question| %> -
    - -
    "> - - <%= render partial: 'show_question', locals: {question: question} %> -
    - <% if section.phase.template.customization_of.present? %> - - <% end %> -
    - - <% if last_question_id == question.id %> -
    - <% else %> -
    - <% end %> - <% end %> - <% end %> -
    -
    -
    diff --git a/app/views/templates/_show_suggested_answer.html.erb b/app/views/templates/_show_suggested_answer.html.erb deleted file mode 100644 index c760bc9..0000000 --- a/app/views/templates/_show_suggested_answer.html.erb +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -
    - <% 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 %>
    -
    - -
    - <%= 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/admin_addphase.html.erb b/app/views/templates/admin_addphase.html.erb deleted file mode 100644 index 02c62ad..0000000 --- a/app/views/templates/admin_addphase.html.erb +++ /dev/null @@ -1,75 +0,0 @@ -<%- model_class = Phase -%> -<%= stylesheet_link_tag "admin" %> -<% javascript "admin.js" %> - -

    - <%= @template.title %> - -
    - <%= link_to t("org_admin.templates.view_all_templates"), - admin_index_template_path, - class: "btn btn-primary" %> -
    -

    - -
    - - -<%= render partial: "admin_nav_tabs", locals: {template: @template, active: "add_plan"} %> - - -
    -
    - - -
    -
    - - - <%= form_for :phase, url: { action: "admin_createphase"} do |f| %> -

    - <%= t("org_admin.templates.phase_details_label")%> -

    - <%= raw t("org_admin.templates.phase_new_text_html")%> -
    -
    - <%= f.hidden_field :template_id, value: @template.id%> - - - - - - - - - - - - - -
    <%= 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.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") %>
    <%= t("org_admin.templates.desc_label") %> -
    - <%= text_area_tag("phase-desc","" , class: "tinymce") %> -
    -
    - <%= link_to( image_tag("help_button.png"), "#", class: "phase_desc_popover", rel: "popover", "data-html" => "true", "data-content" => t("org_admin.templates.phase_desc_help_text_html"))%> -
    -
    -
    -
    - - -
    - <%= f.submit t("helpers.submit.save"), class: "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), admin_template_template_path(@template), class: "btn cancel" %> -
    - - <%end%> -
    -
    -
    -
    - -<%= tinymce content_css: asset_path("application.css") %> \ No newline at end of file diff --git a/app/views/templates/admin_phase.html.erb b/app/views/templates/admin_phase.html.erb deleted file mode 100644 index 26c154e..0000000 --- a/app/views/templates/admin_phase.html.erb +++ /dev/null @@ -1,69 +0,0 @@ -<%- model_class = Phase -%> -<%= stylesheet_link_tag "admin" %> -<% javascript 'admin.js' %> - -<%= tinymce content_css: asset_path('application.css') %> - -

    - <%= @phase.template.title %> - -
    - <%= link_to t("org_admin.templates.view_all_templates"), - admin_index_template_path, - class: 'btn btn-primary' %> -
    -

    - -
    - - -<%= render partial: "admin_nav_tabs", locals: {template: @phase.template, active: @phase.id} %> - - -
    -
    - - -
    -
    - - -
    - <%= render partial: "show_phase", locals: {phase: @phase}%> -
    - <% if @phase.modifiable && @edit %> - - <% end %> -
    -
    - - - <% @sections.order("number ASC").each do |section| %> - <% if @edit && section.modifiable %> - <%= render partial: 'edit_section', locals: {section: section, edit: @edit, phase: @phase} %> - <% else %> - <%= render partial: 'show_section', locals: {section: section}%> - <% end %> - <% end %> - -
    -
    - - -<% if @edit || @phase.template.customization_of.present? %> - - - - -
    -
    - <%= link_to t('org_admin.add_section_label'),'#', id: 'add_section_button', class: 'btn btn-primary' %> -
    -
    -<% end %> - - diff --git a/app/views/templates/admin_previewphase.html.erb b/app/views/templates/admin_previewphase.html.erb deleted file mode 100644 index 58de962..0000000 --- a/app/views/templates/admin_previewphase.html.erb +++ /dev/null @@ -1,59 +0,0 @@ -<%- model_class = Phase -%> -<%= stylesheet_link_tag "admin" %> - -

    - <%= @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: {template: @template, active: @phase.id} %> - - -
    -
    - <% 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 12edc0c..7316afa 100644 --- a/app/views/templates/admin_template.html.erb +++ b/app/views/templates/admin_template.html.erb @@ -14,18 +14,18 @@
    -<%= render partial: "admin_nav_tabs", locals: {template: @template, active: "show_template"} %> +<%= render partial: "templates/admin_nav_tabs", locals: {template: @template, active: "show_template"} %>
    <% if @template.org.funder? || current_user.org.funder? then %> <%end%>
    - <%= render partial: "show_template", locals: {template: @template}%> + <%= render partial: "templates/show_template", locals: {template: @template}%>
    @@ -33,7 +33,7 @@ <% if @template.phases.count == 1 then %> <% @template.phases.each do |phase| %> - <%= render partial: 'show_phases_sections', locals: {phase: phase}%> + <%= render partial: 'templates/show_phases_sections', locals: {phase: phase}%> <%end%> <%else%> <% @template.phases.order(:number).each do |phase| %> @@ -48,7 +48,7 @@
    - <%= render partial: 'show_phases_sections', locals: {phase: phase}%> + <%= render partial: 'templates/show_phases_sections', locals: {phase: phase}%>
    diff --git a/config/routes.rb b/config/routes.rb index 1eff413..e29b441 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,28 +97,45 @@ get 'admin_index' get 'admin_template' get 'admin_new' - get 'admin_addphase' - get 'admin_phase' - get 'admin_previewphase' - get 'admin_cloneversion' get 'admin_template_history' delete 'admin_destroy' - delete 'admin_destroyversion' - delete 'admin_destroyphase' - delete 'admin_destroysection' - delete 'admin_destroyquestion' - delete 'admin_destroysuggestedanswer' post 'admin_create' - post 'admin_createphase' - post 'admin_createsection' - post 'admin_createquestion' - post 'admin_createsuggestedanswer' put 'admin_update' - put 'admin_updatephase' - put 'admin_updateversion' - put 'admin_updatesection' - put 'admin_updatequestion' - put 'admin_updatesuggestedanswer' + end + end + + resources :phases, path: 'org/admin/templates/phases', only: [] do + member do + get 'admin_show' + get 'admin_preview' + get 'admin_add' + put 'admin_update' + post 'admin_create' + delete 'admin_destroy' + end + end + + resources :sections, path: 'org/admin/templates/sections', only: [] do + member do + post 'admin_create' + put 'admin_update' + delete 'admin_destroy' + end + end + + resources :questions, path: 'org/admin/templates/questions', only: [] do + member do + post 'admin_create' + put 'admin_update' + delete 'admin_destroy' + end + end + + resources :suggested_answers, path: 'org/admin/templates/suggested_answers', only: [] do + member do + post 'admin_create' + put 'admin_update' + delete 'admin_destroy' end end