diff --git a/app/views/annotations/_show.html.erb b/app/views/annotations/_show.html.erb new file mode 100644 index 0000000..0530e84 --- /dev/null +++ b/app/views/annotations/_show.html.erb @@ -0,0 +1,10 @@ + +<% if annotation.type == :example_answer %> +

<%= _('Example Answer') %>

+<% elsif annotation.type == :guidance %> +

<%= _('Guidance') %>

+<% else %> +

<%= _('Annotation') %>

+<% end %> + +

<%= raw annotation.text %>

diff --git a/app/views/answers/_new_edit.html.erb b/app/views/answers/_new_edit.html.erb index 2434033..b2ef8b1 100644 --- a/app/views/answers/_new_edit.html.erb +++ b/app/views/answers/_new_edit.html.erb @@ -2,100 +2,106 @@ This partial creates a form for each type of question. The local variables are: plan, answer, question, readonly --> <% q_format = question.question_format %> -<%= semantic_form_for answer, :url => {controller: :answers, action: :update }, html: {method: "put", class: "roadmap-form", 'data-autosave': question.id }, remote: true do |f| %> -
- <% if !readonly %> - <%= f.input :id, as: :hidden, input_html: { value: answer.id } %> - <%= f.input :plan_id, as: :hidden, input_html: { value: answer.plan_id } %> - <%= f.input :user_id, as: :hidden, input_html: { value: answer.user_id } %> - <%= f.input :question_id, as: :hidden, input_html: { value: answer.question_id } %> - <%= f.input :lock_version, as: :hidden, input_html: { value: answer.lock_version } %> - <% end %> +<%= form_for answer, url: {controller: :answers, action: :update}, html: {method: :put, class: "roadmap-form", 'data-autosave': question.id}, remote: true do |f| %> +
+ <% if !readonly %> + <%= f.hidden_field :id %> + <%= f.hidden_field :plan_id %> + <%= f.hidden_field :user_id %> + <%= f.hidden_field :question_id %> + <%= f.hidden_field :lock_version %> + <% end %> - -

- <%= raw question.text %> -

+
+ + <% if question.option_based? %> + <%= f.label raw(question.text), for: :question_option_ids, class: "no-colon" %> + <% else %> + <%= f.label raw(question.text), for: :text, class: "no-colon" %> + <% end %> + + + <% if !readonly && question.annotations.where(type: Annotation.types[:example_answer]).any? %> + <% annotation = question.annotations.where(type: Annotation.types[:example_answer]).order(:created_at).first %> + <% if annotation.text.present? %> +
+ + <%="#{annotation.org.abbreviation} "%> <%=_('Example of answer')%> + - - <% if !readonly && question.annotations.where(type: Annotation.types[:example_answer]).any? %> - <% annotation = question.annotations.where(type: Annotation.types[:example_answer]).order(:created_at).first %> - <% if annotation.text.present? %> -
- - <%="#{annotation.org.abbreviation} "%> <%=_('Example of answer')%> - +
+

<%= raw annotation.text %>

+
+
+ <% end %> + <% end %> -
-

- <%= raw annotation.text %> -

-
-
- <% end %> - <% end %> + <% if question.option_based? %> + <% options = question.question_options.by_number %> + <% if q_format.checkbox? %> +
    + <% options.each do |op| %> +
  1. + <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id), disabled: readonly }, op.id, nil) %> + <%= raw op.text %> +
  2. + <% end %> +
+ <% elsif q_format.radiobuttons? %> +
    + <% options.each do |op| %> +
  1. + <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id), id: "answer_option_ids_#{op.id}", disabled: readonly } %> + <%= raw op.text %> +
  2. + <% end %> +
+ <% elsif q_format.dropdown? || q_format.multiselectbox? %> + <% + options_html = "" + options.each do |op| + options_html += answer.has_question_option(op.id) ? + "" : + "" + end + %> + <%= select_tag('answer[question_option_ids]', raw(options_html), + {multiple: q_format.multiselectbox?, include_blank: q_format.dropdown?, disabled: readonly }) %> + <% end %> + + <% if question.option_comment_display == true %> + <%= label_tag('answer[text]', _('Comment')) %> + <% if readonly %> +

<%= raw(answer.text) %>

+ <% else %> + <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}") %> + <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.tinymce_answer_events", content_css: asset_path('application.css')) %> + <% end %> + <%end%> - <% if question.option_based? %> - <% options = question.question_options.by_number %> - <% if q_format.checkbox? %> -
    - <% options.each do |op| %> -
  1. - <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id), disabled: readonly }, op.id, nil) %> - <%= raw op.text %> -
  2. - <% end %> -
- <% elsif q_format.radiobuttons? %> -
    - <% options.each do |op| %> -
  1. - <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id), id: "answer_option_ids_#{op.id}", disabled: readonly } %> - <%= raw op.text %> -
  2. - <% end %> -
