-
Notifications
You must be signed in to change notification settings - Fork 242
React autosave: patient dashboard form (bugs fixed 🙂 ) #3337
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
Open
mercedesb
wants to merge
15
commits into
DARIAEngineering:main
Choose a base branch
from
mercedesb:fix-patient-dashboard-react-bugs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
eb72db1
Re-Reactify Patient Dashboard
mercedesb 234b1aa
fix identified bugs :)
mercedesb 6a44583
fix styling of status
mercedesb 49b71fd
remove click_away_from_field to get spec to pass
mercedesb 4578729
add initial_call_date_display to patient json
mercedesb a7799e0
use initial_call_date_display from json instead of prop
mercedesb fbcf4bb
allow Input to behave either like a controlled or uncontrolled component
mercedesb a3fecd8
add status_help_text to update patient response
mercedesb b3a35a5
simplify state mgmt in Input even more
mercedesb 3313fbd
bugfix: when selected value is 0, dont set to empty string
mercedesb b6b5016
fix debounce so it doesnt make a new timeout on every rerender
mercedesb 1f6aef5
make integration spec helper to wait for debounce autosave to run
mercedesb fcd88a5
use correct class name to offset select with sr-only label
mercedesb 94c78ab
refactor Input to handle controlled/uncontrolled w/o conditional hooks
mercedesb 5c3ea3b
remove useCallback
mercedesb 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
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,77 +1,10 @@ | ||
| <div id="patient_dashboard_content"> | ||
| <%= bootstrap_form_with model: patient, | ||
| html: { id: 'patient_dashboard_form' }, | ||
| local: false, | ||
| method: 'patch', | ||
| class: 'edit_patient' do |f| %> | ||
| <div class="row"> | ||
|
|
||
| <div class="col-4"> | ||
| <%= f.text_field :name, | ||
| label: t('patient.shared.name'), | ||
| autocomplete: 'off' %> | ||
| </div> | ||
|
|
||
| <div class="col"> | ||
| <%= f.select :last_menstrual_period_weeks, | ||
| options_for_select(weeks_options, patient.last_menstrual_period_weeks ), | ||
| label: t('patient.dashboard.weeks_along'), | ||
| autocomplete: 'off', | ||
| help: t('patient.dashboard.currently', weeks: patient.last_menstrual_period_now_weeks, days: patient.last_menstrual_period_now_days) %> | ||
| </div> | ||
|
|
||
| <div class="col mt-4"> | ||
| <%= f.select :last_menstrual_period_days, | ||
| options_for_select(days_options, patient.last_menstrual_period_days), | ||
| autocomplete: 'off', | ||
| skip_label: true, | ||
| help: t('patient.dashboard.called_on', date: patient.initial_call_date.strftime("%m/%d/%Y")) %> | ||
| <%= f.label :last_menstrual_period_days, t('common.days_along'), class: "sr-only" %> | ||
| </div> | ||
|
|
||
| <div class="col-3"> | ||
| <%= f.date_field :appointment_date, | ||
| label: t('patient.shared.appt_date'), | ||
| autocomplete: 'off', | ||
| help: t('patient.dashboard.approx_gestation', weeks: patient.last_menstrual_period_at_appt_weeks, days: patient.last_menstrual_period_at_appt_days) %> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="row"> | ||
| <div class="col-4"> | ||
| <%= f.text_field :primary_phone, | ||
| value: patient.primary_phone_display, | ||
| label: t('patient.dashboard.phone'), | ||
| autocomplete: 'off' %> | ||
| </div> | ||
|
|
||
| <div class="col"> | ||
| <%= f.text_field :pronouns, | ||
| value: patient.pronouns, | ||
| autocomplete: 'off' %> | ||
| </div> | ||
|
|
||
| <div class="col"> | ||
| <div class="form-group"> | ||
| <label for="status"><%= t 'patient.shared.status' %> <%= tooltip_shell status_help_text(patient) %></label> | ||
| <input type="text" value="<%= patient.status %>" class="form-control form-control-plaintext" id="patient_status_display" autocomplete="off" disabled> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="col-3"> | ||
| <% if current_user.admin? %> | ||
| <div class="form-group"> | ||
| <label for="admin-delete"><%= t 'patient.dashboard.delete_label' %></label> | ||
| <div> | ||
| <%= link_to t('patient.dashboard.delete'), | ||
| patient_path(patient), | ||
| class: 'btn btn-danger', | ||
| method: :delete, | ||
| data: { confirm: t('patient.dashboard.confirm_del', name: patient.name) } %> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
| </div> | ||
| <%= render ReactComponent.new("PatientDashboardForm", raw_props: { | ||
| patient: patient.as_json.merge(status_help_text: status_help_text(@patient)), | ||
| weeksOptions: weeks_options.map { |opt| { label: opt[0], value: opt[1] } }, | ||
| daysOptions: days_options.map { |opt| { label: opt[0], value: opt[1] } }, | ||
| isAdmin: current_user.admin?, | ||
| patientPath: patient_path(patient), | ||
| formAuthenticityToken: form_authenticity_token | ||
| }) %> | ||
| </div> |
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 |
|---|---|---|
|
|
@@ -27,9 +27,7 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase | |
| describe 'changing patient dashboard information' do | ||
| describe 'updating name' do | ||
| before do | ||
| fill_in 'First and last name', with: 'Susie Everyteen 2' | ||
| click_away_from_field | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. honestly dope |
||
| wait_for_ajax | ||
| fill_in_field_with_autosave 'First and last name', with: 'Susie Everyteen 2' | ||
| reload_page_and_click_link 'Patient Information' | ||
| end | ||
|
|
||
|
|
@@ -74,9 +72,7 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase | |
|
|
||
| describe 'updating appointment date' do | ||
| before do | ||
| fill_in 'Appointment date', with: 5.days.from_now.strftime('%m/%d/%Y') | ||
| click_away_from_field | ||
| wait_for_ajax | ||
| fill_in_field_with_autosave 'Appointment date', with: 5.days.from_now.strftime('%m/%d/%Y') | ||
| reload_page_and_click_link 'Patient Information' | ||
| end | ||
|
|
||
|
|
@@ -107,9 +103,7 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase | |
|
|
||
| describe 'updating phone number' do | ||
| before do | ||
| fill_in 'Phone number', with: '123-666-8888' | ||
| click_away_from_field | ||
| wait_for_ajax | ||
| fill_in_field_with_autosave 'Phone number', with: '123-666-8888' | ||
| reload_page_and_click_link 'Patient Information' | ||
| end | ||
|
|
||
|
|
@@ -122,9 +116,7 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase | |
|
|
||
| describe 'updating pronouns' do | ||
| before do | ||
| fill_in 'Pronouns', with: 'they/them' | ||
| click_away_from_field | ||
| wait_for_ajax | ||
| fill_in_field_with_autosave 'Pronouns', with: 'they/them' | ||
| reload_page_and_click_link 'Patient Information' | ||
| end | ||
|
|
||
|
|
@@ -298,7 +290,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase | |
|
|
||
| it 'should flash failure on a bad field change' do | ||
| fill_in 'Phone number', with: '111-222-3333445' | ||
| click_away_from_field | ||
| assert has_text? 'Primary phone is the wrong length' | ||
| end | ||
| end | ||
|
|
@@ -365,7 +356,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase | |
| private | ||
|
|
||
| def reload_page_and_click_link(link_text) | ||
| click_away_from_field | ||
| visit authenticated_root_path | ||
| visit edit_patient_path @patient | ||
| click_link link_text | ||
|
|
||
Oops, something went wrong.
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.
this is the main culprit right?
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.
actually the change below with the debounce was the main culprit. a combo of the useMemo and not passing the params through to the autosave function
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.
ah, good to know! makes sense
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.
I really need to learn to just stop reaching for useMemo. I mess it up nearly every time and it has cost me hours of my life 😅