diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb new file mode 100644 index 0000000..5c08f41 --- /dev/null +++ b/app/controllers/phases_controller.rb @@ -0,0 +1,47 @@ +class PhasesController < ApplicationController + + after_action :verify_authorized + + TEXTAREA = QuestionFormat.where(title: "Text area").first.id + TEXTFIELD = QuestionFormat.where(title: "Text field").first.id + RADIO = QuestionFormat.where(title: "Radio buttons").first.id + CHECKBOX = QuestionFormat.where(title: "Check box").first.id + DROPDOWN = QuestionFormat.where(title: "Dropdown").first.id + MULTI = QuestionFormat.where(title: "Multi select box").first.id + + # GET /phases/1/edit + def edit + + @textarea = TEXTAREA + @textfield = TEXTFIELD + @radio = RADIO + @checkbox = CHECKBOX + @dropdown = DROPDOWN + @multi = MULTI + + @plan = Plan.find(params[:plan_id]) + authorize @plan + @phase = Phase.where(template_id: @plan.template_id, slug: params[:id]).first + + @sections = @phase.sections + @section_answers = Hash.new + @phase.sections.each do |section| + nanswers = 0 + questions = section.questions + questions.each do |q| + answers = q.answers.where(plan_id: @plan) + nanswers += answers.count + end + @section_answers[section.id] = nanswers + end + + if !user_signed_in? then + respond_to do |format| + format.html { redirect_to edit_user_registration_path } + end + end + + end + + +end diff --git a/app/helpers/phases_helper.rb b/app/helpers/phases_helper.rb new file mode 100644 index 0000000..610c227 --- /dev/null +++ b/app/helpers/phases_helper.rb @@ -0,0 +1,2 @@ +module PhasesHelper +end diff --git a/app/models/plan_guidance_group.rb b/app/models/plan_guidance_group.rb new file mode 100644 index 0000000..7b76499 --- /dev/null +++ b/app/models/plan_guidance_group.rb @@ -0,0 +1,11 @@ +# Used to link plans to guidance groups +# the links are created at plan creation stage +# and link to all possible GGs +# then the selected field keeps track of which ones the user has turned on /off +# +class PlanGuidanceGroup < ActiveRecord::Base + belongs_to :plan + belongs_to :guidance_group + + attr_accessible :selected +end diff --git a/app/views/phases/_add_note.html.erb b/app/views/phases/_add_note.html.erb new file mode 100644 index 0000000..00584fd --- /dev/null +++ b/app/views/phases/_add_note.html.erb @@ -0,0 +1,20 @@ + + +<% new_note = Note.new %> +<% answerid = answer.id %> + +<%= form_for :new_note, + :url => {:controller => :notes, :action => :create }, + :html=>{:method=>:post, :id => "new_note_form_#{answerid}", :class => "add_note_form"} do |f| %> + <%= f.hidden_field :user_id, :value => current_user.id %> + <%= f.hidden_field :answer_id, :value => answerid %> + + <%= text_area_tag("#{answerid}new_note_text".to_sym, "" , class: "tinymce") %> +
+ + +
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary new_comment_submit_button" %> +
+
+<%end%> diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb new file mode 100644 index 0000000..289ef9b --- /dev/null +++ b/app/views/phases/_answer_form.html.erb @@ -0,0 +1,209 @@ + + +
+ + <% q_format = question.question_format %> + +
+ <%= semantic_form_for answer, :url => {:controller => :answers, :action => :update }, :html=>{:method=>:put}, :remote => true do |f| %> + <%= f.inputs do %> + <%= f.input :plan_id, :as => :hidden %> + <%= f.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %> + <%= f.input :question_id, :as => :hidden, :input_html => { :class => "question_id" } %> + + + + <%= raw question.text %> + + + <% suggested_answer = question.suggested_answers.where(org_id: plan.template.org_id).first %> + <% if suggested_answer && suggested_answer.text.present? %> +
+ + <% 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 %> + + + <% if [ @checkbox, @multi, @radio, @dropdown ].include?( q_format.id ) %> + <% options = question.options.order("number") %> + + + <% if q_format.id == @checkbox %> + <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, :input_html => { :id => "options-#{question.id}" } %> + <% elsif q_format.id == @multi %> + <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true , :id => "options-#{question.id}" } %> + <% elsif q_format.id == @radio %> +
    + <% options.each do |op| %> +
  1. + <% if answer.option_ids[0] == op.id then%> + <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%> + <%else%> + <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%> + <% end %> + <%= raw op.text %>
  2. + <% end %> +