- <% elsif q_format.dropdown? || q_format.multiselectbox? %> - <% - options_html = "" - options.each do |op| - options_html += answer.has_question_option(op.id) ? - "" : - "" - end - %> - <%= select_tag('answer[question_option_ids]', raw(options_html), - {multiple: q_format.multiselectbox?, include_blank: q_format.dropdown?, disabled: readonly }) %> - <% end %> - - <% if question.option_comment_display == true %> - <%= label_tag('answer[text]', _('Comment')) %> - <% if readonly %> -

<%= raw(answer.text) %>

- <% else %> - <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}") %> - <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.tinymce_answer_events", content_css: asset_path('application.css')) %> - <% end %> - <%end%> - <% end %> - - <% if q_format.textfield? %> - <% if readonly %> -

<%= strip_tags(answer.text) %>

- <% else %> - <%= text_field_tag('answer[text]', strip_tags(answer.text)) %> - <% end %> - <% elsif q_format.textarea? %> - <% if readonly %> -

<%= raw(answer.text) %>

- <% else %> - <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}") %> - <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.tinymce_answer_events", content_css: asset_path('application.css')) %> - <% end %> - <% end %> + + <% elsif q_format.textfield? %> + <% if readonly %> +

<%= strip_tags(answer.text) %>

+ <% else %> + <%= text_field_tag('answer[text]', strip_tags(answer.text)) %> + <% end %> + + <% elsif q_format.textarea? %> + <% if readonly %> +

<%= raw(answer.text) %>

+ <% else %> + <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}") %> + <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.tinymce_answer_events", content_css: asset_path('application.css')) %> + <% end %> + <% end %> - <% if !readonly %> - - <% end %> -
- <% end %> \ No newline at end of file + + + <% if !readonly %> +
+ +
+ <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/guidance_groups/_show.html.erb b/app/views/guidance_groups/_show.html.erb new file mode 100644 index 0000000..060a8f3 --- /dev/null +++ b/app/views/guidance_groups/_show.html.erb @@ -0,0 +1,8 @@ +

+ <%= group[:org] %> guidance on <%= theme %> + +

+ +
+
<%= raw group[:text] %>
+
\ No newline at end of file diff --git a/app/views/guidances/untitled.txt b/app/views/guidances/untitled.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/views/guidances/untitled.txt diff --git a/app/views/phases/_DELETE_answer_form.html.erb b/app/views/phases/_DELETE_answer_form.html.erb new file mode 100644 index 0000000..762340d --- /dev/null +++ b/app/views/phases/_DELETE_answer_form.html.erb @@ -0,0 +1,122 @@ + + +
+ <% + answers = question.plan_answers(plan.id) + if answers.present? + answer = answers.first + else + answer = Answer.new({ plan_id: plan.id, question_id: question.id, user_id: current_user.id }) + if question.default_value.present? + answer.text = question.default_value + end + end + %> +
+
" class="answer-locking">
+
"> + <%= render(partial: 'answers/new_edit', locals: { question: question, answer: answer, readonly: readonly }) %> +
+
" class="answer-status"> + <%= render(partial: 'answers/status', locals: { answer: answer }) %> +
+
+
+ + +
+ +
+ <% comments = answer.notes.all %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <% active_tab = nil %> + + + + +
+
+ + + +
+ + + <% num_annotations = 0 %> + <% i = 0 %> + <% if annotations.present? %> + <% annotations.each do |annotation| %> + +

+ <%= annotation.org.abbreviation %> <%= _('Guidance') %> + +

+ + +
+
<%= raw annotation.text %>
+
+ <% num_annotations += 1%> + <% i += 1 %> + <% end %> + <% end %> + + + <% guidance_accordion_id = num_annotations %> + <% question_guidances.each_pair do |theme, group| %> + <% group.each do |gobj| %> +

+ <%= gobj[:org] %> guidance on <%= theme %> + +

