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 @@ + +
| <%= 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("org_admin.questions.suggested_or_example_answer_label")%> | +
+
|
+
| <%= t('org_admin.templates.title_label') %> | +<%= f.text_field :title, + as: :string, + class: 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %> | +
| <%= t('org_admin.templates.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'))%>
+
+ |
+
| <%= t('org_admin.templates.title_label') %> | +<%= @phase.title %> | +
| <%= t('org_admin.templates.phase_order_label') %> | +<%= @phase.number %> | +
| <%= t('org_admin.templates.desc_label') %> | +<%= raw @phase.description %> | +
| <%= t("org_admin.templates.title_label") %> | +<%= 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"))%>
+
+
+ |
+
| <%= 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 %>
+
+
+ <%= 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"))%>
+
+
+
+ |
+
| <%= 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 %>
+
+
+ <%= 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"))%>
+
+ |
+
| <%= 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") %>
+
+ <% 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 %> + | +
| <%= 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"))%>
+
+ |
+
| <%= 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'))%>
+
+ |
+
| <%= t("org_admin.questions.suggested_or_example_answer_label")%> | +
+
|
+
| <%= t('org_admin.questions.suggested_or_example_answer_label')%> | +
+
|
+
| + <% 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 %> | +
| <%= 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("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 %>
-
-
- <%= 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"))%>
-
-
-
- |
-
| <%= 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"))%>
-
- |
-
| <%= t("org_admin.questions.suggested_or_example_answer_label")%> | -
-
|
-
| <%= t("org_admin.questions.suggested_or_example_answer_label")%> | -
-
|
-
| <%= t('org_admin.templates.title_label') %> | -<%= f.text_field :title, - as: :string, - class: 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %> | -
| <%= t('org_admin.templates.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'))%>
-
- |
-
| <%= 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 %>
-
-
- <%= 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"))%>
-
- |
-
| <%= 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'))%>
-
- |
-
| <%= t('org_admin.questions.suggested_or_example_answer_label')%> | -
-
|
-
| <%= t('org_admin.templates.title_label') %> | -<%= @phase.title %> | -
| <%= t('org_admin.templates.phase_order_label') %> | -<%= @phase.number %> | -
| <%= t('org_admin.templates.desc_label') %> | -<%= raw @phase.description %> | -
| <%= t('org_admin.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") %>
-
- <% 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 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 %> | -
| <%= 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"))%>
-
-
- |
-