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 @@ - -
- <%= form_for :guidance, :url => {:action => "admin_create"}, :html => {:id => "new_guidance_form"} do |f| %> - - - - - - - - - - - - - - - - - -
<%= t("org_admin.guidance.text_label") %>
- <%= text_area_tag("guidance-text", "", class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_text_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.text_help_text_html"))%> -
-
-
<%= t("org_admin.guidance.by_theme_or_by_question") %>
- <%= select_tag "g_options", options_for_select([[t("org_admin.guidance.by_themes_label"), 1], - [t("org_admin.guidance.by_question_label"), 2]]) %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_apply_to_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.apply_to_help_text_html"))%> -
-
- - -
<%= t("org_admin.guidance.published") %>
- <%= f.check_box :published , :as => :check_boxes%> -
-
- -
-
<%= t("org_admin.guidance.guidance_group_label") %>
- <%= f.collection_select(:guidance_group_ids, - GuidanceGroup.where("organisation_id = ?", current_user.organisation_id).order("name ASC"), - :id, :name, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => false})%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_group_select_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.guidance_group_select_help_text_html"))%> -
-
- -
- - - -
- <%= t("helpers.submit.save")%> - - <%= link_to t("helpers.submit.cancel"), :back, :class => "btn cancel" %> -
- -
- <%= tinymce :content_css => asset_path("application.css") %> - <%end%> -
- - - - - \ No newline at end of file diff --git a/app/views/dmptemplates/_add_question.html.erb b/app/views/dmptemplates/_add_question.html.erb deleted file mode 100644 index 1caf54c..0000000 --- a/app/views/dmptemplates/_add_question.html.erb +++ /dev/null @@ -1,179 +0,0 @@ - - -<% @new_question = Question.new %> -<% @new_question.number = section.questions.count + 1 %> - - -<%= form_for @new_question, :url => {:action => "admin_createquestion"}, :html => {:id => "new_question_#{section.id}"} do |f| %> -<%= f.hidden_field :section_id, :value => section.id %> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, :in => 1..50, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %> - -
-
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, :rows => "5", :id => "new_question_text_#{section.id}" %> -
-
<%= t("org_admin.questions.answer_format_label")%><%= f.hidden_field :section_id, :value => section.id, :class => "section_id" %> -
-
- <%= f.select :question_format_id, - options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, QuestionFormat.find_by_title(t("helpers.text_area")).id), - {}, :id => "new-select-format-#{section.id}"%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "question_format_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> -
- -
-
- - -
- - -
- - -
- -
-
-
-
<%= t("org_admin.questions.suggested_or_example_answer_label")%>
- <% suggested_answer = @new_question.suggested_answers.build %> - <%= f.fields_for :suggested_answers, suggested_answer do |s|%> - <%= s.hidden_field :organisation_id, :value => current_user.organisation.id %> -
    -
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • -
  • <%= s.text_area :text, :rows => 5 %>
  • -
- <%end%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "suggested_answer_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> -
-
-
- -
<%= t("org_admin.questions.guidance_label")%>
- <%= text_area_tag("new-question-guidance", "", class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "question_guidance_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> -
-
-
-
<%= t("org_admin.questions.themes_label")%>
- <%= f.collection_select(:theme_ids, - Theme.all.order("title"), - :id, :title, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => true})%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "question_themes_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> -
- - -
-
- - -
- <%= hidden_field_tag :section_id, section.id, :class => "section_id" %> - <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary new_question_save_button" %> - <%= hidden_field_tag :section_id, section.id, :class => "section_id_new" %> - <%= link_to t("helpers.submit.cancel"), '#', :class => "btn cancel cancel_add_new_question" %> -
-
- -<%end%> - diff --git a/app/views/dmptemplates/_add_section.html.erb b/app/views/dmptemplates/_add_section.html.erb deleted file mode 100644 index b445c85..0000000 --- a/app/views/dmptemplates/_add_section.html.erb +++ /dev/null @@ -1,54 +0,0 @@ - - -<% @new_section = Section.new %> -<% @new_section.number = version.sections.count + 1 %> - - -<%= form_for @new_section, :url => {:action => "admin_createsection"} do |f| %> - <%= f.hidden_field :version_id, :value => version.id %> - <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> - -
-
-
-
- - <%= f.text_field :title, :as => :string, :class => "text_field", :placeholder => t("org_admin.templates.section_title_placeholder")%> -
- - -
- -
-
-
- - - - - - - - - -
<%= t("org_admin.templates.phase_order_label") %> - <%= f.number_field :number, :in => 1..15, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.section_number_help_text") %>
<%= t("org_admin.templates.desc_label") %> -
- <%= text_area_tag("section-desc", "" , class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "section_desc_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.templates.section_desc_help_text_html"))%> -
-
- -
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), "#", :id => "", :class => "btn cancel" %> -
-
-
-
-
-<%end%> - - diff --git a/app/views/dmptemplates/_add_suggested_answer.html.erb b/app/views/dmptemplates/_add_suggested_answer.html.erb deleted file mode 100644 index 03e11b7..0000000 --- a/app/views/dmptemplates/_add_suggested_answer.html.erb +++ /dev/null @@ -1,25 +0,0 @@ - -<%= form_for :suggested_answer, :url => {:action => "admin_createsuggestedanswer"} do |f| %> - <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> - <%= f.hidden_field :question_id, :value => question.id %> - - - - - - -
<%= t("org_admin.questions.suggested_or_example_answer_label")%> -
    -
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • -
  • <%= f.text_area :text, :rows => 5 %> -
  • -
-
-
- - -
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), "#", :id => "cancel_suugested_answer", :class => "btn cancel" %> -
-<%end%> diff --git a/app/views/dmptemplates/_admin_nav_tabs.html.erb b/app/views/dmptemplates/_admin_nav_tabs.html.erb deleted file mode 100644 index 49c3c20..0000000 --- a/app/views/dmptemplates/_admin_nav_tabs.html.erb +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/app/views/dmptemplates/_edit_guidance.html.erb b/app/views/dmptemplates/_edit_guidance.html.erb deleted file mode 100644 index 8debbca..0000000 --- a/app/views/dmptemplates/_edit_guidance.html.erb +++ /dev/null @@ -1,26 +0,0 @@ - -<%= form_for(suggested_answer, :url => admin_updatesuggestedanswer_dmptemplate_path(suggested_answer), :html => { :method => :put}) do |f| %> - <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> - - - - - - -
<%= t("org_admin.questions.suggested_or_example_answer_label")%> -
    -
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • -
  • <%= f.text_area :text, :rows => 5 %>
  • -
-
-
- - -
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> - <%= link_to t("helpers.submit.delete"), admin_destroysuggestedanswer_dmptemplate_path(:suggested_answer => suggested_answer.id), - :confirm => t("org_admin.questions.delete_suggested_answer_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> - <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("helpers.submit.cancel"), "#", :class => "btn cancel cancel_edit_suggested_answer" %> -
-<%end%> diff --git a/app/views/dmptemplates/_edit_phase.html.erb b/app/views/dmptemplates/_edit_phase.html.erb deleted file mode 100644 index 1536a48..0000000 --- a/app/views/dmptemplates/_edit_phase.html.erb +++ /dev/null @@ -1,45 +0,0 @@ - - -<%= form_for(phase, :url => admin_updatephase_dmptemplate_path(phase), :html => { :method => :put}) do |f| %> - -

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

-
- <%= raw t('org_admin.templates.phase_details_text_html')%> -
-
-
- - - - - - - - - - - - - - -
<%= t('org_admin.templates.title_label') %><%= f.text_field :title, - :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %>
<%= t('org_admin.templates.phase_order_label') %><%= f.number_field :number, :in => 0..5, :class => "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_number_help_text') %>
<%= t('org_admin.templates.desc_label') %> -
- <%= text_area_tag("phase-desc", phase.description, class: "tinymce") %> -
-
- <%= link_to( image_tag('help_button.png'), '#', :class => 'phase_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.phase_desc_help_text_html'))%> -
-
-
- - -
- <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <%= link_to t('helpers.submit.cancel'), admin_phase_dmptemplate_path(phase), :class => 'btn cancel' %> -
- -<%end%> \ No newline at end of file diff --git a/app/views/dmptemplates/_edit_question.html.erb b/app/views/dmptemplates/_edit_question.html.erb deleted file mode 100644 index ab12c02..0000000 --- a/app/views/dmptemplates/_edit_question.html.erb +++ /dev/null @@ -1,174 +0,0 @@ - - -<%= form_for(question, :url => admin_updatequestion_dmptemplate_path(question), :html => { :method => :put}) do |f| %> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, :in => 1..50, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %> -
-
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, :rows => "5" %> -
-
<%= t("org_admin.questions.answer_format_label")%>
-
- <%= f.hidden_field :id,{ :class => "quest_id" } %> - <%= f.select :question_format_id, - options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, question.question_format_id), - {}, :id => "#{question.id}-select-format"%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "question_format_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> -
- -
- - - -
- - -
- - -
- -
-
-
-
<%= t("org_admin.questions.suggested_or_example_answer_label")%>
- <% suggested_answer = question.suggested_answers.find_by_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 %> -
    -
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • -
  • <%= s.text_area :text, :rows => 5 %> -
  • -