+ <% elsif q_format.id == @dropdown %> + <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :id => "options-#{question.id}" } %> + <% end %> + + + + <% if question.option_comment_display == true %> + <%= label_tag("answer-text-#{question.id}".to_sym, t("helpers.comment")) %> + <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> + <%end%> + <% end %> + + <% if q_format.id == @textfield %> + <%= text_field_tag("answer-text-#{question.id}".to_sym, strip_tags(answer.text), class: "question_text_field") %> + <% elsif q_format.id == @textarea %> + <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> + <% end %> + + <% end %> + + + <%= f.actions do %> + <%= f.action :submit, :label => t("helpers.save"), :button_html => { :class => "btn btn-primary"} %> + + <% end %> + <% end %> +
+ + <% if answer.created_at.nil? %> + <%= t("helpers.notanswered") %> + <% else %> + <%= t("helpers.answered_by")%><%= answer.created_at %><%= t("helpers.answered_by_part2")%><%= answer.user.name %> + <% end %> +
+ + + + +
+ +
+ <% comments = answer.notes.all %> + <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + +
+ + + +
+
+ + + <% if question.guidance.present? %> +
+ + + + + +
+
<%= raw question.guidance %>
+
+ +
+ <% end %> + + + + + <% question_guidances.each_index do |gindex| %> + <% qguidance = @question_guidances[gindex] + orgname = qguidance[:orgname] + theme = qguidance[:theme] + guidance = qguidance[:guidance] + %> + +
+ + + + + +
+
<%= raw guidance.text %>
+
+ +
+ <% end %> + +
+
+ + +
+ <%= render :partial => "note", locals: {answer: answer, plan: plan}%> +
+ +
+ + +<% if last_question_id == question.id then %> +
+<% else %> +
+<% end %> diff --git a/app/views/phases/_answer_form_ro.html.erb b/app/views/phases/_answer_form_ro.html.erb new file mode 100644 index 0000000..64a0fb0 --- /dev/null +++ b/app/views/phases/_answer_form_ro.html.erb @@ -0,0 +1,248 @@ + +<% answer = @plan.answer(question.id) %> + +
+ + <% q_format = question.question_format%> + + <% if readonly != "always" then %> +
> + <%= semantic_form_for answer, :url => {:controller => :answers, :action => :create }, :html=>{:method=>:post}, :remote => true do |f| %> + <%= f.inputs do %> + <%= f.input :plan_id, :as => :hidden %> + <%= f.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %> + <%= f.input :question_id, :as => :hidden, :input_html => { :class => "question_id" } %> + + + + <%= raw question.text %> + + + <% suggested_answer = question.suggested_answers.where(org_id: @plan.template.org_id).first %> + <% if suggested_answer.present? %> +
+ + <% 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 %> + + + <% 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 readonly then %> + <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, input_html => { :disabled => true, :id => "options-#{question.id}" } %> + <% else %> + <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, :input_html => { :id => "options-#{question.id}" } %> + <% end %> + + <% elsif q_format.title == t("helpers.multi_select_box") then %> + <% if readonly then %> + <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true, :disabled => true , :id => "options-#{question.id}" } %> + <% else %> + <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true , :id => "options-#{question.id}" } %> + <% end %> + + <% elsif q_format.title == t("helpers.radio_buttons") then%> +
    + <% options.each do |op| %> +
  1. + <% if answer.option_ids[0] == op.id then%> + <% if readonly then %> + <%= f.radio_button :option_ids, op.id, :checked => true, disabled: true, id: "answer_option_ids_#{op.id}"%> + <% else %> + <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%> + <% end %> + <%else%> + <% if readonly then %> + <%= f.radio_button :option_ids, op.id, :checked => false, disabled: true, id: "answer_option_ids_#{op.id}"%> + <% else %> + <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%> + <% end %> + <% end %> + <%= op.text %>
  2. + <% end %> +
