diff --git a/app/controllers/dmptemplates_controller.rb b/app/controllers/dmptemplates_controller.rb deleted file mode 100644 index 9c7f757..0000000 --- a/app/controllers/dmptemplates_controller.rb +++ /dev/null @@ -1,450 +0,0 @@ -# [+Project:+] DMPRoadmap -# [+Description:+] This controller is responsible for all the actions in the admin interface under templates (e.g. phases, versions, sections, questions, suggested answer) (index; show; create; edit; delete) -# [+Copyright:+] Digital Curation Centre and University of California Curation Center - -class DmptemplatesController < ApplicationController - after_action :verify_authorized - - # GET /dmptemplates - def admin_index - authorize Dmptemplate - #institutional templates - @dmptemplates_own = Dmptemplate.own_institutional_templates(current_user.organisation_id) - #funders templates - @dmptemplates_funders = Dmptemplate.funders_templates - respond_to do |format| - format.html # index.html.erb - end - end - - # GET /dmptemplates/1 - def admin_template - @dmptemplate = Dmptemplate.find(params[:id]) - authorize @dmptemplate - respond_to do |format| - format.html # show.html.erb - end - end - - - - # PUT /dmptemplates/1 - def admin_update - @dmptemplate = Dmptemplate.find(params[:id]) - authorize @dmptemplate - @dmptemplate.description = params["template-desc"] - respond_to do |format| - if @dmptemplate.update_attributes(params[:dmptemplate]) - format.html { redirect_to admin_template_dmptemplate_path(params[:dmptemplate]), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "edit" } - end - end - end - - - # GET /dmptemplates/new - def admin_new - @dmptemplate = Dmptemplate.new - authorize @dmptemplate - respond_to do |format| - format.html # new.html.erb - end - end - - # POST /dmptemplates - def admin_create - @dmptemplate = Dmptemplate.new(params[:dmptemplate]) - @dmptemplate.organisation_id = current_user.organisation.id - @dmptemplate.description = params['template-desc'] - authorize @dmptemplate - respond_to do |format| - if @dmptemplate.save - format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.created_message') } - else - format.html { render action: "admin_new" } - end - end - end - - - - # DELETE /dmptemplates/1 - def admin_destroy - @dmptemplate = Dmptemplate.find(params[:id]) - authorize @dmptemplate - @dmptemplate.destroy - respond_to do |format| - format.html { redirect_to admin_index_dmptemplate_path } - end - end - - - - # PHASES - - #show and edit a phase of the template - def admin_phase - @phase = Phase.find(params[:id]) - authorize @phase.dmptemplate - if !params.has_key?(:version_id) then - @edit = 'false' - #check for the most recent published version, if none is available then return the most recent one - versions = @phase.versions.where('published = ?', true).order('updated_at DESC') - if versions.any?() then - @version = versions.first - else - @version = @phase.versions.order('updated_at DESC').first - end - # When the version_id is passed as an argument - else - @edit = params[:edit] - @version = Version.find(params[:version_id]) - end - #verify if there are any sections if not create one - @sections = @version.sections - if !@sections.any?() || @sections.count == 0 then - @section = @version.sections.build - @section.title = '' - @section.version_id = params[:version_id] - @section.number = 1 - @section.organisation_id = current_user.organisation.id - @section.published = 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) then - @open = true - @section_id = params[:section_id].to_i - end - if params.has_key?(:question_id) then - @question_id = params[:question_id].to_i - end - respond_to do |format| - format.html - end - end - - - #preview a phase - def admin_previewphase - @version = Version.find(params[:id]) - authorize @version.phase.dmptemplate - respond_to do |format| - format.html - end - end - - - #add a new phase to a template - def admin_addphase - @dmptemplate = Dmptemplate.find(params[:id]) - @phase = Phase.new - authorize @dmptemplate - if @dmptemplate.phases.count == 0 then - @phase.number = '1' - else - @phase.number = @dmptemplate.phases.count + 1 - end - respond_to do |format| - format.html - end - end - - - #create a phase - def admin_createphase - @phase = Phase.new(params[:phase]) - authorize @phase.dmptemplate - @phase.description = params["phase-desc"] - @version = @phase.versions.build - @version.title = "#{@phase.title} v.1" - @version.phase_id = @phase.id - @version.number = 1 - @version.published = false - respond_to do |format| - if @phase.save - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - - #update a phase of a template - def admin_updatephase - @phase = Phase.find(params[:id]) - authorize @phase.dmptemplate - @phase.description = params["phase-desc"] - respond_to do |format| - if @phase.update_attributes(params[:phase]) - format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #delete a version, sections and questions - def admin_destroyphase - @phase = Phase.find(params[:phase_id]) - authorize @phase.dmptemplate - @dmptemplate = @phase.dmptemplate - @phase.destroy - respond_to do |format| - format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.destroyed_message') } - end - end - -# VERSIONS - - #update a version of a template - def admin_updateversion - @version = Version.find(params[:id]) - authorize @version.phase.dmptemplate - @version.description = params["version-desc"] - @phase = @version.phase - if @version.published && !@phase.dmptemplate.published then - @phase.dmptemplate.published = true - end - if @version.published == true then - @all_versions = @phase.versions.where('published = ?', true) - @all_versions.each do |v| - if v.id != @version.id && v.published == true then - v.published = false - v.save - end - end - end - respond_to do |format| - if @version.update_attributes(params[:version]) - format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'false'), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #clone a version of a template - def admin_cloneversion - @old_version = Version.find(params[:version_id]) - authorize @old_version.phase.dmptemplate - @version = @old_version.amoeba_dup - @phase = @version.phase - respond_to do |format| - if @version.save - format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #delete a version, sections and questions - def admin_destroyversion - @version = Version.find(params[:version_id]) - authorize @version.phase.dmptemplate - @phase = @version.phase - @version.destroy - respond_to do |format| - format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.destroyed_message') } - end - end - - -# SECTIONS - #create a section - def admin_createsection - @section = Section.new(params[:section]) - authorize @section.version.phase.dmptemplate - @section.description = params["section-desc"] - respond_to do |format| - if @section.save - format.html { redirect_to admin_phase_dmptemplate_path(:id => @section.version.phase_id, :version_id => @section.version_id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - - #update a section of a template - def admin_updatesection - @section = Section.find(params[:id]) - authorize @section.version.phase.dmptemplate - @section.description = params["section-desc-#{params[:id]}"] - @version = @section.version - @phase = @version.phase - respond_to do |format| - if @section.update_attributes(params[:section]) - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id , :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - - #delete a section and questions - def admin_destroysection - @section = Section.find(params[:section_id]) - authorize @section.version.phase.dmptemplate - @version = @section.version - @phase = @version.phase - @section.destroy - respond_to do |format| - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') } - end - end - - -# QUESTIONS - - #create a question - def admin_createquestion - @question = Question.new(params[:question]) - authorize @question.section.version.phase.dmptemplate - @question.guidance = params["new-question-guidance"] - @question.default_value = params["new-question-default-value"] - respond_to do |format| - if @question.save - format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #update a question of a template - def admin_updatequestion - @question = Question.find(params[:id]) - authorize @question.section.version.phase.dmptemplate - @question.guidance = params["question-guidance-#{params[:id]}"] - @question.default_value = params["question-default-value-#{params[:id]}"] - @section = @question.section - @version = @section.version - @phase = @version.phase - respond_to do |format| - if @question.update_attributes(params[:question]) - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #delete a version, sections and questions - def admin_destroyquestion - @question = Question.find(params[:question_id]) - authorize @question.section.version.phase.dmptemplate - @section = @question.section - @version = @section.version - @phase = @version.phase - @question.destroy - respond_to do |format| - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') } - end - end - - - #SUGGESTED ANSWERS - #create suggested answers - def admin_createsuggestedanswer - @suggested_answer = SuggestedAnswer.new(params[:suggested_answer]) - authorize @suggested_answer.question.section.version.phase.dmptemplate - respond_to do |format| - if @suggested_answer.save - format.html { redirect_to admin_phase_dmptemplate_path(:id => @suggested_answer.question.section.version.phase_id, :version_id => @suggested_answer.question.section.version_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 - format.html { render action: "admin_phase" } - end - end - end - - - #update a suggested answer of a template - def admin_updatesuggestedanswer - @suggested_answer = SuggestedAnswer.find(params[:id]) - authorize @suggested_answer.question.section.version.phase.dmptemplate - @question = @suggested_answer.question - @section = @question.section - @version = @section.version - @phase = @version.phase - - respond_to do |format| - if @suggested_answer.update_attributes(params[:suggested_answer]) - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #delete a suggested answer - def admin_destroysuggestedanswer - @suggested_answer = SuggestedAnswer.find(params[:suggested_answer]) - authorize @suggested_answer.question.section.version.phase.dmptemplate - @question = @suggested_answer.question - @section = @question.section - @version = @section.version - @phase = @version.phase - @suggested_answer.destroy - respond_to do |format| - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') } - end - end - -# GUIDANCES - - #create a guidance - def admin_createguidance - @question = Question.find(params[:question][:id]) - authorize @question.section.version.phase.dmptemplate - @guidance = Guidance.new(params[:guidance]) - @guidance.question_id = @question.id - #@question.guidance = params["new-question-guidance"] - #@question.default_value = params["new-question-default-value"] - respond_to do |format| - if @guidance.save - format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #update a guidance of a template - def admin_updateguidance - @question = Question.find(params[:id]) - authorize @question.section.version.phase.dmptemplate - @question.guidance = params["question-guidance-#{params[:id]}"] - @question.default_value = params["question-default-value-#{params[:id]}"] - @section = @question.section - @version = @section.version - @phase = @version.phase - respond_to do |format| - if @question.update_attributes(params[:question]) - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "admin_phase" } - end - end - end - - #delete a version, sections and guidance - def admin_destroyguidance - @question = Question.find(params[:question_id]) - authorize @question.section.version.phase.dmptemplate - @section = @question.section - @version = @section.version - @phase = @version.phase - @question.destroy - respond_to do |format| - format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') } - end - end - - -end \ No newline at end of file diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb new file mode 100644 index 0000000..9c7f757 --- /dev/null +++ b/app/controllers/templates_controller.rb @@ -0,0 +1,450 @@ +# [+Project:+] DMPRoadmap +# [+Description:+] This controller is responsible for all the actions in the admin interface under templates (e.g. phases, versions, sections, questions, suggested answer) (index; show; create; edit; delete) +# [+Copyright:+] Digital Curation Centre and University of California Curation Center + +class DmptemplatesController < ApplicationController + after_action :verify_authorized + + # GET /dmptemplates + def admin_index + authorize Dmptemplate + #institutional templates + @dmptemplates_own = Dmptemplate.own_institutional_templates(current_user.organisation_id) + #funders templates + @dmptemplates_funders = Dmptemplate.funders_templates + respond_to do |format| + format.html # index.html.erb + end + end + + # GET /dmptemplates/1 + def admin_template + @dmptemplate = Dmptemplate.find(params[:id]) + authorize @dmptemplate + respond_to do |format| + format.html # show.html.erb + end + end + + + + # PUT /dmptemplates/1 + def admin_update + @dmptemplate = Dmptemplate.find(params[:id]) + authorize @dmptemplate + @dmptemplate.description = params["template-desc"] + respond_to do |format| + if @dmptemplate.update_attributes(params[:dmptemplate]) + format.html { redirect_to admin_template_dmptemplate_path(params[:dmptemplate]), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "edit" } + end + end + end + + + # GET /dmptemplates/new + def admin_new + @dmptemplate = Dmptemplate.new + authorize @dmptemplate + respond_to do |format| + format.html # new.html.erb + end + end + + # POST /dmptemplates + def admin_create + @dmptemplate = Dmptemplate.new(params[:dmptemplate]) + @dmptemplate.organisation_id = current_user.organisation.id + @dmptemplate.description = params['template-desc'] + authorize @dmptemplate + respond_to do |format| + if @dmptemplate.save + format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.created_message') } + else + format.html { render action: "admin_new" } + end + end + end + + + + # DELETE /dmptemplates/1 + def admin_destroy + @dmptemplate = Dmptemplate.find(params[:id]) + authorize @dmptemplate + @dmptemplate.destroy + respond_to do |format| + format.html { redirect_to admin_index_dmptemplate_path } + end + end + + + + # PHASES + + #show and edit a phase of the template + def admin_phase + @phase = Phase.find(params[:id]) + authorize @phase.dmptemplate + if !params.has_key?(:version_id) then + @edit = 'false' + #check for the most recent published version, if none is available then return the most recent one + versions = @phase.versions.where('published = ?', true).order('updated_at DESC') + if versions.any?() then + @version = versions.first + else + @version = @phase.versions.order('updated_at DESC').first + end + # When the version_id is passed as an argument + else + @edit = params[:edit] + @version = Version.find(params[:version_id]) + end + #verify if there are any sections if not create one + @sections = @version.sections + if !@sections.any?() || @sections.count == 0 then + @section = @version.sections.build + @section.title = '' + @section.version_id = params[:version_id] + @section.number = 1 + @section.organisation_id = current_user.organisation.id + @section.published = 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) then + @open = true + @section_id = params[:section_id].to_i + end + if params.has_key?(:question_id) then + @question_id = params[:question_id].to_i + end + respond_to do |format| + format.html + end + end + + + #preview a phase + def admin_previewphase + @version = Version.find(params[:id]) + authorize @version.phase.dmptemplate + respond_to do |format| + format.html + end + end + + + #add a new phase to a template + def admin_addphase + @dmptemplate = Dmptemplate.find(params[:id]) + @phase = Phase.new + authorize @dmptemplate + if @dmptemplate.phases.count == 0 then + @phase.number = '1' + else + @phase.number = @dmptemplate.phases.count + 1 + end + respond_to do |format| + format.html + end + end + + + #create a phase + def admin_createphase + @phase = Phase.new(params[:phase]) + authorize @phase.dmptemplate + @phase.description = params["phase-desc"] + @version = @phase.versions.build + @version.title = "#{@phase.title} v.1" + @version.phase_id = @phase.id + @version.number = 1 + @version.published = false + respond_to do |format| + if @phase.save + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + + #update a phase of a template + def admin_updatephase + @phase = Phase.find(params[:id]) + authorize @phase.dmptemplate + @phase.description = params["phase-desc"] + respond_to do |format| + if @phase.update_attributes(params[:phase]) + format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #delete a version, sections and questions + def admin_destroyphase + @phase = Phase.find(params[:phase_id]) + authorize @phase.dmptemplate + @dmptemplate = @phase.dmptemplate + @phase.destroy + respond_to do |format| + format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.destroyed_message') } + end + end + +# VERSIONS + + #update a version of a template + def admin_updateversion + @version = Version.find(params[:id]) + authorize @version.phase.dmptemplate + @version.description = params["version-desc"] + @phase = @version.phase + if @version.published && !@phase.dmptemplate.published then + @phase.dmptemplate.published = true + end + if @version.published == true then + @all_versions = @phase.versions.where('published = ?', true) + @all_versions.each do |v| + if v.id != @version.id && v.published == true then + v.published = false + v.save + end + end + end + respond_to do |format| + if @version.update_attributes(params[:version]) + format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'false'), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #clone a version of a template + def admin_cloneversion + @old_version = Version.find(params[:version_id]) + authorize @old_version.phase.dmptemplate + @version = @old_version.amoeba_dup + @phase = @version.phase + respond_to do |format| + if @version.save + format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #delete a version, sections and questions + def admin_destroyversion + @version = Version.find(params[:version_id]) + authorize @version.phase.dmptemplate + @phase = @version.phase + @version.destroy + respond_to do |format| + format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.destroyed_message') } + end + end + + +# SECTIONS + #create a section + def admin_createsection + @section = Section.new(params[:section]) + authorize @section.version.phase.dmptemplate + @section.description = params["section-desc"] + respond_to do |format| + if @section.save + format.html { redirect_to admin_phase_dmptemplate_path(:id => @section.version.phase_id, :version_id => @section.version_id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + + #update a section of a template + def admin_updatesection + @section = Section.find(params[:id]) + authorize @section.version.phase.dmptemplate + @section.description = params["section-desc-#{params[:id]}"] + @version = @section.version + @phase = @version.phase + respond_to do |format| + if @section.update_attributes(params[:section]) + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id , :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + + #delete a section and questions + def admin_destroysection + @section = Section.find(params[:section_id]) + authorize @section.version.phase.dmptemplate + @version = @section.version + @phase = @version.phase + @section.destroy + respond_to do |format| + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') } + end + end + + +# QUESTIONS + + #create a question + def admin_createquestion + @question = Question.new(params[:question]) + authorize @question.section.version.phase.dmptemplate + @question.guidance = params["new-question-guidance"] + @question.default_value = params["new-question-default-value"] + respond_to do |format| + if @question.save + format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #update a question of a template + def admin_updatequestion + @question = Question.find(params[:id]) + authorize @question.section.version.phase.dmptemplate + @question.guidance = params["question-guidance-#{params[:id]}"] + @question.default_value = params["question-default-value-#{params[:id]}"] + @section = @question.section + @version = @section.version + @phase = @version.phase + respond_to do |format| + if @question.update_attributes(params[:question]) + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #delete a version, sections and questions + def admin_destroyquestion + @question = Question.find(params[:question_id]) + authorize @question.section.version.phase.dmptemplate + @section = @question.section + @version = @section.version + @phase = @version.phase + @question.destroy + respond_to do |format| + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') } + end + end + + + #SUGGESTED ANSWERS + #create suggested answers + def admin_createsuggestedanswer + @suggested_answer = SuggestedAnswer.new(params[:suggested_answer]) + authorize @suggested_answer.question.section.version.phase.dmptemplate + respond_to do |format| + if @suggested_answer.save + format.html { redirect_to admin_phase_dmptemplate_path(:id => @suggested_answer.question.section.version.phase_id, :version_id => @suggested_answer.question.section.version_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 + format.html { render action: "admin_phase" } + end + end + end + + + #update a suggested answer of a template + def admin_updatesuggestedanswer + @suggested_answer = SuggestedAnswer.find(params[:id]) + authorize @suggested_answer.question.section.version.phase.dmptemplate + @question = @suggested_answer.question + @section = @question.section + @version = @section.version + @phase = @version.phase + + respond_to do |format| + if @suggested_answer.update_attributes(params[:suggested_answer]) + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #delete a suggested answer + def admin_destroysuggestedanswer + @suggested_answer = SuggestedAnswer.find(params[:suggested_answer]) + authorize @suggested_answer.question.section.version.phase.dmptemplate + @question = @suggested_answer.question + @section = @question.section + @version = @section.version + @phase = @version.phase + @suggested_answer.destroy + respond_to do |format| + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') } + end + end + +# GUIDANCES + + #create a guidance + def admin_createguidance + @question = Question.find(params[:question][:id]) + authorize @question.section.version.phase.dmptemplate + @guidance = Guidance.new(params[:guidance]) + @guidance.question_id = @question.id + #@question.guidance = params["new-question-guidance"] + #@question.default_value = params["new-question-default-value"] + respond_to do |format| + if @guidance.save + format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #update a guidance of a template + def admin_updateguidance + @question = Question.find(params[:id]) + authorize @question.section.version.phase.dmptemplate + @question.guidance = params["question-guidance-#{params[:id]}"] + @question.default_value = params["question-default-value-#{params[:id]}"] + @section = @question.section + @version = @section.version + @phase = @version.phase + respond_to do |format| + if @question.update_attributes(params[:question]) + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') } + else + format.html { render action: "admin_phase" } + end + end + end + + #delete a version, sections and guidance + def admin_destroyguidance + @question = Question.find(params[:question_id]) + authorize @question.section.version.phase.dmptemplate + @section = @question.section + @version = @section.version + @phase = @version.phase + @question.destroy + respond_to do |format| + format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') } + end + end + + +end \ No newline at end of file diff --git a/app/policies/dmptemplate_policy.rb b/app/policies/dmptemplate_policy.rb deleted file mode 100644 index 3524c40..0000000 --- a/app/policies/dmptemplate_policy.rb +++ /dev/null @@ -1,124 +0,0 @@ -class TemplatePolicy < ApplicationPolicy - attr_reader :user, :template - - def initialize(user, template) - raise Pundit::NotAuthorizedError, "must be logged in" unless user - @user = user - @template = template - end - - def admin_index? - user.can_modify_templates? - end - - def admin_template? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_update? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_new? - user.can_modify_templates? - end - - def admin_create? - user.can_modify_templates? && (template.org_id == user.org_id) - end - - def admin_destroy? - 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 - scope.where(org_id: user.org_id) - end - end - -end \ No newline at end of file diff --git a/app/policies/template_policy.rb b/app/policies/template_policy.rb new file mode 100644 index 0000000..3524c40 --- /dev/null +++ b/app/policies/template_policy.rb @@ -0,0 +1,124 @@ +class TemplatePolicy < ApplicationPolicy + attr_reader :user, :template + + def initialize(user, template) + raise Pundit::NotAuthorizedError, "must be logged in" unless user + @user = user + @template = template + end + + def admin_index? + user.can_modify_templates? + end + + def admin_template? + user.can_modify_templates? && (template.org_id == user.org_id) + end + + def admin_update? + user.can_modify_templates? && (template.org_id == user.org_id) + end + + def admin_new? + user.can_modify_templates? + end + + def admin_create? + user.can_modify_templates? && (template.org_id == user.org_id) + end + + def admin_destroy? + 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 + scope.where(org_id: user.org_id) + end + end + +end \ No newline at end of file diff --git a/app/views/dmptemplates/_add_guidance.html.erb b/app/views/dmptemplates/_add_guidance.html.erb deleted file mode 100644 index de49775..0000000 --- a/app/views/dmptemplates/_add_guidance.html.erb +++ /dev/null @@ -1,93 +0,0 @@ - -
| <%= t("org_admin.guidance.text_label") %> | -
- <%= text_area_tag("guidance-text", "", class: "tinymce") %>
-
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_text_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.text_help_text_html"))%>
-
-
- |
-
| <%= t("org_admin.guidance.by_theme_or_by_question") %> | -
- <%= select_tag "g_options", options_for_select([[t("org_admin.guidance.by_themes_label"), 1],
- [t("org_admin.guidance.by_question_label"), 2]]) %>
-
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_apply_to_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.apply_to_help_text_html"))%>
-
-
-
-
- |
-
| <%= t("org_admin.guidance.published") %> | -
- <%= f.check_box :published , :as => :check_boxes%>
-
-
-
-
- |
-
| <%= t("org_admin.guidance.guidance_group_label") %> | -
- <%= f.collection_select(:guidance_group_ids,
- GuidanceGroup.where("organisation_id = ?", current_user.organisation_id).order("name ASC"),
- :id, :name, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => false})%>
-
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_group_select_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.guidance_group_select_help_text_html"))%>
-
-
-
- |
-
| <%= t("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 :organisation_id, :value => current_user.organisation.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_organisation_id(current_user.organisation.id) %>
- <% if suggested_answer.nil? then %>
- <% suggested_answer = question.suggested_answers.build %>
- <%end%>
- <%= f.fields_for :suggested_answers, suggested_answer do |s|%>
- <%= s.hidden_field :organisation_id, :value => current_user.organisation.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') %> | -<%= f.text_field :title, :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.title_help_text') %> | -
| <%= t('org_admin.templates.desc_label') %> | -
- <%= text_area_tag("template-desc", dmptemplate.description, class: "tinymce") %>
-
-
- <%= link_to( image_tag('help_button.png'), '#', :class => 'template_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.desc_help_text_html'))%>
-
- |
-
| <%= t('org_admin.templates.published_label') %> | -<%if dmptemplate.published? || dmptemplate.has_published_versions? then%> - <%= f.check_box :published, :as => :check_boxes %> - <%else%> - <%= t('org_admin.templates.cannot_publish')%> - <%end%> - | -
| <%= t('org_admin.templates.created') %> | -- <%= l dmptemplate.created_at.to_date, :formats => :short %> - | -
| <%= t('org_admin.templates.last_updated') %> | -- <%= l dmptemplate.updated_at.to_date, :formats => :short %> - | -
| <%= t('org_admin.templates.title_label') %> | -<%= f.text_field :title, :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %> | - -
| <%= t('org_admin.templates.desc_label') %> | -
- <%= text_area_tag("version-desc", version.description, class: "tinymce") %>
-
-
- <%= link_to( image_tag('help_button.png'), '#', :class => 'version_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.versions.desc_help_text_html'))%>
-
- |
-
| <%= t('org_admin.templates.published_label') %> | -<%= f.check_box :published, :as => :check_boxes %> | - -
| <%= 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 %> | -
<%= raw phase.description %>
-| <%= t('helpers.sections_label')%> | -<%= t('helpers.questions_label')%> | -
|---|---|
|
- <%= section.title %> - |
-
- <% if section.questions.any? %>
- <% questions = section.questions.order("number ASC") %>
-
|
-
| <%= 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") then%>
-
- <% 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") then%> - <% if question.option_comment_display == true then%> - <%= t("org_admin.questions.option_comment_display")%> - <%else%> - <%= t("org_admin.questions.option_comment_hide")%> - <%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.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 then%> - , - <% 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') %> | -<%= dmptemplate.title %> | -
| <%= t('org_admin.templates.desc_label') %> | -<% if !dmptemplate.description.nil? && dmptemplate.description != "" then %> - <%= raw dmptemplate.description %> - <%else%> - - - <%end%> - | -
| <%= t('org_admin.templates.published_label') %> | -<%if dmptemplate.published || dmptemplate.has_published_versions? then%> - <%= dmptemplate.published %> - <%else%> - <%= t('org_admin.templates.cannot_publish')%> - <%end%> - | -
| <%= t('org_admin.templates.created') %> | -<%= l dmptemplate.created_at.to_date, :formats => :short %> | -
| <%= t('org_admin.templates.last_updated') %> | -<%= l dmptemplate.updated_at.to_date, :formats => :short %> | -
| <%= t('org_admin.templates.title_label') %> | -<%= version.title %> | -
| <%= t('org_admin.templates.desc_label') %> | -<%= raw version.description %> | -
| <%= t('org_admin.templates.published_label') %> | -<%= version.published %> | -
| <%= t('org_admin.templates.created') %> | -- <%= l version.created_at.to_date, :formats => :short %> - | -
| <%= t('org_admin.templates.last_updated') %> | -- <%= l version.updated_at.to_date, :formats => :short %> - | -
- <%= t('org_admin.versions.versions_text_html')%> -
- - -| <%= t('org_admin.templates.title_label')%> | -<%= t('org_admin.templates.published_label')%> | -<%= t('org_admin.templates.created')%> | -<%= t('org_admin.templates.last_updated') %> | -<%= t('org_admin.templates.actions') %> | -
|---|---|---|---|---|
| - <%= v.title %> - | -- <%= v.published %> - | -- <%= l v.created_at.to_date, :formats => :short %> - | -- <%= l v.updated_at.to_date, :formats => :short %> - | -- <%= link_to t("helpers.view"), admin_phase_dmptemplate_path( :version_id => v.id, :id => phase.id , :edit => 'false'), :class => "dmp_table_link"%> - <% if v.published? then%> - - <%= t('org_admin.versions.edit_label')%> - - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> - <%else%> - <%= link_to t("org_admin.versions.edit_label"), admin_phase_dmptemplate_path(phase, :version_id => v.id, :edit => 'true'), :class => "dmp_table_link" %> - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> - <%#= link_to t("helpers.submit.delete"), admin_destroyversion_dmptemplate_path(:version_id => v.id, :phase => phase , :edit => 'false'), - :confirm => t("org_admin.versions.delete_message", :version_title => v.title ), :method => :delete, :class => "dmp_table_link"%> - <%end%> - | -
| <%= 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.templates.title_label') %> | -<%= t('org_admin.templates.desc_label') %> | -<%= t('org_admin.templates.published_label') %> | -<%= t('org_admin.templates.last_updated') %> | -<%= t('org_admin.templates.actions') %> | -
|---|---|---|---|---|
| - <%= org_template.title%> - | -- <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %> - | -- <%= org_template.published %> - | -- <% last_temp_updated = org_template.updated_at %> - <% org_template.phases.each do |phase|%> - <% if phase.versions.any? then%> - <% phase.versions.each do |version| %> - <% if org_template.updated_at.to_date < version.updated_at.to_date then %> - <% last_temp_updated = version.updated_at %> - <%end%> - <%end%> - <%end%> - <%end%> - <%= l last_temp_updated.to_date, :formats => :short %> - | -- <%if current_user.can_org_admin? then%> - <% b_label = t('helpers.submit.edit')%> - <%else%> - <% b_label = t('helpers.view')%> - <%end%> - <%= link_to b_label, admin_template_dmptemplate_path(org_template), :class => "dmp_table_link"%> - | -
| <%= t('org_admin.templates.title_label') %> | -<%= t('org_admin.templates.desc_label') %> | -<%= t('org_admin.templates.published_label') %> | -<%= t('org_admin.templates.last_updated') %> | -<%= t('org_admin.templates.actions') %> | -
|---|---|---|---|---|
| - <%= org_template.title%> - | -- <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %> - | -- <%if org_template.published? then %> - <%= org_template.published%> - <%else%> - <%= t("helpers.false_lowercase")%> - <%end%> - | -- <% last_updated = org_template.updated_at %> - <% org_template.phases.each do |phase|%> - <% if phase.versions.any? then%> - <% phase.versions.each do |version| %> - <% if org_template.updated_at.to_date < version.updated_at.to_date then %> - <% last_updated = version.updated_at %> - <%end%> - <%end%> - <%end%> - <%end%> - <%= l last_updated.to_date, :formats => :short %> - - | -- <%if current_user.can_org_admin? then%> - <% if org_template.org_type == constant("organisation_types.funder") then %> - <%if org_template.has_customisations?(current_user.organisation_id, org_template) then%> - <% b_label = t("org_admin.templates.edit_customisation")%> - <%else%> - <% b_label = t("org_admin.templates.customise")%> - <%end%> - <%else%> - <% b_label = t("helpers.submit.edit")%> - <%end%> - <%else%> - <% b_label = t("helpers.view")%> - <%end%> - <%= link_to b_label, admin_template_dmptemplate_path(org_template), :class => "dmp_table_link"%> - | -
| <%= t("org_admin.templates.title_label") %> | -<%= f.text_field :title, :as => :string, - :class => "text_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.title_help_text") %> | -
| <%= t("org_admin.templates.desc_label") %> | -
- <%= text_area_tag("template-desc", "", class: "tinymce") %>
-
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "template_desc_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.template_desc_help_text_html"))%>
-
- |
-
| <%= t("org_admin.guidance.text_label") %> | +
+ <%= text_area_tag("guidance-text", "", class: "tinymce") %>
+
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_text_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.text_help_text_html"))%>
+
+
+ |
+
| <%= t("org_admin.guidance.by_theme_or_by_question") %> | +
+ <%= select_tag "g_options", options_for_select([[t("org_admin.guidance.by_themes_label"), 1],
+ [t("org_admin.guidance.by_question_label"), 2]]) %>
+
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_apply_to_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.apply_to_help_text_html"))%>
+
+
+
+
+ |
+
| <%= t("org_admin.guidance.published") %> | +
+ <%= f.check_box :published , :as => :check_boxes%>
+
+
+
+
+ |
+
| <%= t("org_admin.guidance.guidance_group_label") %> | +
+ <%= f.collection_select(:guidance_group_ids,
+ GuidanceGroup.where("organisation_id = ?", current_user.organisation_id).order("name ASC"),
+ :id, :name, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => false})%>
+
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_group_select_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.guidance_group_select_help_text_html"))%>
+
+
+
+ |
+
| <%= t("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 :organisation_id, :value => current_user.organisation.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_organisation_id(current_user.organisation.id) %>
+ <% if suggested_answer.nil? then %>
+ <% suggested_answer = question.suggested_answers.build %>
+ <%end%>
+ <%= f.fields_for :suggested_answers, suggested_answer do |s|%>
+ <%= s.hidden_field :organisation_id, :value => current_user.organisation.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') %> | +<%= f.text_field :title, :as => :string, + :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.title_help_text') %> | +
| <%= t('org_admin.templates.desc_label') %> | +
+ <%= text_area_tag("template-desc", dmptemplate.description, class: "tinymce") %>
+
+
+ <%= link_to( image_tag('help_button.png'), '#', :class => 'template_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.desc_help_text_html'))%>
+
+ |
+
| <%= t('org_admin.templates.published_label') %> | +<%if dmptemplate.published? || dmptemplate.has_published_versions? then%> + <%= f.check_box :published, :as => :check_boxes %> + <%else%> + <%= t('org_admin.templates.cannot_publish')%> + <%end%> + | +
| <%= t('org_admin.templates.created') %> | ++ <%= l dmptemplate.created_at.to_date, :formats => :short %> + | +
| <%= t('org_admin.templates.last_updated') %> | ++ <%= l dmptemplate.updated_at.to_date, :formats => :short %> + | +
| <%= t('org_admin.templates.title_label') %> | +<%= f.text_field :title, :as => :string, + :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %> | + +
| <%= t('org_admin.templates.desc_label') %> | +
+ <%= text_area_tag("version-desc", version.description, class: "tinymce") %>
+
+
+ <%= link_to( image_tag('help_button.png'), '#', :class => 'version_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.versions.desc_help_text_html'))%>
+
+ |
+
| <%= t('org_admin.templates.published_label') %> | +<%= f.check_box :published, :as => :check_boxes %> | + +
| <%= 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 %> | +
<%= raw phase.description %>
+| <%= t('helpers.sections_label')%> | +<%= t('helpers.questions_label')%> | +
|---|---|
|
+ <%= section.title %> + |
+
+ <% if section.questions.any? %>
+ <% questions = section.questions.order("number ASC") %>
+
|
+
| <%= 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") then%>
+
+ <% 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") then%> + <% if question.option_comment_display == true then%> + <%= t("org_admin.questions.option_comment_display")%> + <%else%> + <%= t("org_admin.questions.option_comment_hide")%> + <%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.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 then%> + , + <% 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') %> | +<%= dmptemplate.title %> | +
| <%= t('org_admin.templates.desc_label') %> | +<% if !dmptemplate.description.nil? && dmptemplate.description != "" then %> + <%= raw dmptemplate.description %> + <%else%> + - + <%end%> + | +
| <%= t('org_admin.templates.published_label') %> | +<%if dmptemplate.published || dmptemplate.has_published_versions? then%> + <%= dmptemplate.published %> + <%else%> + <%= t('org_admin.templates.cannot_publish')%> + <%end%> + | +
| <%= t('org_admin.templates.created') %> | +<%= l dmptemplate.created_at.to_date, :formats => :short %> | +
| <%= t('org_admin.templates.last_updated') %> | +<%= l dmptemplate.updated_at.to_date, :formats => :short %> | +
| <%= t('org_admin.templates.title_label') %> | +<%= version.title %> | +
| <%= t('org_admin.templates.desc_label') %> | +<%= raw version.description %> | +
| <%= t('org_admin.templates.published_label') %> | +<%= version.published %> | +
| <%= t('org_admin.templates.created') %> | ++ <%= l version.created_at.to_date, :formats => :short %> + | +
| <%= t('org_admin.templates.last_updated') %> | ++ <%= l version.updated_at.to_date, :formats => :short %> + | +
+ <%= t('org_admin.versions.versions_text_html')%> +
+ + +| <%= t('org_admin.templates.title_label')%> | +<%= t('org_admin.templates.published_label')%> | +<%= t('org_admin.templates.created')%> | +<%= t('org_admin.templates.last_updated') %> | +<%= t('org_admin.templates.actions') %> | +
|---|---|---|---|---|
| + <%= v.title %> + | ++ <%= v.published %> + | ++ <%= l v.created_at.to_date, :formats => :short %> + | ++ <%= l v.updated_at.to_date, :formats => :short %> + | ++ <%= link_to t("helpers.view"), admin_phase_dmptemplate_path( :version_id => v.id, :id => phase.id , :edit => 'false'), :class => "dmp_table_link"%> + <% if v.published? then%> + + <%= t('org_admin.versions.edit_label')%> + + <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> + <%else%> + <%= link_to t("org_admin.versions.edit_label"), admin_phase_dmptemplate_path(phase, :version_id => v.id, :edit => 'true'), :class => "dmp_table_link" %> + <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> + <%#= link_to t("helpers.submit.delete"), admin_destroyversion_dmptemplate_path(:version_id => v.id, :phase => phase , :edit => 'false'), + :confirm => t("org_admin.versions.delete_message", :version_title => v.title ), :method => :delete, :class => "dmp_table_link"%> + <%end%> + | +
| <%= 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.templates.title_label') %> | +<%= t('org_admin.templates.desc_label') %> | +<%= t('org_admin.templates.published_label') %> | +<%= t('org_admin.templates.last_updated') %> | +<%= t('org_admin.templates.actions') %> | +
|---|---|---|---|---|
| + <%= org_template.title%> + | ++ <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %> + | ++ <%= org_template.published %> + | ++ <% last_temp_updated = org_template.updated_at %> + <% org_template.phases.each do |phase|%> + <% if phase.versions.any? then%> + <% phase.versions.each do |version| %> + <% if org_template.updated_at.to_date < version.updated_at.to_date then %> + <% last_temp_updated = version.updated_at %> + <%end%> + <%end%> + <%end%> + <%end%> + <%= l last_temp_updated.to_date, :formats => :short %> + | ++ <%if current_user.can_org_admin? then%> + <% b_label = t('helpers.submit.edit')%> + <%else%> + <% b_label = t('helpers.view')%> + <%end%> + <%= link_to b_label, admin_template_dmptemplate_path(org_template), :class => "dmp_table_link"%> + | +
| <%= t('org_admin.templates.title_label') %> | +<%= t('org_admin.templates.desc_label') %> | +<%= t('org_admin.templates.published_label') %> | +<%= t('org_admin.templates.last_updated') %> | +<%= t('org_admin.templates.actions') %> | +
|---|---|---|---|---|
| + <%= org_template.title%> + | ++ <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %> + | ++ <%if org_template.published? then %> + <%= org_template.published%> + <%else%> + <%= t("helpers.false_lowercase")%> + <%end%> + | ++ <% last_updated = org_template.updated_at %> + <% org_template.phases.each do |phase|%> + <% if phase.versions.any? then%> + <% phase.versions.each do |version| %> + <% if org_template.updated_at.to_date < version.updated_at.to_date then %> + <% last_updated = version.updated_at %> + <%end%> + <%end%> + <%end%> + <%end%> + <%= l last_updated.to_date, :formats => :short %> + + | ++ <%if current_user.can_org_admin? then%> + <% if org_template.org_type == constant("organisation_types.funder") then %> + <%if org_template.has_customisations?(current_user.organisation_id, org_template) then%> + <% b_label = t("org_admin.templates.edit_customisation")%> + <%else%> + <% b_label = t("org_admin.templates.customise")%> + <%end%> + <%else%> + <% b_label = t("helpers.submit.edit")%> + <%end%> + <%else%> + <% b_label = t("helpers.view")%> + <%end%> + <%= link_to b_label, admin_template_dmptemplate_path(org_template), :class => "dmp_table_link"%> + | +
| <%= t("org_admin.templates.title_label") %> | +<%= f.text_field :title, :as => :string, + :class => "text_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.title_help_text") %> | +
| <%= t("org_admin.templates.desc_label") %> | +
+ <%= text_area_tag("template-desc", "", class: "tinymce") %>
+
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "template_desc_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.template_desc_help_text_html"))%>
+
+ |
+