- <%end%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "suggested_answer_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> -
-
-
-
<%= t("org_admin.questions.guidance_label")%>
- <%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "question_guidance_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> -
-
-
-
<%= t("org_admin.questions.themes_label")%>
- <%= f.collection_select(:theme_ids, - Theme.all.order("title"), - :id, :title, {:prompt => false, :include_blank => "None"}, {:multiple => true})%> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "question_themes_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> -
-
-
- -
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> - <% if !question.section.version.published? then%> - <%= link_to t("helpers.submit.delete"), admin_destroyquestion_dmptemplate_path(:question_id => question.id), - :confirm => t("org_admin.questions.delete_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> - <%end%> - <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("helpers.submit.cancel"), "#", :class => "btn cancel cancel_edit_question" %> -
-
- - - -<%= render :partial => "guidance_display", locals: {question: question}%> -<%end%> diff --git a/app/views/dmptemplates/_edit_section.html.erb b/app/views/dmptemplates/_edit_section.html.erb deleted file mode 100644 index 8f7f8b4..0000000 --- a/app/views/dmptemplates/_edit_section.html.erb +++ /dev/null @@ -1,116 +0,0 @@ - - - -<%= form_for(section, :url => admin_updatesection_dmptemplate_path(section, :phase => phase, :edit => edit), :html => { :method => :put}) do |s| %> - <%if @open && @section_id == section.id then%> - <% toggle = 'accordion-body section-collapse in collapse'%> - <%else%> - <% toggle = 'accordion-body collapse section-collapse' %> - <%end%> - - <%if @new_sec then%> - <% toggle = 'accordion-body section-collapse in collapse'%> - <%end%> - -
-
-
-
- <%= s.text_field :title, :as => :string, :class => 'text_field', :placeholder => t('org_admin.templates.section_title_placeholder') %> - -
-
- -
- - -
-
- - - - - - - - - -
<%= t('org_admin.templates.phase_order_label') %><%= s.number_field :number, :in => 1..15, :class => "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.section_number_help_text') %>
<%= t('org_admin.templates.desc_label') %> -
- <%= text_area_tag("section-desc-#{section.id}", section.description , class: "tinymce") %> -
-
- <%= link_to( image_tag('help_button.png'), '#', :class => 'section_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.section_desc_help_text_html'))%> -
-
- -
- <%= s.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <% if !section.version.published? || phase.dmptemplate.org_type == constant("organisation_types.funder") then%> - <%= link_to t("helpers.submit.delete"), admin_destroysection_dmptemplate_path(:section_id => section.id), - :confirm => t("org_admin.templates.section_delete_message", :section_title => section.title ), :method => :delete, :class => "btn btn-primary"%> - <%end%> - <%= link_to t('helpers.submit.cancel'), :back, :class => 'btn cancel' %> -
- <%end%> -
- <% @questions = section.questions.order("number")%> - <%if @questions.count > 0 %> - <% question_left = @questions.count %> - <% @questions.each do |question| %> -
-
"> - - <%= render :partial => 'show_question', locals: {question: question} %> -
- - -
- - <%if question_left.to_i > 1 then %> -
- <%else%> -
- <%end%> - <% question_left = question_left - 1 %> - - <%end%> - <%end%> - - - <% if !section.version.published? || phase.dmptemplate.org_type == constant("organisation_types.funder") then%> - - <%if @questions.count != 0 %> -
- <%end%> - - - - -
-
- <%= hidden_field_tag :section_id, section.id, :class => "section_id" %> - <%= link_to t("org_admin.add_question_label"), '#', :class => "btn btn-primary add_question_button" %> -
-
- <%end%> - -
-
-
-
diff --git a/app/views/dmptemplates/_edit_suggested_answer.html.erb b/app/views/dmptemplates/_edit_suggested_answer.html.erb deleted file mode 100644 index 2f78934..0000000 --- a/app/views/dmptemplates/_edit_suggested_answer.html.erb +++ /dev/null @@ -1,26 +0,0 @@ - -<%= form_for(suggested_answer, :url => admin_updatesuggestedanswer_dmptemplate_path(suggested_answer), :html => { :method => :put}) do |f| %> - <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> - - - - - - -
<%= t('org_admin.questions.suggested_or_example_answer_label')%> -
    -
  • <%= f.select :is_example, {t('org_admin.questions.example_answer_label') => true, t('org_admin.questions.suggested_answer_label') => false} %>
  • -
  • <%= f.text_area :text, :rows => 5 %>
  • -
