diff --git a/app/views/annotations/_add.html.erb b/app/views/annotations/_add.html.erb
new file mode 100644
index 0000000..96d290d
--- /dev/null
+++ b/app/views/annotations/_add.html.erb
@@ -0,0 +1,23 @@
+
+
+
<%= _('Add Annotations') %>
+<%= form_tag admin_create_annotation_path , class: 'add_annotation_form' do %>
+
+
+
+
+ <%= submit_tag _('Save'), class: "btn btn-primary" %>
+ <%= hidden_field_tag :question_id, question.id, class: "question_id" %>
+ <%= link_to _('Cancel'), "#add_annotations_div_#{question.id}", class: "btn cancel btn-default cancel_add_annotations", role: 'button'%>
+
+<%end%>
diff --git a/app/views/annotations/_edit.html.erb b/app/views/annotations/_edit.html.erb
new file mode 100644
index 0000000..821c3d4
--- /dev/null
+++ b/app/views/annotations/_edit.html.erb
@@ -0,0 +1,38 @@
+
+<%= _('Edit Annotations') %>
+<%= form_tag admin_update_annotation_path, method: :put do %>
+ <% example_answer_text = example_answer.present? ? example_answer.text : '' %>
+ <% guidance_text = guidance.present? ? guidance.text : '' %>
+ <%= hidden_field_tag :example_answer_id, example_answer.present? ? example_answer.id : nil %>
+ <%= hidden_field_tag :guidance_id, guidance.present? ? guidance.id : nil %>
+
+
+
+
+
+
+
+ <%= submit_tag _('Save'), class: 'btn btn-primary' %>
+ <% if example_answer.present? %>
+ <%= link_to _('Delete Example Answer'), admin_destroy_annotation_path(id: example_answer.id),
+ confirm: _("You are about to delete an example answer for '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%>
+ <% end %>
+ <% if guidance.present? %>
+ <%= link_to _('Delete Example Answer'), admin_destroy_annotation_path(id: guidance.id),
+ confirm: _("You are about to delete a guidance for '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%>
+ <% end %>
+
+ <%= hidden_field_tag :question_id, question.id, class: "question_id" %>
+ <%= link_to _('Cancel'), "#edit_annotations_div_#{question.id}", class: 'btn cancel btn-default cancel_edit_annotations', role: 'button' %>
+
+<% end %>
diff --git a/app/views/annotations/_show.html.erb b/app/views/annotations/_show.html.erb
index 8343f07..8ce44e2 100644
--- a/app/views/annotations/_show.html.erb
+++ b/app/views/annotations/_show.html.erb
@@ -1,24 +1,11 @@
-<%# locals: {template, annotation, question } %>
-
-
-
-
- <%= raw annotation.text %>
-
-
+ <%= _('Annotations') %>
+
+ <% if example_answer.present? %>
+ - <%= _('Example Answer') %>
+ - <%= example_answer.text %>
-
+ <% end %>
+ <% if guidance.present? %>
+
- <%= _('Guidance') %>
+ - <%=guidance.text%>
+ <% end %>
+
diff --git a/app/views/questions/_show_question.html.erb b/app/views/questions/_show_question.html.erb
index ccc063d..482edb9 100644
--- a/app/views/questions/_show_question.html.erb
+++ b/app/views/questions/_show_question.html.erb
@@ -59,21 +59,51 @@
+<<<<<<< 436bb9e6a6a98b57d656f4bf89e90ff2aeb884f5
<% if (question.modifiable) %>
+=======
+
+ <% example_answer = question.get_example_answer(current_user.org_id) %>
+ <% guidance = question.get_guidance_annotation(current_user.org_id) %>
+ <% if !question.modifiable %>
+ <% if example_answer.present? || guidance.present? %>
+
+ <%= render partial: 'annotations/show', locals: {example_answer: example_answer, guidance: guidance, question: question} %>
+
+
+ <%= render partial: 'annotations/edit', locals: {example_answer: example_answer, guidance: guidance, question: question} %>
+
+ <% end %>
+
+ <%= render partial: 'annotations/add', locals: {question: question} %>
+
+ <% end %>
+
+ <% if (question.modifiable) %>
+>>>>>>> added template customization back in #791
<%= link_to _('Edit question'), "#question_edit#{question.id}", class: "btn btn-default question_edit_link", role: "button" %>
<%= link_to _('Delete question'), admin_destroy_question_path(question_id: question.id),
confirm: _("You are about to delete '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-default", role:"button" %>
- <% else %>
- <% if example_answer.nil? && guidance.nil? %>
+ <% else %>
+ <% if example_answer.nil? && guidance.nil? %>
- <%= link_to _('Add Annotations'), '# ', class: "btn btn-default add_annotations_button", role:"button"%>
+ <%= link_to _('Add Annotations'), "#add_annotations_div_#{question.id}", class: "btn btn-default add_annotations_button", role:"button"%>
+ <% else %>
+
+ <%= link_to _('Edit Annotations'), "#edit_annotations_div_#{question.id}", class: "btn btn-default edit_annotations_button", role:"button"%>
+
+ <% end %>
<% end %>
+<<<<<<< 436bb9e6a6a98b57d656f4bf89e90ff2aeb884f5
<% end %>
+=======
+
+>>>>>>> added template customization back in #791
<%#= render partial: 'guidances/guidance_display', locals: {question: question} %>
-
\ No newline at end of file
+
diff --git a/app/views/templates/_admin_nav_tabs.html.erb b/app/views/templates/_admin_nav_tabs.html.erb
index 4ed2afc..80d8026 100644
--- a/app/views/templates/_admin_nav_tabs.html.erb
+++ b/app/views/templates/_admin_nav_tabs.html.erb
@@ -9,9 +9,9 @@
<% end %>
- <% if current_user.can_org_admin? && (template.org.funder? || current_user.org.funder? || (template.org == current_user.org)) %>
+ <% if current_user.can_org_admin? && template.customization_of.nil? %>
>
<%= link_to(_('Add new phase'), admin_add_phase_path(template), { 'aria-controls': 'add_phase', role: 'tab' }) %>
<% end %>
-
\ No newline at end of file
+
diff --git a/app/views/templates/_show_phases_sections.html.erb b/app/views/templates/_show_phases_sections.html.erb
index e7df95b..e1ab1ad 100644
--- a/app/views/templates/_show_phases_sections.html.erb
+++ b/app/views/templates/_show_phases_sections.html.erb
@@ -9,12 +9,13 @@
- <%= link_to _('Show Phase'), admin_show_phase_path(id: phase.id), { class: "btn btn-default", role: 'button' } %>
+ <% phase_button_text = template.customization_of.nil? ? _('Show Phase') : _('Customize Phase') %>
+ <%= link_to phase_button_text, admin_show_phase_path(id: phase.id), { class: "btn btn-default", role: 'button' } %>
<% if template == current && phase.modifiable %>
<%= link_to _('Delete'), admin_destroy_phase_path(phase_id: phase.id), {
confirm: _("You are about to delete '%{phase_title}'. This will affect versions, sections and questions linked to this phase. Are you sure?") % { phase_title: phase.title },
- method: :delete,
- class: "btn btn-default", role: "button" }
+ method: :delete,
+ class: "btn btn-default", role: "button" }
%>
<% end %>
diff --git a/lib/assets/javascripts/application.js b/lib/assets/javascripts/application.js
index 4eb6f65..e1ecbcf 100644
--- a/lib/assets/javascripts/application.js
+++ b/lib/assets/javascripts/application.js
@@ -9,6 +9,8 @@
// Page specific JS
import './views/answers/edit';
+import './views/annotations/add';
+import './views/annotations/edit';
import './views/contacts/new';
import './views/devise/invitations/edit';
import './views/devise/passwords/edit';
diff --git a/lib/assets/javascripts/views/annotations/add.js b/lib/assets/javascripts/views/annotations/add.js
new file mode 100644
index 0000000..498c8f5
--- /dev/null
+++ b/lib/assets/javascripts/views/annotations/add.js
@@ -0,0 +1,9 @@
+$(() => {
+ $('.cancel_add_annotations').on('click', (e) => {
+ e.preventDefault();
+ const target = $(e.target).attr('href');
+ $(target).hide();
+ $(target).closest('.col-md-12').find('.add_annotations_button').show();
+ $(target).closest('.col-md-12').find('.show_annotations_div').show();
+ });
+});
diff --git a/lib/assets/javascripts/views/annotations/edit.js b/lib/assets/javascripts/views/annotations/edit.js
new file mode 100644
index 0000000..0884ed9
--- /dev/null
+++ b/lib/assets/javascripts/views/annotations/edit.js
@@ -0,0 +1,9 @@
+$(() => {
+ $('.cancel_edit_annotations').on('click', (e) => {
+ e.preventDefault();
+ const target = $(e.target).attr('href');
+ $(target).hide();
+ $(target).closest('.col-md-12').find('.edit_annotations_button').show();
+ $(target).closest('.col-md-12').find('.show_annotations_div').show();
+ });
+});
diff --git a/lib/assets/javascripts/views/questions/show.js b/lib/assets/javascripts/views/questions/show.js
index 668c007..718fefa 100644
--- a/lib/assets/javascripts/views/questions/show.js
+++ b/lib/assets/javascripts/views/questions/show.js
@@ -5,4 +5,19 @@
$(source).closest('.question_show').hide();
$(target).show();
});
+
+ $('.add_annotations_button').on('click', (e) => {
+ const source = e.target;
+ const target = $(source).attr('href');
+ $(target).show();
+ $(source).hide();
+ });
+
+ $('.edit_annotations_button').on('click', (e) => {
+ const source = e.target;
+ const target = $(source).attr('href');
+ $(target).show();
+ $(source).hide();
+ $(target).closest('.col-md-12').find('.show_annotations_div').hide();
+ });
});