-
Notifications
You must be signed in to change notification settings - Fork 12
Add personal contact columns to Facilitator #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| class FacilitatorDecorator < Draper::Decorator | ||
| delegate_all | ||
|
|
||
| DISPLAY_FIELDS = { | ||
| "First name" => :first_name, | ||
| "Last name" => :last_name, | ||
| "Primary email address" => :primary_email_address, | ||
| "Primary email type" => :primary_email_address_type, | ||
| "Street address" => :street_address, | ||
| "City" => :city, | ||
| "State" => :state, | ||
| "ZIP" => :zip, | ||
| "Country" => :country, | ||
| "Mailing address type" => :mailing_address_type, | ||
| "Phone number" => :phone_number, | ||
| "Phone number type" => :phone_number_type | ||
| } | ||
|
|
||
| def display_fields | ||
| DISPLAY_FIELDS.map do |label, method| | ||
| { label: label, value: object.send(method) } | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,32 @@ | ||
| class Facilitator < ApplicationRecord | ||
| has_one :user | ||
|
|
||
| validates :first_name, presence: true | ||
| validates :last_name, presence: true | ||
| validates :email, presence: true | ||
| CONTACT_TYPES = ["Work", "Personal"].freeze | ||
| PERMITTED_PARAMS = [ | ||
| :first_name, :last_name, :primary_email_address, :primary_email_address_type, | ||
| :street_address, :city, :state, :zip, :country, :mailing_address_type, | ||
| :phone_number, :phone_number_type | ||
| ].freeze | ||
|
|
||
| validates :first_name, | ||
| :last_name, | ||
| :primary_email_address, | ||
| :primary_email_address_type, | ||
| :street_address, | ||
| :city, | ||
| :state, | ||
| :zip, | ||
| :country, | ||
| :mailing_address_type, | ||
| :phone_number, | ||
| :phone_number_type, | ||
| presence: true | ||
|
|
||
| validates :primary_email_address_type, inclusion: {in: CONTACT_TYPES} | ||
| validates :mailing_address_type, inclusion: {in: CONTACT_TYPES} | ||
| validates :phone_number_type, inclusion: {in: CONTACT_TYPES} | ||
|
|
||
| # TODO: add validation for zip code containing only numbers | ||
| # TODO: add validation on STATE | ||
| # TODO: add validation on phone number type | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,24 @@ | ||
| <%= form_for(@facilitator) do |f| %> | ||
| <%= render 'shared/errors', resource: facilitator if facilitator.errors.any? %> | ||
|
|
||
| <div class="form-inputs"> | ||
| <%= f.label :first_name, class: 'bold' %> | ||
| <%= f.text_field :first_name %> | ||
| <%= f.label :last_name, class: 'bold' %> | ||
| <%= f.text_field :last_name %> | ||
| <%= f.label :email, class: 'bold' %> | ||
| <%= f.text_field :email %> | ||
| </div> | ||
|
|
||
| <div class="form-actions"> | ||
| <%= f.button :submit %> | ||
| </div> | ||
| <%= simple_form_for @facilitator do |f| %> | ||
| <%= f.input :first_name %> | ||
| <%= f.input :last_name %> | ||
| <%= f.input :primary_email_address %> | ||
| <%= f.input :primary_email_address_type, | ||
| as: :radio_buttons, | ||
| collection: Facilitator::CONTACT_TYPES, | ||
| item_wrapper_class: 'form-check' %> | ||
| <%= f.input :street_address %> | ||
| <%= f.input :city %> | ||
| <%= f.input :state %> | ||
| <%= f.input :zip %> | ||
| <%= f.input :country %> | ||
| <%= f.input :mailing_address_type, | ||
| as: :radio_buttons, | ||
| collection: Facilitator::CONTACT_TYPES, | ||
| item_wrapper_class: 'form-check' %> | ||
| <%= f.input :phone_number%> | ||
| <%= f.input :phone_number_type, | ||
| as: :radio_buttons, | ||
| collection: Facilitator::CONTACT_TYPES, | ||
| item_wrapper_class: 'form-check' %> | ||
| <%= f.button :submit %> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,13 @@ | ||
| <p id="notice"><%= notice %></p> | ||
|
|
||
| <p> | ||
| <strong>First name:</strong> | ||
| <%= @facilitator.first_name %> | ||
| </p> | ||
| <% @facilitator.display_fields.each do |field| %> | ||
| <p> | ||
| <strong><%= field[:label] %>:</strong> | ||
| <%= field[:value].presence || "N/A" %> | ||
| </p> | ||
| <% end %> | ||
|
|
||
| <p> | ||
| <strong>Last name:</strong> | ||
| <%= @facilitator.last_name %> | ||
| </p> | ||
|
|
||
| <p> | ||
| <strong>Email:</strong> | ||
| <%= @facilitator.email %> | ||
| </p> | ||
|
|
||
| <%= link_to 'Edit', edit_facilitator_path(@facilitator) %> | | ||
| <%= link_to 'Back', facilitators_path %> |
14 changes: 14 additions & 0 deletions
14
db/migrate/20250913164451_add_contact_info_to_facilitators.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| class AddContactInfoToFacilitators < ActiveRecord::Migration[6.1] | ||
| def change | ||
| add_column :facilitators, :primary_email_address, :string, null: false | ||
| add_column :facilitators, :primary_email_address_type, :string, null: false | ||
| add_column :facilitators, :street_address, :string, null: false | ||
| add_column :facilitators, :city, :string, null: false | ||
| add_column :facilitators, :state, :string, null: false | ||
| add_column :facilitators, :zip, :string, null: false | ||
| add_column :facilitators, :country, :string, null: false | ||
| add_column :facilitators, :mailing_address_type, :string, null: false | ||
| add_column :facilitators, :phone_number, :string, null: false | ||
| add_column :facilitators, :phone_number_type, :string, null: false | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class RemoveEmailFromFacilitators < ActiveRecord::Migration[6.1] | ||
| def change | ||
| remove_column :facilitators, :email, :string | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe FacilitatorDecorator do | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are requiring all of these fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collaboration agreement has * by all these fields so I'm assuming they are all required. I can confirm with the AWBW team this afternoon! If they're not required I'll change these