-
-
- - -
- <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <%= link_to t("helpers.submit.delete"), admin_destroysuggestedanswer_dmptemplate_path(:suggested_answer => suggested_answer.id), - :confirm => t("org_admin.questions.delete_suggested_answer_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> - <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t('helpers.submit.cancel'), '#', :class => 'btn cancel cancel_edit_suggested_answer' %> -
-<%end%> diff --git a/app/views/dmptemplates/_edit_template.html.erb b/app/views/dmptemplates/_edit_template.html.erb deleted file mode 100644 index dbea10a..0000000 --- a/app/views/dmptemplates/_edit_template.html.erb +++ /dev/null @@ -1,52 +0,0 @@ - - -<%= form_for(dmptemplate, :url => admin_update_dmptemplate_path(dmptemplate), :html => { :method => :put}) do |f| %> -
- - - - - - - - - - - - - - - - - - - - - -
<%= 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 %> -
- - -
- <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <%= link_to t('helpers.submit.cancel'), admin_template_dmptemplate_path(dmptemplate), :class => 'btn cancel' %> -
- -
- -<%end%> \ No newline at end of file diff --git a/app/views/dmptemplates/_edit_version.html.erb b/app/views/dmptemplates/_edit_version.html.erb deleted file mode 100644 index 416fdb7..0000000 --- a/app/views/dmptemplates/_edit_version.html.erb +++ /dev/null @@ -1,47 +0,0 @@ - - - -<%= form_for(version, :url => admin_updateversion_dmptemplate_path(version, :edit => edit, :phase => phase), :html => { :method => :put}) do |f| %> - -

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

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

- <%= raw suggested_answer.text %> -

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

- <%= raw suggested_answer.text %> -

-
-
- <% end %> - - <% end %> - - - - - <% if q_format.title == t("helpers.text_field") then %> - - - <%elsif q_format.title == t("helpers.text_area") then%> - - <%end%> -
- - <%= link_to t("helpers.save"), "#", :class => "btn btn-primary", :onclick => "event.preventDefault();" %> - - <%= t("helpers.notanswered") %> - -
-
-
- - - -<%= render :partial => "guidance_display", locals: {question: question}%> diff --git a/app/views/dmptemplates/_show_phase.html.erb b/app/views/dmptemplates/_show_phase.html.erb deleted file mode 100644 index 01117cf..0000000 --- a/app/views/dmptemplates/_show_phase.html.erb +++ /dev/null @@ -1,37 +0,0 @@ - - -

- <%= t('org_admin.templates.phase_details_label')%> - - - <% if @phase.dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> -
- <%= link_to t("org_admin.templates.edit_phase_details_label"), '#', :class => "btn btn-primary", :id => "edit_phase_button"%> -
- <%end%> -

- -<%if @phase.dmptemplate.org_type != constant("organisation_types.funder") then%> -
- <%= raw t('org_admin.templates.phase_details_text_html')%> -
-<%end%> - -
-
- - - - - - - - - - - - - - -
<%= t('org_admin.templates.title_label') %><%= @phase.title %>
<%= t('org_admin.templates.phase_order_label') %><%= @phase.number %>
<%= t('org_admin.templates.desc_label') %><%= raw @phase.description %>
-
diff --git a/app/views/dmptemplates/_show_phases_sections.html.erb b/app/views/dmptemplates/_show_phases_sections.html.erb deleted file mode 100644 index 19c603a..0000000 --- a/app/views/dmptemplates/_show_phases_sections.html.erb +++ /dev/null @@ -1,73 +0,0 @@ - - -
- -
-

<%= raw phase.description %>

-
- -<% if phase.versions.any? then %> - - <% version = phase.versions.where("published = ?", true).first %> - <% if version.nil? then%> - <% version = phase.versions.order("updated_at DESC").first %> - <%end%> - - -
- - - <%if phase.has_sections == true then %> - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(version), :class => 'btn btn-primary'%> - <%end%> - <% if phase.latest_published_version == nil then%> - <%= link_to t("helpers.submit.delete"), admin_destroyphase_dmptemplate_path(:phase_id => phase.id), - :confirm => t("org_admin.templates.phase_delete_message", :phase_title => phase.title ), :method => :delete, :class => "btn btn-primary"%> - <%end%> - <%if phase.dmptemplate.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder") then%> - <% b_label = t('org_admin.templates.view_phase_label')%> - <%else %> - <% b_label = t('org_admin.templates.edit_phase_label')%> - <%end%> - <%= link_to b_label, admin_phase_dmptemplate_path(phase), :class => "btn btn-primary" %> - -
- <% if version.sections.any? then %> - - - - - - - - - <% version.sections.order("number ASC").each do |section| %> - <%if (section.organisation_id == phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> - - - - - <%end%> - <%end%> - -
<%= t('helpers.sections_label')%><%= t('helpers.questions_label')%>
-

<%= section.title %>

-
- <% if section.questions.any? %> - <% questions = section.questions.order("number ASC") %> -
    - <% questions.each do |ques|%> -
  • - - <%= raw ques.text %> -
  • - <%end%> -
- <%end%> -
- - <%end%> - -<%end%> - - -
diff --git a/app/views/dmptemplates/_show_question.html.erb b/app/views/dmptemplates/_show_question.html.erb deleted file mode 100644 index df79c2b..0000000 --- a/app/views/dmptemplates/_show_question.html.erb +++ /dev/null @@ -1,153 +0,0 @@ - - -
- - - - - - - - - - - - - - <%if q_format.title == t("helpers.text_field") || q_format.title == t("helpers.text_area") then %> - <%if !question.default_value.nil? then %> - - - - - <%end%> - <% end %> - - - - - - - - <% if (question.section.version.phase.dmptemplate.org_type != constant("organisation_types.funder") && question.section.organisation_id == current_user.organisation_id ) then%> - <% suggested_answer = question.get_suggested_answer(current_user.organisation.id) %> - <% if !suggested_answer.nil? && suggested_answer.text != "" then %> - - - - - <%end%> - <%end%> - - <%if !question.guidance.nil? then %> - - - - - <%end%> - - <% themes_q = question.themes %> - <%if !themes_q.nil? then%> - - - - - <%end%> -
<%= t('org_admin.questions.question_number_label')%><%= question.number%>
<%= t('org_admin.questions.question_text_label')%><%= raw question.text %> -
-
- <% q_format = question.question_format %> - <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") then%> -
    - <% if question.options.is_a? Option then %> -
  • - <%= question.options.text %>
  • - <% else %> - <% if !question.options.to_a.nil? then %> - <% question.options.to_a.sort_by{|op| op['number']}.each do |o| %> -
  • - <%= o.text %>
  • - <%end%> - <% end %> - <% end %> -
- <% end %> -
-
<%= t('org_admin.questions.default_value_label')%><%= raw question.default_value %>
<%= t('org_admin.questions.answer_format_label')%><%= q_format.title %> -
- <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") 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 (question.section.version.phase.dmptemplate.org_type == constant("organisation_types.funder") && question.section.organisation_id != current_user.organisation_id ) then%> - <% suggested_answer = question.get_suggested_answer(current_user.organisation.id) %> - <% if !suggested_answer.nil? && suggested_answer.text != "" then %> -
- <%= render :partial => 'show_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %> -
- - - <%end%> - - - - - - <%end%> - -
- - <%if (@edit == 'true'&& question.section.organisation_id == current_user.organisation_id) || (question.section.version.phase.dmptemplate.org_type == constant("organisation_types.funder") && question.section.organisation_id == current_user.organisation_id && current_user.org_type != constant("organisation_types.funder")) then%> -
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("org_admin.questions.question_edit_button"), '# ', :class => "btn btn-primary edit_question_button"%> - <% if !question.section.version.published? then%> - <%= link_to t("org_admin.questions.question_delete_button"), admin_destroyquestion_dmptemplate_path(:question_id => question.id), - :confirm => t("org_admin.questions.delete_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> - <%end%> -
- <%elsif (@edit == 'false' && question.section.organisation_id != current_user.organisation_id )|| (question.section.version.phase.dmptemplate.org_type == constant("organisation_types.funder") && question.section.organisation_id != current_user.organisation_id ) then%> - <% suggested_answer = question.get_suggested_answer(current_user.organisation.id) %> - <% if suggested_answer.nil? then %> -
-
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("org_admin.questions.suggested_or_example_answer_button"), '# ', :class => "btn btn-primary add_suggested_answer_button"%> -
-
- <%end%> - <%end%> -
-
- - - -<%= render :partial => 'guidance_display', locals: {question: question}%> diff --git a/app/views/dmptemplates/_show_section.html.erb b/app/views/dmptemplates/_show_section.html.erb deleted file mode 100644 index 1dbf719..0000000 --- a/app/views/dmptemplates/_show_section.html.erb +++ /dev/null @@ -1,43 +0,0 @@ - -<%if @open && @section_id == section.id then%> - <% toggle = 'accordion-body section-collapse in collapse'%> -<%else%> - <% toggle = 'accordion-body collapse section-collapse' %> -<%end%> -
-
- -
- <% if section.title == '' then%> - <%= t('org_admin.templates.new_section')%> - <%else%> - <%= section.title %> - <%end%> -
- - -
-
-
-
- <%= raw section.description %> -
-
- <% section.questions.order("number").each do |question| %> - <% last_question_id = section.questions.order("number DESC").first.id %> - -
- - <%= render :partial => 'show_question', locals: {question: question}%> -
- - <% if last_question_id == question.id then %> -
- <% else %> -
- <% end %> - - <%end%> -
-
-
diff --git a/app/views/dmptemplates/_show_suggested_answer.html.erb b/app/views/dmptemplates/_show_suggested_answer.html.erb deleted file mode 100644 index 888dd45..0000000 --- a/app/views/dmptemplates/_show_suggested_answer.html.erb +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -
- <% if suggested_answer.is_example? then %> - <%= t('org_admin.questions.example_answer_label')%> - <%else%> - <%= t('org_admin.questions.suggested_answer_label')%> - <%end%> - <%= raw suggested_answer.text %>
-
- -
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - <%= link_to t("org_admin.questions.edit_suggested_answer_button"), '# ', :class => "btn btn-primary edit_form_for_suggested_answer"%> -
diff --git a/app/views/dmptemplates/_show_template.html.erb b/app/views/dmptemplates/_show_template.html.erb deleted file mode 100644 index 7cfec9d..0000000 --- a/app/views/dmptemplates/_show_template.html.erb +++ /dev/null @@ -1,43 +0,0 @@ - - -<% if @dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> -

-
- <%= link_to t("org_admin.templates.edit_details"), '# ', :class => "btn btn-primary", :id => "edit_template_button"%> -
-

-<%end%> -
- - - - - - - - - - - - - - - - - - - - - - -
<%= 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 %>
diff --git a/app/views/dmptemplates/_show_version.html.erb b/app/views/dmptemplates/_show_version.html.erb deleted file mode 100644 index 3e1456e..0000000 --- a/app/views/dmptemplates/_show_version.html.erb +++ /dev/null @@ -1,42 +0,0 @@ - - - -

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

-
- - - - - - - <% if version.description != "" then%> - - - - - <%end%> - - - - - - - - - - - - -
<%= t('org_admin.templates.title_label') %><%= version.title %>
<%= t('org_admin.templates.desc_label') %><%= raw version.description %>
<%= t('org_admin.templates.published_label') %><%= version.published %>
<%= t('org_admin.templates.created') %> - <%= l version.created_at.to_date, :formats => :short %> -
<%= t('org_admin.templates.last_updated') %> - <%= l version.updated_at.to_date, :formats => :short %> -
-
- - - - - diff --git a/app/views/dmptemplates/_versions_table.html.erb b/app/views/dmptemplates/_versions_table.html.erb deleted file mode 100644 index e51dbfe..0000000 --- a/app/views/dmptemplates/_versions_table.html.erb +++ /dev/null @@ -1,73 +0,0 @@ -<%if !phase.versions.nil? then %> -
-

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

-

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

- - - - - - - - - - - - - - <% phase.versions.each do |v|%> - - - - - - - - - - - - - <%end%> - -
<%= t('org_admin.templates.title_label')%><%= t('org_admin.templates.published_label')%><%= t('org_admin.templates.created')%><%= t('org_admin.templates.last_updated') %><%= t('org_admin.templates.actions') %>
- <%= v.title %> - - <%= v.published %> - - <%= l v.created_at.to_date, :formats => :short %> - - <%= l v.updated_at.to_date, :formats => :short %> - - <%= link_to t("helpers.view"), admin_phase_dmptemplate_path( :version_id => v.id, :id => phase.id , :edit => 'false'), :class => "dmp_table_link"%> - <% if v.published? then%> - - <%= t('org_admin.versions.edit_label')%> - - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> - <%else%> - <%= link_to t("org_admin.versions.edit_label"), admin_phase_dmptemplate_path(phase, :version_id => v.id, :edit => 'true'), :class => "dmp_table_link" %> - <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> - <%#= link_to t("helpers.submit.delete"), admin_destroyversion_dmptemplate_path(:version_id => v.id, :phase => phase , :edit => 'false'), - :confirm => t("org_admin.versions.delete_message", :version_title => v.title ), :method => :delete, :class => "dmp_table_link"%> - <%end%> -
-
- - - -<%end%> diff --git a/app/views/dmptemplates/admin_addphase.html.erb b/app/views/dmptemplates/admin_addphase.html.erb deleted file mode 100644 index 6e8a336..0000000 --- a/app/views/dmptemplates/admin_addphase.html.erb +++ /dev/null @@ -1,75 +0,0 @@ -<%- model_class = Phase -%> -<%= stylesheet_link_tag "admin" %> -<% javascript "admin.js" %> - -

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

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

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

- <%= raw t("org_admin.templates.phase_new_text_html")%> -
-
- <%= f.hidden_field :dmptemplate_id, :value => @dmptemplate.id%> - - - - - - - - - - - - - -
<%= t("org_admin.templates.title_label") %><%= f.text_field :title, - :as => :string, - :class => "text_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.phase_title_help_text") %>
<%= t("org_admin.templates.phase_order_label") %><%= f.number_field :number, :in => 1..5, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.phase_number_help_text") %>
<%= t("org_admin.templates.desc_label") %> -
- <%= text_area_tag("phase-desc","" , class: "tinymce") %> -
-
- <%= link_to( image_tag("help_button.png"), "#", :class => "phase_desc_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.templates.phase_desc_help_text_html"))%> -
-
-
-
- - -
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), admin_dmptemplate_path(@dmptemplate), :class => "btn cancel" %> -
- - <%end%> -
-
-
-
- -<%= tinymce :content_css => asset_path("application.css") %> \ No newline at end of file diff --git a/app/views/dmptemplates/admin_index.html.erb b/app/views/dmptemplates/admin_index.html.erb deleted file mode 100644 index b22018c..0000000 --- a/app/views/dmptemplates/admin_index.html.erb +++ /dev/null @@ -1,153 +0,0 @@ -<%= stylesheet_link_tag "admin" %> - -

