diff --git a/app/assets/stylesheets/modules/form.sass b/app/assets/stylesheets/modules/form.sass index 43aef6a..6476ac0 100644 --- a/app/assets/stylesheets/modules/form.sass +++ b/app/assets/stylesheets/modules/form.sass @@ -1,20 +1,20 @@ -input +input, textarea background: $off-white + width: 100% padding: 15px + font-size: 14px + +input border: 1px solid $grey - width: 100% + +textarea + border: none label display: block font-weight: bold margin-bottom: 5px -textarea - width: 100% - background: $off-white - border: none - padding: 15px - .boolean.label display: inline-block .checkbox diff --git a/app/models/referral.rb b/app/models/referral.rb index c17e5e2..41541dd 100644 --- a/app/models/referral.rb +++ b/app/models/referral.rb @@ -54,8 +54,9 @@ def to_param def extract_values(array) array&.map do |hash| - hash[:text] || hash[:email] || hash[:date] || hash[:number] || - hash[:boolean] || hash[:choices] || hash[:choice] + hash[:text] || hash[:email] || hash[:date] || + hash[:number] || hash[:choices] || + parse_choice(hash[:choice]) || parse_boolean(hash[:boolean]) end end @@ -68,4 +69,12 @@ def find_state(hash) 'review' end end + + def parse_boolean(val) + { true => 'Yes', false => 'No' }[val] + end + + def parse_choice(val) + val&.fetch(:label, nil) + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6e46d2b..b43450a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,8 +11,8 @@ - <% if user_signed_in? %> - <% if alert || notice %>
diff --git a/app/views/referrals/new.html.erb b/app/views/referrals/new.html.erb index 603a5b7..517962a 100644 --- a/app/views/referrals/new.html.erb +++ b/app/views/referrals/new.html.erb @@ -1,3 +1,5 @@ +

<%= @partner.name %>

+
<% if @partner.can_accept_referrals? %> <%= tag.div(id: "typeform", data: { form_url: @partner.form_url }) %> @@ -37,7 +39,7 @@
<% if user_signed_in? && @partner.referrals.any? %> -

Sent Referrals

+

Sent Referrals

Name
diff --git a/app/views/referrals/show.html.erb b/app/views/referrals/show.html.erb index 67313ca..2a70f91 100644 --- a/app/views/referrals/show.html.erb +++ b/app/views/referrals/show.html.erb @@ -56,18 +56,18 @@ <%= f.input :notes, placeholder: "Leave a note to explain your decision.", input_html: { class: "rounded mb20" } %>
- <% if @referral.last_state == "accepted" %> - <%= f.button :submit, "Accepted", class: "btn-wide", disabled: true %> + <% if @referral.last_state == "declined" %> + <%= f.button :submit, "Declined", class: "btn-wide", disabled: true %> <% else %> - <%= f.button :submit, "Accept", class: "confirm btn-wide", data: { disable_with: "Accepting...", confirm: "Are you sure you want to accept this referral?" } %> + <%= f.button :submit, "Decline", class: "confirm btn-invert btn-wide", data: { disable_with: "Declining...", confirm: "Are you sure you want to decline this referral?" } %> <% end %> - <% if @referral.last_state == "declined" %> - <%= f.button :submit, "Declined", class: "btn-wide", disabled: true %> + <% if @referral.last_state == "accepted" %> + <%= f.button :submit, "Accepted", class: "btn-wide", disabled: true %> <% else %> - <%= f.button :submit, "Decline", class: "confirm btn-invert btn-wide", data: { disable_with: "Declining...", confirm: "Are you sure you want to decline this referral?" } %> + <%= f.button :submit, "Accept", class: "confirm btn-wide", data: { disable_with: "Accepting...", confirm: "Are you sure you want to accept this referral?" } %> <% end %>
<% end %> diff --git a/test/factories/referrals.rb b/test/factories/referrals.rb index 18e761a..f112cda 100644 --- a/test/factories/referrals.rb +++ b/test/factories/referrals.rb @@ -1,13 +1,19 @@ FactoryBot.define do factory :referral do - original_response { + original_response do { form_response: { calculated: { score: 0 }, - definition: { fields: [{ title: 'q1' }, { title: 'q2' }] }, - answers: [{ text: 'a1' }, { text: 'a2' }] + definition: { + fields: [ + { title: 'q1' }, { title: 'q2' }, { title: 'q3' } + ] + }, + answers: [ + { text: 'text' }, { boolean: true }, { choice: { label: 'choice' } } + ] } } - } + end end end diff --git a/test/models/referral_test.rb b/test/models/referral_test.rb index 6504a35..cfa096b 100644 --- a/test/models/referral_test.rb +++ b/test/models/referral_test.rb @@ -60,11 +60,12 @@ class ReferralTest < ActiveSupport::TestCase end test '#response_answers found' do - assert_equal({ 'q1' => 'a1', 'q2' => 'a2' }, @subject.response_answers) + answers = { 'q1' => 'text', 'q2' => 'Yes', 'q3' => 'choice' } + assert_equal(answers, @subject.response_answers) end test '#response_identifier found' do - assert_equal('a1', @subject.response_identifier) + assert_equal('text', @subject.response_identifier) end test '#response_identifier not found' do diff --git a/test/system/referral_review_test.rb b/test/system/referral_review_test.rb index c1a8474..ca13a08 100644 --- a/test/system/referral_review_test.rb +++ b/test/system/referral_review_test.rb @@ -51,7 +51,7 @@ class ReferralReviewTest < ApplicationSystemTestCase test 'lists answers' do visit referral_path(@partner, @referral) sign_in - %w[q1 a1 q2 a2].each { |t| assert_text(t) } + %w[q1 text q2 Yes q3 choice].each { |t| assert_text(t) } end test 'not signed in referrals_path' do