From fbf31737471696513cf3a3d7a6303730e0c22fac Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Fri, 12 Jun 2020 16:38:59 +0200 Subject: [PATCH] Upstream sync --- app/assets/javascripts/collapse_select.js | 21 ++++++++------ .../contract_templates_controller.rb | 7 ++++- .../public/medical_releases_controller.rb | 5 ++++ app/views/contract_templates/_form.html.erb | 14 ++++++---- app/views/contracts/_signature_page.html.erb | 9 ++++++ app/views/projects/_form.html.erb | 2 +- .../public/medical_releases/new.html.erb | 13 +++++++++ app/views/shared/_custom_fields.html.erb | 5 ++++ config/locales/en.yml | 10 +++++-- ...d_question_fields_to_contract_templates.rb | 14 ++++++++++ ...9_add_answer_fields_to_medical_releases.rb | 14 ++++++++++ db/structure.sql | 28 +++++++++++++++++-- 12 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 app/views/shared/_custom_fields.html.erb create mode 100644 db/migrate/20200610085411_add_question_fields_to_contract_templates.rb create mode 100644 db/migrate/20200610140459_add_answer_fields_to_medical_releases.rb diff --git a/app/assets/javascripts/collapse_select.js b/app/assets/javascripts/collapse_select.js index d3d19e4..06ef0fa 100644 --- a/app/assets/javascripts/collapse_select.js +++ b/app/assets/javascripts/collapse_select.js @@ -1,11 +1,16 @@ $(document).on("change", "[data-toggle=collapse-select]", function(event) { const select = event.target; - const target = select.dataset.target; - const showValues = JSON.parse(select.dataset.showValues); - - if (showValues.indexOf(select.value) > -1) { - $(target).show("fast"); - } else { - $(target).hide("fast"); - } + const mappings = JSON.parse(select.dataset.targetShowValuesMapping); + + $.each(mappings, function( key, value ) { + if (value.indexOf(select.value) > -1) { + $(key).show("fast"); + } else { + $(key).hide("fast"); + } + }); }); + +$(document).on("turbolinks:load", function() { + $("[data-toggle=collapse-select]").trigger("change"); +}); \ No newline at end of file diff --git a/app/controllers/contract_templates_controller.rb b/app/controllers/contract_templates_controller.rb index f5698c0..6e09308 100644 --- a/app/controllers/contract_templates_controller.rb +++ b/app/controllers/contract_templates_controller.rb @@ -61,7 +61,12 @@ class ContractTemplatesController < ApplicationController :applicable_medium_id, :applicable_medium_text, :territory_id, :territory_text, :term_id, :term_text, - :restriction_id, :restriction_text) + :restriction_id, :restriction_text, + :question_1_text, :question_2_text, + :question_3_text, :question_4_text, + :question_5_text, :question_6_text, + :question_7_text, :question_8_text, + :question_9_text, :question_10_text) end def download_attributes diff --git a/app/controllers/public/medical_releases_controller.rb b/app/controllers/public/medical_releases_controller.rb index 597c522..7645582 100644 --- a/app/controllers/public/medical_releases_controller.rb +++ b/app/controllers/public/medical_releases_controller.rb @@ -48,6 +48,11 @@ class Public::MedicalReleasesController < Public::BaseController :signature_base64, :locale, :contract_template, + :question_1_answer, :question_2_answer, + :question_3_answer, :question_4_answer, + :question_5_answer, :question_6_answer, + :question_7_answer, :question_8_answer, + :question_9_answer, :question_10_answer, photos: [], ) end diff --git a/app/views/contract_templates/_form.html.erb b/app/views/contract_templates/_form.html.erb index 0917df1..5771059 100644 --- a/app/views/contract_templates/_form.html.erb +++ b/app/views/contract_templates/_form.html.erb @@ -2,20 +2,24 @@ <%= field_set_tag content_tag(:span, t(".release_info.heading"), class: "h6 text-muted text-uppercase") do %>
<%= form.text_field :name, wrapper_class: "col-sm-6" %> - <%= form.select :release_type, options_for_release_type_select(project, @release_type), { wrapper_class: "col-sm-6" }, data: { toggle: "collapse-select", target: "#guardian_clause", show_values: %w(appearance talent) }, class: "form-control custom-select" %> + <%= form.select :release_type, options_for_release_type_select(project, @release_type), { wrapper_class: "col-sm-6" }, data: { toggle: "collapse-select", target_show_values_mapping: { "#guardian_clause": %w(appearance talent), "#fee_field": %w(appearance talent location material acquired_media), "#exploitable_rights_fields": %w(appearance talent location material acquired_media), "#custom_fields": %w(medical) } }, class: "form-control custom-select" %>
-
+
<%= form.number_field :fee, min:"0", max:"99999999", step: "0.01", prepend: "$", help: "Leave at $0.00 for no-fee", wrapper_class: "col-sm-6" %>
<% end %>
- <%= field_set_tag content_tag(:span, t(".exploitable_rights.heading"), class: "h6 text-muted text-uppercase")do %> + <%= field_set_tag content_tag(:span, t(".exploitable_rights.heading"), class: "h6 text-muted text-uppercase"), id: "exploitable_rights_fields" do %> <%= render "shared/exploitable_rights_fields", form: form %> +
+ <% end %> + + <%= field_set_tag content_tag(:span, t(".custom_fields.heading"), class: "h6 text-muted text-uppercase"), id: "custom_fields", style: "display: none;" do %> + <%= render "shared/custom_fields", form: form %> +
<% end %> - -
<%= field_set_tag content_tag(:span, t(".legal.heading"), class: "h6 text-muted text-uppercase") do %> <%= form.form_group do %> diff --git a/app/views/contracts/_signature_page.html.erb b/app/views/contracts/_signature_page.html.erb index e39c8be..276e5de 100644 --- a/app/views/contracts/_signature_page.html.erb +++ b/app/views/contracts/_signature_page.html.erb @@ -39,6 +39,15 @@ <% end %> +<% if releasable.model_name == "MedicalRelease" %> + <% (1..10).each do |n| %> + <% if contract_template.public_send("question_#{n}_text").present? %> +