- <%= t('org_admin.templates_label') %> -

-
-

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

- -
- <%= raw t('org_admin.templates.create_own_template_text_html')%> -
-
- -
- <%= link_to t("org_admin.templates.create_template"), - admin_new_dmptemplate_path, - :class => 'btn btn-primary' %> -
-
-
- - -<% if @dmptemplates_own.count > 0 then %> - - - - - - - - - - - - <% @dmptemplates_own.each do |org_template| %> - - - - - - - - - <%end%> - -
<%= 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"%> -
- -<%end%> - -
-
- - -<% if current_user.org_type != constant("organisation_types.funder") then %> -

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

- - - <% if @dmptemplates_funders.count > 0 then %> - - - - - - - - - - - - - - <% @dmptemplates_funders.each do |org_template| %> - <% if org_template.published? ||org_template.has_customisations?(current_user.organisation_id, org_template) then %> - - - - - - - - <%end%> - <%end%> - -
<%= 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"%> -
- <%end%> -<%end%> diff --git a/app/views/dmptemplates/admin_new.html.erb b/app/views/dmptemplates/admin_new.html.erb deleted file mode 100644 index 798f855..0000000 --- a/app/views/dmptemplates/admin_new.html.erb +++ /dev/null @@ -1,48 +0,0 @@ -<%= stylesheet_link_tag "admin" %> -<% javascript "admin.js" %> - -

- <%= t("org_admin.templates.new_label") %> - -
- <%= link_to t("org_admin.templates.view_all_templates"), - admin_index_dmptemplate_path, - :class => "btn btn-primary" %> -
-

- -
-
- -
- <%= raw t("org_admin.templates.create_new_template_text_html")%> -
- <%= form_for :dmptemplate, :url => {:action => "admin_create"} do |f| %> - - - - - - - - - - -
<%= 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"))%> -
-
- -
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> - <%= link_to t("helpers.submit.cancel"), admin_index_dmptemplate_path, :class => "btn cancel" %> -
-
- <%end%> -
-
-<%= tinymce :content_css => asset_path("application.css") %> \ No newline at end of file diff --git a/app/views/dmptemplates/admin_phase.html.erb b/app/views/dmptemplates/admin_phase.html.erb deleted file mode 100644 index b85927b..0000000 --- a/app/views/dmptemplates/admin_phase.html.erb +++ /dev/null @@ -1,82 +0,0 @@ -<%- model_class = Phase -%> -<%= stylesheet_link_tag "admin" %> -<% javascript 'admin.js' %> - -<%= tinymce :content_css => asset_path('application.css') %> - -

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

- -
- - -<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @phase.dmptemplate, active: @phase.id} %> - - -
-
- - -
-
- - -
- <%= render :partial => "show_phase", locals: {phase: @phase}%> -
- <% if @phase.dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> - - - - <%= render :partial => "versions_table", locals: {phase: @phase}%> - <%end%> - - - <% if @edit == "false" || (@phase.dmptemplate.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder")) then%> - <%= render :partial => 'show_version', locals: {version: @version}%> - <%elsif @edit == "true" || current_user.org_type == constant("organisation_types.funder") then %> - <%= render :partial => 'edit_version', locals: {version: @version, edit: @edit, phase: @phase} %> - <%end%> -
-
- - - <% @sections.order("number ASC").each do |section| %> - <%if (@edit == "true" && section.organisation_id == current_user.organisation_id) || - (@phase.dmptemplate.org_type == constant("organisation_types.funder") && section.organisation_id == current_user.organisation_id && current_user.org_type != constant("organisation_types.funder"))then%> - <%= render :partial => 'edit_section', locals: {section: section, edit: @edit, phase: @phase, version: @version} %> - <%elsif (section.organisation_id == @phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> - <%= render :partial => 'show_section', locals: {section: section}%> - <%end%> - <% end %> - -
-
- - - - <% if !@version.published? || (@phase.dmptemplate.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder"))then %> - - - - - -
-
- <%= link_to t('org_admin.add_section_label'),'#', :id => 'add_section_button', :class =>'btn btn-primary' %> -
-
- <%end%> - - diff --git a/app/views/dmptemplates/admin_previewphase.html.erb b/app/views/dmptemplates/admin_previewphase.html.erb deleted file mode 100644 index 12c2507..0000000 --- a/app/views/dmptemplates/admin_previewphase.html.erb +++ /dev/null @@ -1,64 +0,0 @@ -<%- model_class = Phase -%> -<%= stylesheet_link_tag "admin" %> - -

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

- -
- - -<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @version.phase.dmptemplate, active: @version.phase_id} %> - - -
-
- <% sections = @version.sections %> - <% sections.order(:number).each do |section| %> - <%if (section.organisation_id == @version.phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> - -
- -
-
- <%= raw section.description %> -
-
- <% section.questions.order("number").each do |question| %> - <% last_question_id = section.questions.order("number DESC").first.id%> - - - <%= render :partial => 'preview_question', locals: {question: question}%> - - <% if last_question_id == question.id then %> -
- <% else %> -
- <% end %> - - <%end%> -
-
-
- <%end%> - <%end%> -
-
\ No newline at end of file diff --git a/app/views/dmptemplates/admin_template.html.erb b/app/views/dmptemplates/admin_template.html.erb deleted file mode 100644 index 642fb15..0000000 --- a/app/views/dmptemplates/admin_template.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -<%= stylesheet_link_tag "admin" %> -<% javascript 'admin.js' %> - -

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

- -
- - -<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @dmptemplate, active: "show_template"} %> - - -
-
- <% if @dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> - - <%end%> -
- <%= render :partial => "show_template", locals: {dmptemplate: @dmptemplate}%> -
-
- - <% if !@dmptemplate.phases.nil? then %> - <% if @dmptemplate.phases.count == 1 then %> - <% @dmptemplate.phases.each do |phase| %> - - <%= render :partial => 'show_phases_sections', locals: {phase: phase}%> - <%end%> - <%else%> - <% @dmptemplate.phases.order(:number).each do |phase| %> -
-
- -
-
- - <%= render :partial => 'show_phases_sections', locals: {phase: phase}%> -
-
-
-
- <%end%> - <%end%> - <%end%> -
- -<%= tinymce :content_css => asset_path('application.css') %> diff --git a/app/views/dmptemplates/export.pdf.erb b/app/views/dmptemplates/export.pdf.erb deleted file mode 100644 index 3726b39..0000000 --- a/app/views/dmptemplates/export.pdf.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - <%= @template.title %> - - - - -

<%= @template.title %>

- - \ No newline at end of file diff --git a/app/views/templates/_add_guidance.html.erb b/app/views/templates/_add_guidance.html.erb new file mode 100644 index 0000000..de49775 --- /dev/null +++ b/app/views/templates/_add_guidance.html.erb @@ -0,0 +1,93 @@ + +
+ <%= form_for :guidance, :url => {:action => "admin_create"}, :html => {:id => "new_guidance_form"} do |f| %> + + + + + + + + + + + + + + + + + +
<%= t("org_admin.guidance.text_label") %>
+ <%= text_area_tag("guidance-text", "", class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_text_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.text_help_text_html"))%> +
+
+
<%= t("org_admin.guidance.by_theme_or_by_question") %>
+ <%= select_tag "g_options", options_for_select([[t("org_admin.guidance.by_themes_label"), 1], + [t("org_admin.guidance.by_question_label"), 2]]) %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_apply_to_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.apply_to_help_text_html"))%> +
+
+ + +
<%= t("org_admin.guidance.published") %>
+ <%= f.check_box :published , :as => :check_boxes%> +
+
+ +
+
<%= t("org_admin.guidance.guidance_group_label") %>
+ <%= f.collection_select(:guidance_group_ids, + GuidanceGroup.where("organisation_id = ?", current_user.organisation_id).order("name ASC"), + :id, :name, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => false})%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "guidance_group_select_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.guidance.guidance_group_select_help_text_html"))%> +
+
+ +
+ + + +
+ <%= t("helpers.submit.save")%> + + <%= link_to t("helpers.submit.cancel"), :back, :class => "btn cancel" %> +
+ +
+ <%= tinymce :content_css => asset_path("application.css") %> + <%end%> +
+ + + + + \ No newline at end of file diff --git a/app/views/templates/_add_question.html.erb b/app/views/templates/_add_question.html.erb new file mode 100644 index 0000000..1caf54c --- /dev/null +++ b/app/views/templates/_add_question.html.erb @@ -0,0 +1,179 @@ + + +<% @new_question = Question.new %> +<% @new_question.number = section.questions.count + 1 %> + + +<%= form_for @new_question, :url => {:action => "admin_createquestion"}, :html => {:id => "new_question_#{section.id}"} do |f| %> +<%= f.hidden_field :section_id, :value => section.id %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, :in => 1..50, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %> + +
+
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, :rows => "5", :id => "new_question_text_#{section.id}" %> +
+
<%= t("org_admin.questions.answer_format_label")%><%= f.hidden_field :section_id, :value => section.id, :class => "section_id" %> +
+
+ <%= f.select :question_format_id, + options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, QuestionFormat.find_by_title(t("helpers.text_area")).id), + {}, :id => "new-select-format-#{section.id}"%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "question_format_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> +
+ +
+
+ + +
+ + +
+ + +
+ +
+
+
+
<%= t("org_admin.questions.suggested_or_example_answer_label")%>
+ <% suggested_answer = @new_question.suggested_answers.build %> + <%= f.fields_for :suggested_answers, suggested_answer do |s|%> + <%= s.hidden_field :organisation_id, :value => current_user.organisation.id %> +
    +
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= s.text_area :text, :rows => 5 %>
  • +
