diff --git a/app/views/plans/_edit_details.html.erb b/app/views/plans/_edit_details.html.erb index 9d9d86a..fabe519 100644 --- a/app/views/plans/_edit_details.html.erb +++ b/app/views/plans/_edit_details.html.erb @@ -10,14 +10,9 @@ title: _('If applying for funding, state the name exactly as in the grant proposal.')) %> -
+
<%= f.hidden_field :visibility %> -
- <%= f.label(:is_test, _('mock project for testing, practice, or educational purposes'), class: 'control-label') %> -
-
- <%= check_box_tag(:is_test,1, @plan.is_test?) %> -
+ <%= f.label(:is_test, raw("#{check_box_tag(:is_test,1, @plan.is_test?)} #{_('mock project for testing, practice, or educational purposes')}"), class: 'control-label') %>
@@ -43,9 +38,9 @@
<%= f.label(:description, _('Project Abstract'), class: 'control-label') %>
-
Questions to consider:
  • What is the nature of your research project?
  • What research questions are you addressing?
  • For what purpose are the data being collected or created?

Guidance:

Briefly summarise the type of study (or studies) to help others understand the purposes for which the data are being collected or created.

").html_safe %>"> +
"> <%= f.text_area( - :description, + :description, rows: 6, class: 'form-control tinymce', "aria-required": false) %>
@@ -95,9 +90,24 @@ "data-validation": "email") %>
+
+
+ <%= f.label(:principal_investigator_phone, _('Phone'), class: 'control-label') %> +
+
+ <%= f.phone_field( + :principal_investigator_phone, + class: 'form-control', + "aria-required": false) %> +
+

<%= _('Data Contact Person') %>

-
+
+ <% checked = ((@plan.data_contact.present? || @plan.data_contact_phone.present? || @plan.data_contact_email.present?) ? 1 : 0) %> + <%= label_tag(:show_data_contact, raw("#{check_box_tag(:show_data_contact, checked, checked == 0)} #{_('Same as Principal Investigator')}"), class: 'control-label') %> +
+
<%= f.label(:data_contact, _('Name'), class: 'control-label') %>
@@ -108,18 +118,7 @@ "aria-required": false) %>
-
-
- <%= f.label(:data_contact_phone, _('Phone'), class: 'control-label') %> -
-
- <%= f.text_field( - :data_contact_phone, - class: 'form-control', - "aria-required": false) %> -
-
-
+
<%= f.label(:data_contact_email, _('Email'), class: 'control-label') %>
@@ -131,6 +130,17 @@ "data-validation": "email") %>
+
+
+ <%= f.label(:data_contact_phone, _('Phone'), class: 'control-label') %> +
+
+ <%= f.phone_field( + :data_contact_phone, + class: 'form-control', + "aria-required": false) %> +
+
<%= f.button(_('Submit'), class: "btn btn-default", type: "submit") %> <% end %>
diff --git a/db/migrate/20171013152425_add_principal_investigator_phone_to_plans.rb b/db/migrate/20171013152425_add_principal_investigator_phone_to_plans.rb new file mode 100644 index 0000000..dc39e45 --- /dev/null +++ b/db/migrate/20171013152425_add_principal_investigator_phone_to_plans.rb @@ -0,0 +1,5 @@ +class AddPrincipalInvestigatorPhoneToPlans < ActiveRecord::Migration + def change + add_column :plans, :principal_investigator_phone, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 925db70..a15cd65 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170719114516) do +ActiveRecord::Schema.define(version: 20171013152425) do create_table "annotations", force: :cascade do |t| t.integer "question_id", limit: 4 @@ -228,6 +228,7 @@ t.string "data_contact_email", limit: 255 t.string "data_contact_phone", limit: 255 t.string "principal_investigator_email", limit: 255 + t.string "principal_investigator_phone" end add_index "plans", ["template_id"], name: "index_plans_on_template_id", using: :btree diff --git a/lib/assets/javascripts/views/plans/edit_details.js b/lib/assets/javascripts/views/plans/edit_details.js index 84f3535..fd04772 100644 --- a/lib/assets/javascripts/views/plans/edit_details.js +++ b/lib/assets/javascripts/views/plans/edit_details.js @@ -7,4 +7,17 @@ $('#plan_visibility').val($(this).is(':checked') ? 'is_test' : 'privately_visible'); }); ariatiseForm({ selector: '.edit_plan' }); + + const showHideDataContact = (el) => { + if ((el).is(':checked')) { + $('div.data-contact').fadeOut(); + } else { + $('div.data-contact').fadeIn(); + } + }; + + $('#show_data_contact').click((e) => { + showHideDataContact($(e.currentTarget)); + }); + showHideDataContact($('#show_data_contact')); });