<%= contract_template.public_send("question_#{n}_text") %>

+

<%= releasable.public_send("question_#{n}_answer") %>

+ <% end %> + <% end %> +<% end %> + <% if releasable.minor? %>

Guardian Information

diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index a8a91d7..677a545 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -1,6 +1,6 @@ <%= bootstrap_form_with model: project, local: true do |form| %> <%= form.text_field :name %> - <%= form.select :predefined_client_name, options_for_select(options_for_predefined_client_name_select, selected_project_client_value(project)), {}, data: { toggle: "collapse-select", target: "#other_client", show_values: [:other] }, class: "form-control custom-select" %> + <%= form.select :predefined_client_name, options_for_select(options_for_predefined_client_name_select, selected_project_client_value(project)), {}, data: { toggle: "collapse-select", target_show_values_mapping: { "#other_client": [:other] } }, class: "form-control custom-select" %>
<%= form.text_field :client_name, placeholder: true %> <%= form.form_group do %> diff --git a/app/views/public/medical_releases/new.html.erb b/app/views/public/medical_releases/new.html.erb index 93199d6..c673178 100644 --- a/app/views/public/medical_releases/new.html.erb +++ b/app/views/public/medical_releases/new.html.erb @@ -13,6 +13,19 @@ <% end %>
+ + <% if (1..10).map {|n| @contract_template.public_send("question_#{n}_text").presence }.compact.any? %> + <%= card_field_set_tag t(".questionnaire.heading") do %> + <% (1..10).each do |n| %> + <% if @contract_template.public_send("question_#{n}_text").present? %> +
+ <%= form.text_area "question_#{n}_answer", wrapper_class: "col-sm-12", label: @contract_template.public_send("question_#{n}_text") %> +
+ <% end %> + <% end %> + <% end %> +
+ <% end %> <%= card_field_set_tag t(".personal_info.heading") do %>
<%= t ".personal_info.instructions" %>
diff --git a/app/views/shared/_custom_fields.html.erb b/app/views/shared/_custom_fields.html.erb new file mode 100644 index 0000000..48f729a --- /dev/null +++ b/app/views/shared/_custom_fields.html.erb @@ -0,0 +1,5 @@ +<% (1..10).each do |n| %> +
+ <%= form.text_area "question_#{n}_text", wrapper_class: "col-sm-12" %> +
+<% end%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 19afb42..5ce9bc8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -212,12 +212,14 @@ en: archived_failure: Failed to archive the release template archived_notice: The release template has been archived form: + custom_fields: + heading: Custom Fields exploitable_rights: - heading: 2 of 3 Exploitable Rights + heading: Exploitable Rights legal: - heading: 3 of 3 Legal + heading: Legal release_info: - heading: 1 of 3 Release Info + heading: Release Info index: actions: import: Import Release Template @@ -851,6 +853,8 @@ en: instructions: Now, enter your personal information. photo: heading: Photos + questionnaire: + heading: Questionnaire signature: heading: Signature talent_releases: diff --git a/db/migrate/20200610085411_add_question_fields_to_contract_templates.rb b/db/migrate/20200610085411_add_question_fields_to_contract_templates.rb new file mode 100644 index 0000000..0187af8 --- /dev/null +++ b/db/migrate/20200610085411_add_question_fields_to_contract_templates.rb @@ -0,0 +1,14 @@ +class AddQuestionFieldsToContractTemplates < ActiveRecord::Migration[6.0] + def change + add_column :contract_templates, :question_1_text, :text + add_column :contract_templates, :question_2_text, :text + add_column :contract_templates, :question_3_text, :text + add_column :contract_templates, :question_4_text, :text + add_column :contract_templates, :question_5_text, :text + add_column :contract_templates, :question_6_text, :text + add_column :contract_templates, :question_7_text, :text + add_column :contract_templates, :question_8_text, :text + add_column :contract_templates, :question_9_text, :text + add_column :contract_templates, :question_10_text, :text + end +end diff --git a/db/migrate/20200610140459_add_answer_fields_to_medical_releases.rb b/db/migrate/20200610140459_add_answer_fields_to_medical_releases.rb new file mode 100644 index 0000000..3e78fb5 --- /dev/null +++ b/db/migrate/20200610140459_add_answer_fields_to_medical_releases.rb @@ -0,0 +1,14 @@ +class AddAnswerFieldsToMedicalReleases < ActiveRecord::Migration[6.0] + def change + add_column :medical_releases, :question_1_answer, :text + add_column :medical_releases, :question_2_answer, :text + add_column :medical_releases, :question_3_answer, :text + add_column :medical_releases, :question_4_answer, :text + add_column :medical_releases, :question_5_answer, :text + add_column :medical_releases, :question_6_answer, :text + add_column :medical_releases, :question_7_answer, :text + add_column :medical_releases, :question_8_answer, :text + add_column :medical_releases, :question_9_answer, :text + add_column :medical_releases, :question_10_answer, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index 2888215..06d35f1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -606,7 +606,17 @@ CREATE TABLE public.contract_templates ( term_text character varying, restriction_id bigint, restriction_text character varying, - archived_at timestamp without time zone + archived_at timestamp without time zone, + question_1_text text, + question_2_text text, + question_3_text text, + question_4_text text, + question_5_text text, + question_6_text text, + question_7_text text, + question_8_text text, + question_9_text text, + question_10_text text ); @@ -955,7 +965,17 @@ CREATE TABLE public.medical_releases ( notes text, signed_at timestamp without time zone, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + question_1_answer text, + question_2_answer text, + question_3_answer text, + question_4_answer text, + question_5_answer text, + question_6_answer text, + question_7_answer text, + question_8_answer text, + question_9_answer text, + question_10_answer text ); @@ -3595,6 +3615,8 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200512161738'), ('20200526113516'), ('20200603090419'), -('20200606044747'); +('20200606044747'), +('20200610085411'), +('20200610140459');