+ <%end%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "suggested_answer_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> +
+
+
+ +
<%= t("org_admin.questions.guidance_label")%>
+ <%= text_area_tag("new-question-guidance", "", class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "question_guidance_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> +
+
+
+
<%= t("org_admin.questions.themes_label")%>
+ <%= f.collection_select(:theme_ids, + Theme.all.order("title"), + :id, :title, {:prompt => false, :include_blank => t('helpers.none')}, {:multiple => true})%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "question_themes_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> +
+ + +
+
+ + +
+ <%= hidden_field_tag :section_id, section.id, :class => "section_id" %> + <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary new_question_save_button" %> + <%= hidden_field_tag :section_id, section.id, :class => "section_id_new" %> + <%= link_to t("helpers.submit.cancel"), '#', :class => "btn cancel cancel_add_new_question" %> +
+
+ +<%end%> + diff --git a/app/views/templates/_add_section.html.erb b/app/views/templates/_add_section.html.erb new file mode 100644 index 0000000..b445c85 --- /dev/null +++ b/app/views/templates/_add_section.html.erb @@ -0,0 +1,54 @@ + + +<% @new_section = Section.new %> +<% @new_section.number = version.sections.count + 1 %> + + +<%= form_for @new_section, :url => {:action => "admin_createsection"} do |f| %> + <%= f.hidden_field :version_id, :value => version.id %> + <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> + +
+
+
+
+ + <%= f.text_field :title, :as => :string, :class => "text_field", :placeholder => t("org_admin.templates.section_title_placeholder")%> +
+ + +
+ +
+
+
+ + + + + + + + + +
<%= t("org_admin.templates.phase_order_label") %> + <%= f.number_field :number, :in => 1..15, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.section_number_help_text") %>
<%= t("org_admin.templates.desc_label") %> +
+ <%= text_area_tag("section-desc", "" , class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "section_desc_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.templates.section_desc_help_text_html"))%> +
+
+ +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), "#", :id => "", :class => "btn cancel" %> +
+
+
+
+
+<%end%> + + diff --git a/app/views/templates/_add_suggested_answer.html.erb b/app/views/templates/_add_suggested_answer.html.erb new file mode 100644 index 0000000..03e11b7 --- /dev/null +++ b/app/views/templates/_add_suggested_answer.html.erb @@ -0,0 +1,25 @@ + +<%= form_for :suggested_answer, :url => {:action => "admin_createsuggestedanswer"} do |f| %> + <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> + <%= f.hidden_field :question_id, :value => question.id %> + + + + + + +
<%= t("org_admin.questions.suggested_or_example_answer_label")%> +
    +
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= f.text_area :text, :rows => 5 %> +
  • +
+
+
+ + +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), "#", :id => "cancel_suugested_answer", :class => "btn cancel" %> +
+<%end%> diff --git a/app/views/templates/_admin_nav_tabs.html.erb b/app/views/templates/_admin_nav_tabs.html.erb new file mode 100644 index 0000000..49c3c20 --- /dev/null +++ b/app/views/templates/_admin_nav_tabs.html.erb @@ -0,0 +1,34 @@ + + + diff --git a/app/views/templates/_edit_guidance.html.erb b/app/views/templates/_edit_guidance.html.erb new file mode 100644 index 0000000..8debbca --- /dev/null +++ b/app/views/templates/_edit_guidance.html.erb @@ -0,0 +1,26 @@ + +<%= form_for(suggested_answer, :url => admin_updatesuggestedanswer_dmptemplate_path(suggested_answer), :html => { :method => :put}) do |f| %> + <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> + + + + + + +
<%= t("org_admin.questions.suggested_or_example_answer_label")%> +
    +
  • <%= f.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= f.text_area :text, :rows => 5 %>
  • +
+
+
+ + +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> + <%= link_to t("helpers.submit.delete"), admin_destroysuggestedanswer_dmptemplate_path(:suggested_answer => suggested_answer.id), + :confirm => t("org_admin.questions.delete_suggested_answer_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> + <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <%= link_to t("helpers.submit.cancel"), "#", :class => "btn cancel cancel_edit_suggested_answer" %> +
+<%end%> diff --git a/app/views/templates/_edit_phase.html.erb b/app/views/templates/_edit_phase.html.erb new file mode 100644 index 0000000..1536a48 --- /dev/null +++ b/app/views/templates/_edit_phase.html.erb @@ -0,0 +1,45 @@ + + +<%= form_for(phase, :url => admin_updatephase_dmptemplate_path(phase), :html => { :method => :put}) do |f| %> + +

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

+
+ <%= raw t('org_admin.templates.phase_details_text_html')%> +
+
+
+ + + + + + + + + + + + + + +
<%= t('org_admin.templates.title_label') %><%= f.text_field :title, + :as => :string, + :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_title_help_text') %>
<%= t('org_admin.templates.phase_order_label') %><%= f.number_field :number, :in => 0..5, :class => "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.phase_number_help_text') %>
<%= t('org_admin.templates.desc_label') %> +
+ <%= text_area_tag("phase-desc", phase.description, class: "tinymce") %> +
+
+ <%= link_to( image_tag('help_button.png'), '#', :class => 'phase_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.phase_desc_help_text_html'))%> +
+
+
+ + +
+ <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> + <%= link_to t('helpers.submit.cancel'), admin_phase_dmptemplate_path(phase), :class => 'btn cancel' %> +
+ +<%end%> \ No newline at end of file diff --git a/app/views/templates/_edit_question.html.erb b/app/views/templates/_edit_question.html.erb new file mode 100644 index 0000000..ab12c02 --- /dev/null +++ b/app/views/templates/_edit_question.html.erb @@ -0,0 +1,174 @@ + + +<%= form_for(question, :url => admin_updatequestion_dmptemplate_path(question), :html => { :method => :put}) do |f| %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t("org_admin.questions.question_number_label")%><%= f.number_field :number, :in => 1..50, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %> +
+
<%= t("org_admin.questions.question_text_label")%><%= f.text_area :text, :rows => "5" %> +
+
<%= t("org_admin.questions.answer_format_label")%>
+
+ <%= f.hidden_field :id,{ :class => "quest_id" } %> + <%= f.select :question_format_id, + options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, question.question_format_id), + {}, :id => "#{question.id}-select-format"%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "question_format_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_format_help_text_html"))%> +
+ +
+ + + +
+ + +
+ + +
+ +
+
+
+
<%= t("org_admin.questions.suggested_or_example_answer_label")%>
+ <% suggested_answer = question.suggested_answers.find_by_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 %> +
    +
  • <%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %>
  • +
  • <%= s.text_area :text, :rows => 5 %> +
  • +