+ +
+
<%= raw gobj[:text] %>
+
+ <% guidance_accordion_id += 1 %> + <% i += 1 %> + <% end %> + <% end %> + +
+ +
+ +
+ + + <%= render partial: "note", locals: {question: question, answer: answer, plan: plan, suffix: "" }%> + +
+
+
+
+ + +<% if last_question_id == question.id then %> +
+<% else %> +
+<% end %> diff --git a/app/views/phases/_DELETE_note.html.erb b/app/views/phases/_DELETE_note.html.erb new file mode 100644 index 0000000..b38f3dd --- /dev/null +++ b/app/views/phases/_DELETE_note.html.erb @@ -0,0 +1,30 @@ + <% if answer.present? && answer.notes.any? %> + <% notes = answer.notes.all.to_a.sort! {|x,y| y.updated_at <=> x.updated_at } %> + <% questionid = question.id %> + <%= hidden_field_tag :question_id, questionid, class: "question_id" %> + + +
+ <%= link_to _('Add note'), + "#question-form-#{questionid}", + class: "btn btn-primary add_comment_button", + onclick: "add_note_button(#{questionid})", + role: "button" + %> +
+ +
+ + + <%= render :partial => "/notes/list", locals: {question_id: question.id, notes: notes, plan: plan} %> + + +
+ + + + <% else%> + <%= render :partial => "/notes/add", locals: {answer: answer, question: question, plan_id: plan.id }%> + <% end%> diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb deleted file mode 100644 index 762340d..0000000 --- a/app/views/phases/_answer_form.html.erb +++ /dev/null @@ -1,122 +0,0 @@ - - -
- <% - answers = question.plan_answers(plan.id) - if answers.present? - answer = answers.first - else - answer = Answer.new({ plan_id: plan.id, question_id: question.id, user_id: current_user.id }) - if question.default_value.present? - answer.text = question.default_value - end - end - %> -
-
" class="answer-locking">
-
"> - <%= render(partial: 'answers/new_edit', locals: { question: question, answer: answer, readonly: readonly }) %> -
-
" class="answer-status"> - <%= render(partial: 'answers/status', locals: { answer: answer }) %> -
-
-
- - -
- -
- <% comments = answer.notes.all %> - <%= hidden_field_tag :question_id, question.id, class: "question_id" %> - <% active_tab = nil %> - - - - -
-
- - - -
- - - <% num_annotations = 0 %> - <% i = 0 %> - <% if annotations.present? %> - <% annotations.each do |annotation| %> - -

- <%= annotation.org.abbreviation %> <%= _('Guidance') %> - -

- - -
-
<%= raw annotation.text %>
-
- <% num_annotations += 1%> - <% i += 1 %> - <% end %> - <% end %> - - - <% guidance_accordion_id = num_annotations %> - <% question_guidances.each_pair do |theme, group| %> - <% group.each do |gobj| %> -

- <%= gobj[:org] %> guidance on <%= theme %> - -

- -
-
<%= raw gobj[:text] %>
-
- <% guidance_accordion_id += 1 %> - <% i += 1 %> - <% end %> - <% end %> - -
- -
- -
- - - <%= render partial: "note", locals: {question: question, answer: answer, plan: plan, suffix: "" }%> - -
-
-
-
- - -<% if last_question_id == question.id then %> -
-<% else %> -
-<% end %> diff --git a/app/views/phases/_note.html.erb b/app/views/phases/_note.html.erb deleted file mode 100644 index b38f3dd..0000000 --- a/app/views/phases/_note.html.erb +++ /dev/null @@ -1,30 +0,0 @@ - <% if answer.present? && answer.notes.any? %> - <% notes = answer.notes.all.to_a.sort! {|x,y| y.updated_at <=> x.updated_at } %> - <% questionid = question.id %> - <%= hidden_field_tag :question_id, questionid, class: "question_id" %> - - -
- <%= link_to _('Add note'), - "#question-form-#{questionid}", - class: "btn btn-primary add_comment_button", - onclick: "add_note_button(#{questionid})", - role: "button" - %> -
- -
- - - <%= render :partial => "/notes/list", locals: {question_id: question.id, notes: notes, plan: plan} %> - - -
- - - - <% else%> - <%= render :partial => "/notes/add", locals: {answer: answer, question: question, plan_id: plan.id }%> - <% end%> diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb index 1652259..a9e8349 100644 --- a/app/views/phases/edit.html.erb +++ b/app/views/phases/edit.html.erb @@ -39,85 +39,213 @@
-
+
-
- <% i = 0 %> - <% @phase.sections.order(:number).each do |section| %> +
+ <% i = 0 %> + <% @phase.sections.order(:number).each do |section| %> + <% sectionid = section.id %> - <% sectionid = section.id %> -

- <%= render :partial => "/sections/progress", locals: { section: section, plan: @plan } %> - -

-
- -

<%= raw section.description %>

+

+ <%= render :partial => "/sections/progress", locals: { section: section, plan: @plan } %> + +

-
- - - - +
+ +

<%= raw section.description %>

- -
- <% section.questions.each do |question| %> - <% if question.id == session[:question_id_comments].to_i then id_css = "current_question" end %> -
- - <% guidances = @question_guidance[question.id] %> - - <%= render partial: 'answer_form', - locals: { - plan: @plan, - question: question, - question_guidances: guidances, - last_question_id: section.questions.last.id, - readonly: @readonly - } - %> -
- <% end %> -
-
- - - + <% end %> + +
+
+ + + + + <% i += 1 %> - <% end %> -
+ <% end %> +
diff --git a/lib/assets/stylesheets/dmproadmap/forms.scss b/lib/assets/stylesheets/dmproadmap/forms.scss index 00cf310..28494f6 100644 --- a/lib/assets/stylesheets/dmproadmap/forms.scss +++ b/lib/assets/stylesheets/dmproadmap/forms.scss @@ -701,6 +701,14 @@ } } +/* Write plan */ +/* ------------------------------------------------ */ +#sections-accordion { + h2 { + font-size: 18px; + } +} + /* Org edit */ /* ------------------------------------------------ */ #edit_org_details {