+ + <% elsif q_format.title == t("helpers.dropdown") then%> + <% if readonly then %> + <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :disabled => true, :id => "options-#{question.id}" } %> + <% else %> + <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :id => "options-#{question.id}" } %> + <% end %> + <% end %> + + <% if question.option_comment_display == true then%> + <%= label_tag("answer-text-#{question.id}".to_sym, t("helpers.comment")) %> + <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> + <%end%> + + + <% elsif q_format.title == t("helpers.text_field") then %> + <%= text_field_tag("answer-text-#{question.id}".to_sym, strip_tags(answer.text), class: "question_text_field") %> + + <% elsif q_format.title == t("helpers.text_area") then%> + <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> + <% end %> + + <% end %> + + + <%= f.actions do %> + <% if readonly then %> + <%= f.action :submit, :label => t("helpers.save"), :button_html => { :class => "btn btn-primary"}, :input_html => { :disabled => true } %> + <% else %> + <%= f.action :submit, :label => t("helpers.save"), :button_html => { :class => "btn btn-primary"} %> + <% end %> + + <% end %> + <% end %> +
+ <% end %> + +
> +

<%= question.text %>

+
+ <% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") %> +
    + <% if answer.options.is_a? Option then %> +
  • <%= answer.options.text %>
  • + <% else %> + <% answer.options.each do |o| %> +
  • <%= o.text %>
  • + <% end %> + <% end %> +