+ <%end%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "suggested_answer_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%> +
+
+
+
<%= t("org_admin.questions.guidance_label")%>
+ <%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "question_guidance_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%> +
+
+
+
<%= t("org_admin.questions.themes_label")%>
+ <%= f.collection_select(:theme_ids, + Theme.all.order("title"), + :id, :title, {:prompt => false, :include_blank => "None"}, {:multiple => true})%> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "question_themes_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%> +
+
+
+ +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> + <% if !question.section.version.published? then%> + <%= link_to t("helpers.submit.delete"), admin_destroyquestion_dmptemplate_path(:question_id => question.id), + :confirm => t("org_admin.questions.delete_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> + <%end%> + <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <%= link_to t("helpers.submit.cancel"), "#", :class => "btn cancel cancel_edit_question" %> +
+
+ + + +<%= render :partial => "guidance_display", locals: {question: question}%> +<%end%> diff --git a/app/views/templates/_edit_section.html.erb b/app/views/templates/_edit_section.html.erb new file mode 100644 index 0000000..8f7f8b4 --- /dev/null +++ b/app/views/templates/_edit_section.html.erb @@ -0,0 +1,116 @@ + + + +<%= form_for(section, :url => admin_updatesection_dmptemplate_path(section, :phase => phase, :edit => edit), :html => { :method => :put}) do |s| %> + <%if @open && @section_id == section.id then%> + <% toggle = 'accordion-body section-collapse in collapse'%> + <%else%> + <% toggle = 'accordion-body collapse section-collapse' %> + <%end%> + + <%if @new_sec then%> + <% toggle = 'accordion-body section-collapse in collapse'%> + <%end%> + +
+
+
+
+ <%= s.text_field :title, :as => :string, :class => 'text_field', :placeholder => t('org_admin.templates.section_title_placeholder') %> + +
+
+ +
+ + +
+
+ + + + + + + + + +
<%= t('org_admin.templates.phase_order_label') %><%= s.number_field :number, :in => 1..15, :class => "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => t('org_admin.templates.section_number_help_text') %>
<%= t('org_admin.templates.desc_label') %> +
+ <%= text_area_tag("section-desc-#{section.id}", section.description , class: "tinymce") %> +
+
+ <%= link_to( image_tag('help_button.png'), '#', :class => 'section_desc_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.section_desc_help_text_html'))%> +
+
+ +
+ <%= s.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> + <% if !section.version.published? || phase.dmptemplate.org_type == constant("organisation_types.funder") then%> + <%= link_to t("helpers.submit.delete"), admin_destroysection_dmptemplate_path(:section_id => section.id), + :confirm => t("org_admin.templates.section_delete_message", :section_title => section.title ), :method => :delete, :class => "btn btn-primary"%> + <%end%> + <%= link_to t('helpers.submit.cancel'), :back, :class => 'btn cancel' %> +
+ <%end%> +
+ <% @questions = section.questions.order("number")%> + <%if @questions.count > 0 %> + <% question_left = @questions.count %> + <% @questions.each do |question| %> +
+
"> + + <%= render :partial => 'show_question', locals: {question: question} %> +
+ + +
+ + <%if question_left.to_i > 1 then %> +
+ <%else%> +
+ <%end%> + <% question_left = question_left - 1 %> + + <%end%> + <%end%> + + + <% if !section.version.published? || phase.dmptemplate.org_type == constant("organisation_types.funder") then%> + + <%if @questions.count != 0 %> +
+ <%end%> + + + + +
+
+ <%= hidden_field_tag :section_id, section.id, :class => "section_id" %> + <%= link_to t("org_admin.add_question_label"), '#', :class => "btn btn-primary add_question_button" %> +
+
+ <%end%> + +
+
+
+
diff --git a/app/views/templates/_edit_suggested_answer.html.erb b/app/views/templates/_edit_suggested_answer.html.erb new file mode 100644 index 0000000..2f78934 --- /dev/null +++ b/app/views/templates/_edit_suggested_answer.html.erb @@ -0,0 +1,26 @@ + +<%= form_for(suggested_answer, :url => admin_updatesuggestedanswer_dmptemplate_path(suggested_answer), :html => { :method => :put}) do |f| %> + <%= f.hidden_field :organisation_id, :value => current_user.organisation.id %> + + + + + + +
<%= t('org_admin.questions.suggested_or_example_answer_label')%> +
    +
  • <%= f.select :is_example, {t('org_admin.questions.example_answer_label') => true, t('org_admin.questions.suggested_answer_label') => false} %>
  • +
  • <%= f.text_area :text, :rows => 5 %>
  • +
+
+
+ + +
+ <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> + <%= link_to t("helpers.submit.delete"), admin_destroysuggestedanswer_dmptemplate_path(:suggested_answer => suggested_answer.id), + :confirm => t("org_admin.questions.delete_suggested_answer_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> + <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <%= link_to t('helpers.submit.cancel'), '#', :class => 'btn cancel cancel_edit_suggested_answer' %> +
+<%end%> diff --git a/app/views/templates/_edit_template.html.erb b/app/views/templates/_edit_template.html.erb new file mode 100644 index 0000000..dbea10a --- /dev/null +++ b/app/views/templates/_edit_template.html.erb @@ -0,0 +1,52 @@ + + +<%= form_for(dmptemplate, :url => admin_update_dmptemplate_path(dmptemplate), :html => { :method => :put}) do |f| %> +
+ + + + + + + + + + + + + + + + + + + + + +
<%= 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 %> +
+ + +
+ <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> + <%= link_to t('helpers.submit.cancel'), admin_template_dmptemplate_path(dmptemplate), :class => 'btn cancel' %> +
+ +
+ +<%end%> \ No newline at end of file diff --git a/app/views/templates/_edit_version.html.erb b/app/views/templates/_edit_version.html.erb new file mode 100644 index 0000000..416fdb7 --- /dev/null +++ b/app/views/templates/_edit_version.html.erb @@ -0,0 +1,47 @@ + + + +<%= form_for(version, :url => admin_updateversion_dmptemplate_path(version, :edit => edit, :phase => phase), :html => { :method => :put}) do |f| %> + +

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

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

+ <%= raw suggested_answer.text %> +

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

+ <%= raw suggested_answer.text %> +

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

+ <%= t('org_admin.templates.phase_details_label')%> + + + <% if @phase.dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> +
+ <%= link_to t("org_admin.templates.edit_phase_details_label"), '#', :class => "btn btn-primary", :id => "edit_phase_button"%> +
+ <%end%> +

+ +<%if @phase.dmptemplate.org_type != constant("organisation_types.funder") then%> +
+ <%= raw t('org_admin.templates.phase_details_text_html')%> +
+<%end%> + +
+
+ + + + + + + + + + + + + + +
<%= t('org_admin.templates.title_label') %><%= @phase.title %>
<%= t('org_admin.templates.phase_order_label') %><%= @phase.number %>
<%= t('org_admin.templates.desc_label') %><%= raw @phase.description %>
+
diff --git a/app/views/templates/_show_phases_sections.html.erb b/app/views/templates/_show_phases_sections.html.erb new file mode 100644 index 0000000..19c603a --- /dev/null +++ b/app/views/templates/_show_phases_sections.html.erb @@ -0,0 +1,73 @@ + + +
+ +
+

<%= raw phase.description %>

+
+ +<% if phase.versions.any? then %> + + <% version = phase.versions.where("published = ?", true).first %> + <% if version.nil? then%> + <% version = phase.versions.order("updated_at DESC").first %> + <%end%> + + +
+ + + <%if phase.has_sections == true then %> + <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(version), :class => 'btn btn-primary'%> + <%end%> + <% if phase.latest_published_version == nil then%> + <%= link_to t("helpers.submit.delete"), admin_destroyphase_dmptemplate_path(:phase_id => phase.id), + :confirm => t("org_admin.templates.phase_delete_message", :phase_title => phase.title ), :method => :delete, :class => "btn btn-primary"%> + <%end%> + <%if phase.dmptemplate.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder") then%> + <% b_label = t('org_admin.templates.view_phase_label')%> + <%else %> + <% b_label = t('org_admin.templates.edit_phase_label')%> + <%end%> + <%= link_to b_label, admin_phase_dmptemplate_path(phase), :class => "btn btn-primary" %> + +
+ <% if version.sections.any? then %> + + + + + + + + + <% version.sections.order("number ASC").each do |section| %> + <%if (section.organisation_id == phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> + + + + + <%end%> + <%end%> + +
<%= t('helpers.sections_label')%><%= t('helpers.questions_label')%>
+

<%= section.title %>

+
+ <% if section.questions.any? %> + <% questions = section.questions.order("number ASC") %> +
    + <% questions.each do |ques|%> +
  • + - <%= raw ques.text %> +
  • + <%end%> +
+ <%end%> +
+ + <%end%> + +<%end%> + + +
diff --git a/app/views/templates/_show_question.html.erb b/app/views/templates/_show_question.html.erb new file mode 100644 index 0000000..df79c2b --- /dev/null +++ b/app/views/templates/_show_question.html.erb @@ -0,0 +1,153 @@ + + +
+ + + + + + + + + + + + + + <%if q_format.title == t("helpers.text_field") || q_format.title == t("helpers.text_area") then %> + <%if !question.default_value.nil? then %> + + + + + <%end%> + <% end %> + + + + + + + + <% if (question.section.version.phase.dmptemplate.org_type != constant("organisation_types.funder") && question.section.organisation_id == current_user.organisation_id ) then%> + <% suggested_answer = question.get_suggested_answer(current_user.organisation.id) %> + <% if !suggested_answer.nil? && suggested_answer.text != "" then %> + + + + + <%end%> + <%end%> + + <%if !question.guidance.nil? then %> + + + + + <%end%> + + <% themes_q = question.themes %> + <%if !themes_q.nil? then%> + + + + + <%end%> +
<%= t('org_admin.questions.question_number_label')%><%= question.number%>
<%= t('org_admin.questions.question_text_label')%><%= raw question.text %> +
+
+ <% q_format = question.question_format %> + <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") then%> +
    + <% if question.options.is_a? Option then %> +
  • - <%= question.options.text %>
  • + <% else %> + <% if !question.options.to_a.nil? then %> + <% question.options.to_a.sort_by{|op| op['number']}.each do |o| %> +
  • - <%= o.text %>
  • + <%end%> + <% end %> + <% end %> +
+ <% end %> +
+
<%= t('org_admin.questions.default_value_label')%><%= raw question.default_value %>
<%= t('org_admin.questions.answer_format_label')%><%= q_format.title %> +
+ <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") 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 (question.section.version.phase.dmptemplate.org_type == constant("organisation_types.funder") && question.section.organisation_id != current_user.organisation_id ) then%> + <% suggested_answer = question.get_suggested_answer(current_user.organisation.id) %> + <% if !suggested_answer.nil? && suggested_answer.text != "" then %> +
+ <%= render :partial => 'show_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %> +
+ + + <%end%> + + + + + + <%end%> + +
+ + <%if (@edit == 'true'&& question.section.organisation_id == current_user.organisation_id) || (question.section.version.phase.dmptemplate.org_type == constant("organisation_types.funder") && question.section.organisation_id == current_user.organisation_id && current_user.org_type != constant("organisation_types.funder")) then%> +
+ <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <%= link_to t("org_admin.questions.question_edit_button"), '# ', :class => "btn btn-primary edit_question_button"%> + <% if !question.section.version.published? then%> + <%= link_to t("org_admin.questions.question_delete_button"), admin_destroyquestion_dmptemplate_path(:question_id => question.id), + :confirm => t("org_admin.questions.delete_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%> + <%end%> +
+ <%elsif (@edit == 'false' && question.section.organisation_id != current_user.organisation_id )|| (question.section.version.phase.dmptemplate.org_type == constant("organisation_types.funder") && question.section.organisation_id != current_user.organisation_id ) then%> + <% suggested_answer = question.get_suggested_answer(current_user.organisation.id) %> + <% if suggested_answer.nil? then %> +
+
+ <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <%= link_to t("org_admin.questions.suggested_or_example_answer_button"), '# ', :class => "btn btn-primary add_suggested_answer_button"%> +
+
+ <%end%> + <%end%> +
+
+ + + +<%= render :partial => 'guidance_display', locals: {question: question}%> diff --git a/app/views/templates/_show_section.html.erb b/app/views/templates/_show_section.html.erb new file mode 100644 index 0000000..1dbf719 --- /dev/null +++ b/app/views/templates/_show_section.html.erb @@ -0,0 +1,43 @@ + +<%if @open && @section_id == section.id then%> + <% toggle = 'accordion-body section-collapse in collapse'%> +<%else%> + <% toggle = 'accordion-body collapse section-collapse' %> +<%end%> +
+
+ +
+ <% if section.title == '' then%> + <%= t('org_admin.templates.new_section')%> + <%else%> + <%= section.title %> + <%end%> +
+ + +
+
+
+
+ <%= raw section.description %> +
+
+ <% section.questions.order("number").each do |question| %> + <% last_question_id = section.questions.order("number DESC").first.id %> + +
+ + <%= render :partial => 'show_question', locals: {question: question}%> +
+ + <% if last_question_id == question.id then %> +
+ <% else %> +
+ <% end %> + + <%end%> +
+
+
diff --git a/app/views/templates/_show_suggested_answer.html.erb b/app/views/templates/_show_suggested_answer.html.erb new file mode 100644 index 0000000..888dd45 --- /dev/null +++ b/app/views/templates/_show_suggested_answer.html.erb @@ -0,0 +1,19 @@ + + + + + + +
+ <% if suggested_answer.is_example? then %> + <%= t('org_admin.questions.example_answer_label')%> + <%else%> + <%= t('org_admin.questions.suggested_answer_label')%> + <%end%> + <%= raw suggested_answer.text %>
+
+ +
+ <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <%= link_to t("org_admin.questions.edit_suggested_answer_button"), '# ', :class => "btn btn-primary edit_form_for_suggested_answer"%> +
diff --git a/app/views/templates/_show_template.html.erb b/app/views/templates/_show_template.html.erb new file mode 100644 index 0000000..7cfec9d --- /dev/null +++ b/app/views/templates/_show_template.html.erb @@ -0,0 +1,43 @@ + + +<% if @dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> +

+
+ <%= link_to t("org_admin.templates.edit_details"), '# ', :class => "btn btn-primary", :id => "edit_template_button"%> +
+

+<%end%> +
+ + + + + + + + + + + + + + + + + + + + + + +
<%= 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 %>
diff --git a/app/views/templates/_show_version.html.erb b/app/views/templates/_show_version.html.erb new file mode 100644 index 0000000..3e1456e --- /dev/null +++ b/app/views/templates/_show_version.html.erb @@ -0,0 +1,42 @@ + + + +

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

+
+ + + + + + + <% if version.description != "" then%> + + + + + <%end%> + + + + + + + + + + + + +
<%= t('org_admin.templates.title_label') %><%= version.title %>
<%= t('org_admin.templates.desc_label') %><%= raw version.description %>
<%= t('org_admin.templates.published_label') %><%= version.published %>
<%= t('org_admin.templates.created') %> + <%= l version.created_at.to_date, :formats => :short %> +
<%= t('org_admin.templates.last_updated') %> + <%= l version.updated_at.to_date, :formats => :short %> +
+
+ + + + + diff --git a/app/views/templates/_versions_table.html.erb b/app/views/templates/_versions_table.html.erb new file mode 100644 index 0000000..e51dbfe --- /dev/null +++ b/app/views/templates/_versions_table.html.erb @@ -0,0 +1,73 @@ +<%if !phase.versions.nil? then %> +
+

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

+

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

+ + + + + + + + + + + + + + <% phase.versions.each do |v|%> + + + + + + + + + + + + + <%end%> + +
<%= t('org_admin.templates.title_label')%><%= t('org_admin.templates.published_label')%><%= t('org_admin.templates.created')%><%= t('org_admin.templates.last_updated') %><%= t('org_admin.templates.actions') %>
+ <%= v.title %> + + <%= v.published %> + + <%= l v.created_at.to_date, :formats => :short %> + + <%= l v.updated_at.to_date, :formats => :short %> + + <%= link_to t("helpers.view"), admin_phase_dmptemplate_path( :version_id => v.id, :id => phase.id , :edit => 'false'), :class => "dmp_table_link"%> + <% if v.published? then%> + + <%= t('org_admin.versions.edit_label')%> + + <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> + <%else%> + <%= link_to t("org_admin.versions.edit_label"), admin_phase_dmptemplate_path(phase, :version_id => v.id, :edit => 'true'), :class => "dmp_table_link" %> + <%= link_to t("helpers.preview"), admin_previewphase_dmptemplate_path(v), :class => "dmp_table_link" %> + <%#= link_to t("helpers.submit.delete"), admin_destroyversion_dmptemplate_path(:version_id => v.id, :phase => phase , :edit => 'false'), + :confirm => t("org_admin.versions.delete_message", :version_title => v.title ), :method => :delete, :class => "dmp_table_link"%> + <%end%> +
+
+ + + +<%end%> diff --git a/app/views/templates/admin_addphase.html.erb b/app/views/templates/admin_addphase.html.erb new file mode 100644 index 0000000..6e8a336 --- /dev/null +++ b/app/views/templates/admin_addphase.html.erb @@ -0,0 +1,75 @@ +<%- model_class = Phase -%> +<%= stylesheet_link_tag "admin" %> +<% javascript "admin.js" %> + +

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

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

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

+ <%= raw t("org_admin.templates.phase_new_text_html")%> +
+
+ <%= f.hidden_field :dmptemplate_id, :value => @dmptemplate.id%> + + + + + + + + + + + + + +
<%= t("org_admin.templates.title_label") %><%= f.text_field :title, + :as => :string, + :class => "text_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.phase_title_help_text") %>
<%= t("org_admin.templates.phase_order_label") %><%= f.number_field :number, :in => 1..5, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.templates.phase_number_help_text") %>
<%= t("org_admin.templates.desc_label") %> +
+ <%= text_area_tag("phase-desc","" , class: "tinymce") %> +
+
+ <%= link_to( image_tag("help_button.png"), "#", :class => "phase_desc_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.templates.phase_desc_help_text_html"))%> +
+
+
+
+ + +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), admin_dmptemplate_path(@dmptemplate), :class => "btn cancel" %> +
+ + <%end%> +
+
+
+
+ +<%= tinymce :content_css => asset_path("application.css") %> \ No newline at end of file diff --git a/app/views/templates/admin_index.html.erb b/app/views/templates/admin_index.html.erb new file mode 100644 index 0000000..b22018c --- /dev/null +++ b/app/views/templates/admin_index.html.erb @@ -0,0 +1,153 @@ +<%= stylesheet_link_tag "admin" %> + +