+ <% end %> +
+ <%= raw answer.text %> +
+
+
+ <% if answer.created_at.nil? then %> + <%= t("helpers.notanswered") %> + <% else %> + <%= t("helpers.answered_by")%><%= answer.created_at %><%= t("helpers.answered_by_part2")%><%= answer.user.name %> + <% end %> + +
+ + + +
+
+ <% @comments = Notes.where("question_id = ? AND plan_id = ?", question.id, answer.plan_id ) %> + <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> + <% @question_guidances = @plan.guidance_for_question(question) %> + +
+ + + +
+
+ + <% if !question.guidance.nil? && question.guidance != "" then %> + + <% end %> + + <% @question_guidances.each_pair do |group,themes| %> + <% themes.each_pair do |theme,guidances| %> + <% guidances.each do |guidance| %> + + <% end %> + <% end %> + <% end %> +
+
+ + +
+ <%= render :partial => "comments", locals: {questionId: question.id, plan_id: answer.plan_id }%> +
+ + + +
+ +<% if last_question_id == question.id then %> +
+<% else %> +
+<% end %> diff --git a/app/views/phases/_archive_note.html.erb b/app/views/phases/_archive_note.html.erb new file mode 100644 index 0000000..904c82d --- /dev/null +++ b/app/views/phases/_archive_note.html.erb @@ -0,0 +1,23 @@ + +<%= form_for(note, :url => {:controller => :notes, :action => :archive } , :html => { :method => :put, :class => "archive_note_form", :id => "archive_note_form_#{note.id}"}) do |f| %> + <%= f.hidden_field :id, :value => note.id %> + <%= f.hidden_field :archived_by, :value => current_user.id %> + + <%= render :partial => "view_note", locals: {note: note} %> + + <% if current_user.id == note.user_id then %> + <%= t('helpers.notes.archive_own_note_question')%> + <% button_label = t("helpers.notes.archive_own_comment_button_label") %> + <% else%> + <%= t("helpers.notes.archive_note_question")%> + <% button_label = t("helpers.notes.archive_comment_button_label") %> + <%end%> + + +
+ <%= hidden_field_tag :note_id, note.id, :class => "comment_id" %> + <%= f.submit button_label, :class => "btn btn-primary archive_comment_submit_button" %> + <%= link_to t("helpers.submit.cancel"), "#", :class => "cancel_archive_comment btn cancel" %> +
+
+<%end%> diff --git a/app/views/phases/_edit_note.html.erb b/app/views/phases/_edit_note.html.erb new file mode 100644 index 0000000..f931d7f --- /dev/null +++ b/app/views/phases/_edit_note.html.erb @@ -0,0 +1,16 @@ + + +<%= form_for(note, :url => {:controller => :notes, :action => :update } , :html => { :method => :put, :class => "edit_note_form", :id=> "edit_note_form_#{note.id}"}) do |f| %> + <%= f.hidden_field :id, :value => note.id %> + + <%= text_area_tag("#{note.id}_note_text".to_sym, note.text , class: "tinymce") %> +
+ + +
+ <%= hidden_field_tag :answer, note.answer_id, :class => "answer_id" %> + <%= hidden_field_tag :note_id, note.id, :class => "note_id" %> + <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary edit_note_submit_button" %> +
+
+<%end%> diff --git a/app/views/phases/_list_notes.html.erb b/app/views/phases/_list_notes.html.erb new file mode 100644 index 0000000..12b17ab --- /dev/null +++ b/app/views/phases/_list_notes.html.erb @@ -0,0 +1,87 @@ + + +<% if notes.count > 1 then%> + <% style_to_add = "height:150px; overflow-y:auto;" %> +<%else%> + <% style_to_add = "" %> +<%end%> + +
+ +
+ + + <% notes.order("updated_at DESC").each do |c|%> + + + + + <%end%> + +
+ <% user = c.user %> + <%= user.name %>
+ (<%= l c.updated_at, format: :custom %>) +
+ + <% if c.archived %> + + <% if c.archived_by == current_user.id %> + <%= t("helpers.comments.retracted")%> + <% else %> + <% archived_by_user = User.find(c.archived_by) %> + <%= t("helpers.comments.clear_by")%> <%= archived_by_user.name %> + <%end%> + + <%else%> + + <%= link_to t("helpers.comments.view_label"),"#", :class => "dmp_table_link view_comment_button" %> + <%= hidden_field_tag :note_id, c.id, :class => "comment_id" %> + + <% if current_user.id == c.user_id %> + <%= link_to t("helpers.comments.edit_label"),"#", :class => "dmp_table_link edit_comment_button" %> + <%= hidden_field_tag :note_id, c.id, :class => "comment_id" %> + <%= link_to t("helpers.comments.retract_label"),"#", :class => "dmp_table_link archive_comment_button" %> + <% end%> + + <% if @plan.administerable_by?(current_user.id) && current_user.id != c.user_id %> + <%= hidden_field_tag :note_id, c.id, :class => "comment_id" %> + <%= link_to t("helpers.comments.clear_label"),"#", :class => "dmp_table_link archive_comment_button" %> + <% end%> + <%end%> + +
+
+ +
+ + +<% notes_not_archived = notes.where("archived IS NULL") %> +<% latest_note = notes_not_archived.order("updated_at DESC").first %> +<% if !latest_note.nil? then%> +
+ <%= render :partial => "view_note", locals: {note: latest_note} %> +
+
+<%end%> + +<%notes.order("updated_at DESC").each do |com|%> + + + + + + + + + +<%end%> diff --git a/app/views/phases/_note.html.erb b/app/views/phases/_note.html.erb new file mode 100644 index 0000000..9a9906a --- /dev/null +++ b/app/views/phases/_note.html.erb @@ -0,0 +1,37 @@ + + + <% notes = answer.notes.all %> + <% answerid = answer.id %> + <%= hidden_field_tag :answer_id, answer.id %> + + <% if notes.count > 0 %> + + +
+ <%= link_to t("helpers.comments.add_comment_label"),'#', :class => "btn btn-primary add_comment_button" %> +
+ +
+ + + <%= render :partial => "list_notes", locals: {notes: notes, plan:plan} %> + +
+ + +
+ <%= link_to t("helpers.comments.add_comment_label"),'#', :class => "btn btn-primary add_comment_button" %> +
+ +
+ + + + + <% else%> + <%= t("helpers.comments.add_comment_text")%> + <%= render :partial => "add_note", locals: {answer: answer}%> + <% end%> diff --git a/app/views/phases/_view_note.html.erb b/app/views/phases/_view_note.html.erb new file mode 100644 index 0000000..6b7737f --- /dev/null +++ b/app/views/phases/_view_note.html.erb @@ -0,0 +1,11 @@ + +<% user = User.find(note.user_id) %> +
+
+
+ +
diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb new file mode 100644 index 0000000..51e638a --- /dev/null +++ b/app/views/phases/edit.html.erb @@ -0,0 +1,166 @@ +<%- model_class = Plan -%> +<% javascript "plans.js" %> + + + + + +<%= render :partial => "/plans/plan_title", locals: {plan: @plan} %> + + + +<% status = @plan.status %> +
+ <%space_used = status["space_used"].to_i + space_title = t("helpers.plan.export.space_used", space_used: space_used, num_pages: @plan.template.settings(:export).max_pages) + answered = %(#{status["num_answers"]}/#{status["num_questions"]})%> +
+ <%= answered -%> <%= t("helpers.project.questions_answered")%> + ;" title="<%= answered -%> <%= t("helpers.project.questions_answered")%>"> +
+ +
+ +
+ = 100 ? "class=bar-full-text" : "" -%>><%= space_title -%> + " style="width: <%= space_used -%>%;" title="<%= space_title -%>"> +
+
+ + + +<%= render :partial => "/plans/plan_nav_tabs", locals: {plan: @plan, active: @phase.title } %> + + + +
+ +
+ <% @sections.each do |section| %> + + + <% if session[:question_id_comments].to_i != 0 then %> + <% question_from_comment = Question.find(session[:question_id_comments])%> + <% if section.id == question_from_comment.section_id then %> + <%= hidden_field_tag :comment_section_id, question_from_comment.section_id, :class => "comment_section_id" %> + <%end%> + <% end%> + + + +
+ + + <% num_section_questions = section.questions.count %> + <% num_section_answers = @section_answers[section.id] %> + <% question_word = "questions" %> + <% if num_section_questions == 1 then %> + <% question_word = "question" %> + <% end %> + <% section_status = "#{num_section_questions} #{question_word}, #{num_section_answers} answered" %> + + + + + +
+
+ <%= raw section.description %> +
+ +
+ + +
+

<%= t ('helpers.loading')%>

+
+ + + + +
+ <% section.questions.order("number").each do |question| %> + <% if question.id == session[:question_id_comments].to_i then id_css = "current_question" end %> +
+ <% partialname = "answer_form" + if @readonly + partialname += "_ro" + end + %> + + <% guidances = @plan.guidance_for_question(question) %> + + <%= render partial: partialname, + locals: { + plan: @plan, + answer: @plan.answer(question.id), + question_guidances: guidances, + question: question, + last_question_id: section.questions.order("number DESC").first.id + } + %> +
+ <% end %> +
+
+
+
+ + + + + <% end %> +
+ + <%= tinymce :content_css => asset_path("application.css"), :setup => "function(editor){editor.on('change', function(e){$.fn.check_textarea(editor)});}" %> +
+ +
+ <%= t("helpers.export") %> +
+<%= render :partial => "plans/export", locals: {plan: @plan} %> + + +<% session.delete(:question_id_comments)%> diff --git a/app/views/plans/_dropdowns_new_plan.html.erb b/app/views/plans/_dropdowns_new_plan.html.erb new file mode 100644 index 0000000..5413579 --- /dev/null +++ b/app/views/plans/_dropdowns_new_plan.html.erb @@ -0,0 +1,41 @@ + + +<%= semantic_form_for @plan, :url => {:controller => :plans, :action => :create }, :html=>{:method=>:post} do |f| %> + <%= f.inputs do %> + <%= hidden_field_tag :default_tag, "false" ,:id => "default_tag" %> +
+ +

<%= t('helpers.project.create_page.title') %>

+
+

<%= raw t('helpers.project.create_page.desc_html')%>

+
+ + + + <% end %> + + + <%= f.actions do %> + <%= f.action :submit, + :as => :button, + :input_html => { :id => "create-plan-button", :class => "btn btn-primary"}, + :label => t('helpers.project.create') %> + <% end %> + +<% end %> diff --git a/app/views/plans/_plan_details.html.erb b/app/views/plans/_plan_details.html.erb new file mode 100644 index 0000000..430288b --- /dev/null +++ b/app/views/plans/_plan_details.html.erb @@ -0,0 +1,321 @@ + +
+ + + + +
"> + +
+

+ <%= raw t('helpers.project.project_details_editing_text_html')%> +

+
+ + +
+ + <%= semantic_form_for @plan, :url => {:controller => :plans, :action => :update }, :html=>{:method=>:put} do |f| %> + <%= f.inputs do %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t('helpers.project.project_name') %> + <%= f.text_field :title, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.project_name_help_text') %> +
<%= t('helpers.project.project_identifier') %> + <%= f.text_field :identifier, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.project_identifier_help_text') %> +
<%= t('helpers.project.grant_title') %> + <%= f.text_field :grant_number, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.grant_help_text') %> +
<%= t('helpers.project.principal_investigator') %> + <%= f.text_field :principal_investigator, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.principal_investigator_help_text') %> +
<%= t('helpers.project.principal_investigator_id') %> + <%= f.text_field :principal_investigator_identifier, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.principal_investigator_id_help_text') %> +
<%= t('helpers.project.project_data_contact') %> + <%= f.text_field :data_contact, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.project_data_contact_help_text') %> +
<%= t('helpers.desc') %> + <%= f.text_area :description, { :rows => 7, :class => 'text_area has-tooltip', 'data-toggle' => "tooltip", 'data-html' => "true", 'title'=> t('helpers.project.project_desc_help_text_html')} %> +
+
+ <% end %> + + <%= f.actions do %> +
+ <%= f.submit t("helpers.submit.save"), :class => 'btn btn-primary' %> + <%= t("helpers.links.cancel") %> +
+ <%end%> + <%end%> +
+ + + +
"> +
+

<%= t('helpers.project.project_details_text_html')%>

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + <% if !@plan.principal_investigator_identifier.nil? && @plan.principal_investigator_identifier != "" then %> + + + + + <%end%> + + + + + + + + +
<%= t('helpers.project.project_name') %><%= @plan.title %>
<%= t('helpers.project.project_identifier') %> + <% if !@plan.identifier.nil? && @plan.identifier != "" then %> + <%= @plan.identifier %> + <%else%> + - + <%end%> +
<%= t('helpers.project.grant_title') %> + <% if !@plan.grant_number.nil? && @plan.grant_number!= "" then %> + <%= @plan.grant_number %> + <%else%> + - + <%end%> +
<%= t('helpers.project.principal_investigator') %><% if !@plan.principal_investigator.nil? && @plan.principal_investigator != "" then %> + <%= @plan.principal_investigator %> + <%else%> + - + <%end%> +
<%= t('helpers.project.principal_investigator_id') %> + <%= @plan.principal_investigator_identifier %> +
<%= t('helpers.project.project_data_contact') %><% if !@plan.data_contact.nil? && @plan.data_contact != "" then%> + <%= @plan.data_contact %> + <%else%> + - + <%end%> +
<%= t('helpers.desc') %><% if !@plan.description.nil? && @plan.description != "" then%> + <%= @plan.description %> + <%else%> + - + <%end%> +
+
+
+ + + +
+
+ +
+
+ <%= semantic_form_for @plan, :url => {:controller => :plans, :action => :update_guidance_choices }, :html=>{:method=>:put}, :remote => true do |f| %> + <%= f.inputs do %> + <%= f.input :plan_guidance_groups, + :as => :check_boxes, + :collection => selected_guidance_groups %> + <% end %> + + <%= f.actions do %> +
+ <%= f.submit t("helpers.submit.save"), :class => 'btn btn-primary' %> + <%= t("helpers.links.cancel") %> +
+ <%end%> + <%end%> +
+
+
+
+ +
+ +

<%= t('helpers.project.project_static_info')%>

+ + + + <%if @plan.template.org.name? %> + + + + + <%end%> + <%if @plan.template.customization_of.present? %> + <%= " (Customised from #{ @plan.template.customization_of.org.name })" %> + <%end%> +
<%= constant("organisation_types.funder") %><%= @plan.template.org.name %>
+ +
+ + + <% phases = @plan.template.phases %> + <% if phases.any? %> + <% if phases.count == 1 then %> + <% phases.each do |phase| %> + +
+ <%= link_to t('helpers.answer_questions'), edit_plan_path(@plan), :class => 'btn btn-primary' %> + <%= t('helpers.export') %> +
+ <%= render :partial => "plans/export", locals: {plan: plan} %> +
+

<%= raw phase.description %>

+ <% if !phase.sections.nil? %> + + + + + + + + + <% phase.sections.each do |section| %> + + + + + <%end%> + +
<%= t('helpers.sections_label')%><%= t('helpers.questions_label')%>
+

<%= section.title %>

+
+ <% if section.questions.any? %> + <% questions = section.questions.sort_by(&:number) %> +
    + <% questions.each do |ques|%> +
  • + <%= raw ques.text %> +
  • + <%end%> +
+ <%end%> +
+ <%end%> + <%end%> + <%else%> +
+ <%= raw @plan.template.description %> +
+ <% phases.each do |phase| %> +
+
+ +
+
+
+ <%= link_to t('helpers.answer_questions'), edit_plan_path(@plan), :class => 'btn btn-primary' %> + <%= t('helpers.export') %> +
+ <%= render :partial => "plans/export", locals: {plan: @plan} %> +
+

<%= raw phase.description %> +

+ + <% if !phase.sections.nil? %> + + + + + + + + + <% phase.sections.each do |section| %> + + + + + <%end%> + +
<%= t('helpers.sections_label')%><%= t('helpers.questions_label')%>
+

<%= section.title %>

+
+ <% if section.questions.any? %> + <% questions = section.questions.sort_by(&:number) %> +
    + <% questions.each do |ques|%> +
  • + - <%= raw ques.text %> +
  • + <%end%> +
+ <%end%> +
+ <%end%> +
+
+
+
+ <%end%> + <%end%> + <%end%> +
diff --git a/app/views/plans/_plan_nav_tabs.html.erb b/app/views/plans/_plan_nav_tabs.html.erb new file mode 100644 index 0000000..3ae1018 --- /dev/null +++ b/app/views/plans/_plan_nav_tabs.html.erb @@ -0,0 +1,38 @@ + + diff --git a/app/views/plans/_plan_title.html.erb b/app/views/plans/_plan_title.html.erb new file mode 100644 index 0000000..d134aa1 --- /dev/null +++ b/app/views/plans/_plan_title.html.erb @@ -0,0 +1,8 @@ + +
+
+

+ <%= plan.title %> +

+
+
diff --git a/app/views/plans/create.html.erb b/app/views/plans/create.html.erb new file mode 100644 index 0000000..b1ef328 --- /dev/null +++ b/app/views/plans/create.html.erb @@ -0,0 +1,14 @@ + +
+ +

Choose one of these templates

+ +<%= debug @templates %> + +<% @templates.each do |t| %> +

<%= t %> +<% end %> + +

+ + diff --git a/app/views/plans/new.html.erb b/app/views/plans/new.html.erb new file mode 100644 index 0000000..4198eb4 --- /dev/null +++ b/app/views/plans/new.html.erb @@ -0,0 +1,10 @@ +<%# javascript "projects.js" %> + +
+

<%= @error %>

+ + <%= render "dropdowns_new_plan" %> + +
+ + diff --git a/db/migrate/20170130105546_create_plan_guidance_groups.rb b/db/migrate/20170130105546_create_plan_guidance_groups.rb new file mode 100644 index 0000000..b3d330e --- /dev/null +++ b/db/migrate/20170130105546_create_plan_guidance_groups.rb @@ -0,0 +1,10 @@ +class CreatePlanGuidanceGroups < ActiveRecord::Migration + def change + create_table :plan_guidance_groups do |t| + t.references :plan, index: true, foreign_key: true + t.references :guidance_group, index: true, foreign_key: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170130111947_add_selected_to_plan_guidance_groups.rb b/db/migrate/20170130111947_add_selected_to_plan_guidance_groups.rb new file mode 100644 index 0000000..d9548ba --- /dev/null +++ b/db/migrate/20170130111947_add_selected_to_plan_guidance_groups.rb @@ -0,0 +1,5 @@ +class AddSelectedToPlanGuidanceGroups < ActiveRecord::Migration + def change + add_column :plan_guidance_groups, :selected, :boolean + end +end diff --git a/test/fixtures/plan_guidance_groups.yml b/test/fixtures/plan_guidance_groups.yml new file mode 100644 index 0000000..03f68c5 --- /dev/null +++ b/test/fixtures/plan_guidance_groups.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + plan_id: + guidance_group_id: + +two: + plan_id: + guidance_group_id: diff --git a/test/models/plan_guidance_group_test.rb b/test/models/plan_guidance_group_test.rb new file mode 100644 index 0000000..8afe24e --- /dev/null +++ b/test/models/plan_guidance_group_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PlanGuidanceGroupTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end