+ <%= t('org_admin.templates_label') %> +

+
+

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

+ +
+ <%= raw t('org_admin.templates.create_own_template_text_html')%> +
+
+ +
+ <%= link_to t("org_admin.templates.create_template"), + admin_new_dmptemplate_path, + :class => 'btn btn-primary' %> +
+
+
+ + +<% if @dmptemplates_own.count > 0 then %> + + + + + + + + + + + + <% @dmptemplates_own.each do |org_template| %> + + + + + + + + + <%end%> + +
<%= 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"%> +
+ +<%end%> + +
+
+ + +<% if current_user.org_type != constant("organisation_types.funder") then %> +

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

+ + + <% if @dmptemplates_funders.count > 0 then %> + + + + + + + + + + + + + + <% @dmptemplates_funders.each do |org_template| %> + <% if org_template.published? ||org_template.has_customisations?(current_user.organisation_id, org_template) then %> + + + + + + + + <%end%> + <%end%> + +
<%= 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"%> +
+ <%end%> +<%end%> diff --git a/app/views/templates/admin_new.html.erb b/app/views/templates/admin_new.html.erb new file mode 100644 index 0000000..798f855 --- /dev/null +++ b/app/views/templates/admin_new.html.erb @@ -0,0 +1,48 @@ +<%= stylesheet_link_tag "admin" %> +<% javascript "admin.js" %> + +

+ <%= t("org_admin.templates.new_label") %> + +
+ <%= link_to t("org_admin.templates.view_all_templates"), + admin_index_dmptemplate_path, + :class => "btn btn-primary" %> +
+

+ +
+
+ +
+ <%= raw t("org_admin.templates.create_new_template_text_html")%> +
+ <%= form_for :dmptemplate, :url => {:action => "admin_create"} do |f| %> + + + + + + + + + + +
<%= 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"))%> +
+
+ +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %> + <%= link_to t("helpers.submit.cancel"), admin_index_dmptemplate_path, :class => "btn cancel" %> +
+
+ <%end%> +
+
+<%= tinymce :content_css => asset_path("application.css") %> \ No newline at end of file diff --git a/app/views/templates/admin_phase.html.erb b/app/views/templates/admin_phase.html.erb new file mode 100644 index 0000000..b85927b --- /dev/null +++ b/app/views/templates/admin_phase.html.erb @@ -0,0 +1,82 @@ +<%- model_class = Phase -%> +<%= stylesheet_link_tag "admin" %> +<% javascript 'admin.js' %> + +<%= tinymce :content_css => asset_path('application.css') %> + +

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

+ +
+ + +<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @phase.dmptemplate, active: @phase.id} %> + + +
+
+ + +
+
+ + +
+ <%= render :partial => "show_phase", locals: {phase: @phase}%> +
+ <% if @phase.dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> + + + + <%= render :partial => "versions_table", locals: {phase: @phase}%> + <%end%> + + + <% if @edit == "false" || (@phase.dmptemplate.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder")) then%> + <%= render :partial => 'show_version', locals: {version: @version}%> + <%elsif @edit == "true" || current_user.org_type == constant("organisation_types.funder") then %> + <%= render :partial => 'edit_version', locals: {version: @version, edit: @edit, phase: @phase} %> + <%end%> +
+
+ + + <% @sections.order("number ASC").each do |section| %> + <%if (@edit == "true" && section.organisation_id == current_user.organisation_id) || + (@phase.dmptemplate.org_type == constant("organisation_types.funder") && section.organisation_id == current_user.organisation_id && current_user.org_type != constant("organisation_types.funder"))then%> + <%= render :partial => 'edit_section', locals: {section: section, edit: @edit, phase: @phase, version: @version} %> + <%elsif (section.organisation_id == @phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> + <%= render :partial => 'show_section', locals: {section: section}%> + <%end%> + <% end %> + +
+
+ + + + <% if !@version.published? || (@phase.dmptemplate.org_type == constant("organisation_types.funder") && current_user.org_type != constant("organisation_types.funder"))then %> + + + + + +
+
+ <%= link_to t('org_admin.add_section_label'),'#', :id => 'add_section_button', :class =>'btn btn-primary' %> +
+
+ <%end%> + + diff --git a/app/views/templates/admin_previewphase.html.erb b/app/views/templates/admin_previewphase.html.erb new file mode 100644 index 0000000..12c2507 --- /dev/null +++ b/app/views/templates/admin_previewphase.html.erb @@ -0,0 +1,64 @@ +<%- model_class = Phase -%> +<%= stylesheet_link_tag "admin" %> + +

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

+ +
+ + +<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @version.phase.dmptemplate, active: @version.phase_id} %> + + +
+
+ <% sections = @version.sections %> + <% sections.order(:number).each do |section| %> + <%if (section.organisation_id == @version.phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> + +
+ +
+
+ <%= raw section.description %> +
+
+ <% section.questions.order("number").each do |question| %> + <% last_question_id = section.questions.order("number DESC").first.id%> + + + <%= render :partial => 'preview_question', locals: {question: question}%> + + <% if last_question_id == question.id then %> +
+ <% else %> +
+ <% end %> + + <%end%> +
+
+
+ <%end%> + <%end%> +
+
\ No newline at end of file diff --git a/app/views/templates/admin_template.html.erb b/app/views/templates/admin_template.html.erb new file mode 100644 index 0000000..642fb15 --- /dev/null +++ b/app/views/templates/admin_template.html.erb @@ -0,0 +1,61 @@ +<%= stylesheet_link_tag "admin" %> +<% javascript 'admin.js' %> + +

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

+ +
+ + +<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @dmptemplate, active: "show_template"} %> + + +
+
+ <% if @dmptemplate.org_type != constant("organisation_types.funder") || current_user.org_type == constant("organisation_types.funder") then %> + + <%end%> +
+ <%= render :partial => "show_template", locals: {dmptemplate: @dmptemplate}%> +
+
+ + <% if !@dmptemplate.phases.nil? then %> + <% if @dmptemplate.phases.count == 1 then %> + <% @dmptemplate.phases.each do |phase| %> + + <%= render :partial => 'show_phases_sections', locals: {phase: phase}%> + <%end%> + <%else%> + <% @dmptemplate.phases.order(:number).each do |phase| %> +
+
+ +
+
+ + <%= render :partial => 'show_phases_sections', locals: {phase: phase}%> +
+
+
+
+ <%end%> + <%end%> + <%end%> +
+ +<%= tinymce :content_css => asset_path('application.css') %> diff --git a/app/views/templates/export.pdf.erb b/app/views/templates/export.pdf.erb new file mode 100644 index 0000000..3726b39 --- /dev/null +++ b/app/views/templates/export.pdf.erb @@ -0,0 +1,23 @@ + + + + + + <%= @template.title %> + + + + +

<%= @template.title %>

+ + \ No newline at end of file