Skip to content
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

Other income additional comments prefix for page 2 13614c #5620

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

embarnard
Copy link
Contributor

@embarnard embarnard commented Feb 21, 2025

Link to pivotal/JIRA issue

Is PM acceptance required? (delete one)

  • Yes - don't merge until JIRA issue is accepted!

Reminder: merge main into this branch and get green tests before merging to main

What was done?

  • Added prefix to other income types field in the open text form field and also the pdf
  • opted to add the prefix with javascript and remove it with javascript before form submission and add when creating the pdf because wanted to avoid it being inserted multiple times if the form was loaded multiple times

How to test? Heroku env

  1. Add text to the additional comments field on the second page of the 13614c form in the hub for a client
  2. save the form a few times to test for duplicates
  3. go to the client/documents tab and view the 13614c pdf

Screenshots (for visual changes)

Screenshot 2025-02-24 at 12 33 06 PM Screenshot 2025-02-24 at 12 33 24 PM

Copy link

Heroku app: https://gyr-review-app-5620-8caad679cdd4.herokuapp.com/
View logs: heroku logs --app gyr-review-app-5620 (optionally add --tail)

@@ -29,7 +29,7 @@ def selected_orgs_and_sites
if model.instance_of? Site
model = available_by_id[model.parent_organization_id]
end
model.coalition_id == selected_model.id
model&.coalition_id == selected_model.id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to this ticket but noticed this will cause this page to crash sometimes; model is nil when can't find model on available_by_id[model.parent_organization_id]

}
});
});
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we have a label_and_field method which allows a prefix in honeycrisp that is used by cfa_textarea although cfa_textarea does not pass through a prefix option -- if that was an available option, would that have been a good solution to creating a prefix? Could we create a vita_min_textarea and then create a ticket to update honeycrisp to allow adding a prefix?

@@ -391,7 +391,7 @@

expect(intake.cv_other_income_cb_yes?).to eq true

expect(intake.cv_p2_notes_comments).to eq "Hello"
expect(intake.cv_p2_notes_comments).to eq "additional income from banana stand"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we see "Other money received during the year includes:" text anywhere in the feature specs?


textArea.addEventListener("input", function() {
if (!this.value.startsWith(prefix)) {
this.value = prefix + this.value.replace(prefix, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this.value be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to look it up online but I don't think so; nil would only occur if the parameter is not included at all in the submitted form data (like if the field is removed via JavaScript before submission)


textArea.form.addEventListener("submit", function() {
if (textArea.value.startsWith(prefix)) {
textArea.value = textArea.value.replace(prefix, '').trim();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can textArea.value be nil? Or is it guaranteed to be ""?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its guaranteed to be at least "", I'm not sure how to check though

form = described_class.new(client, form_attributes)
form.save
intake.reload
end.to change(intake, :had_wages).to "yes"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come had_wages is treated differently from all the other attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could do a long chain of .and change( for the rest of the changes but I decided to use the other pattern and just establish that at least one had changed on the form save; I could just change to use one or the other if its confusing though

Copy link
Contributor

@arinchoi03 arinchoi03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple questions, just want to understand better!

@spompea-cfa
Copy link
Contributor

spompea-cfa commented Feb 26, 2025

Hey @embarnard , thanks for tackling this!

Some good comments here from @arinchoi03 .

Zooming out a bit, a couple things didn't seem to work quite right:

  • When i created an intake using the intake flow and entered a string value on
    the Questions::OtherIncomeTypesController screen, I didn't see that string
    show up in the Hub (p2) and I didn't see it on the "Notes/Comments" of page 2 of
    the generated PDF either.
  • When no value was entered into the Questions::OtherIncomeTypesController
    screen, I still saw the prefix string (i.e., 'Other money received during the
    year includes:') populating into the "Notes/Comments" field in the Hub Page 2.
    I think we should just leave that field blank when other_income_types is
    empty/unfilled.
  • Also regarding the "Notes/Comments" field in the Hub Page 2: I couldn't
    clear/delete the prefix string from the text field. And if I held
    down the backspace key, there was some weirdness where it would keep
    repasting a 2nd copy of the prefix
    string into the field (see GIF below). I think that text field should be fully editable by a
    partner, including setting it to blank if desired.

GIF showing the backspace behavior:

hub-page-2-field-backspace

Good news, i think there's a simpler way to do all of this (without JavaScript
etc). I think the logic needed can be placed into other_income_types_form.rb.
My first thought is that something like this would do it:

if other_income_types is non-empty
  then cv_p2_notes_comments = prexix_string + other_income_types
else cv_p2_notes_comments = ''

There's a sorta-kinda similar thing happening in savings_options_form.rb, just
as an example.

I love the JavaScript idea, I that that was cool actually! 🥞 , but yeah, i think at
the end of the day, I think that can be backed out in favour of just adding some
logic into the form class.

On a separate note, about the switch to using cfa_textarea: per a comment on
https://codeforamerica.atlassian.net/browse/GYR1-680, it sounds like we're
combining GYR1-680 with this one? If so, then I think edit_13614c_form_page3
has a few "Notes/Comments" fields that need updating too.

And definitely let me know if you think I missed / misunderstood something here.

@embarnard
Copy link
Contributor Author

embarnard commented Feb 28, 2025

Hey @embarnard , thanks for tackling this!

Some good comments here from @arinchoi03 .

Zooming out a bit, a couple things didn't seem to work quite right:

  • When i created an intake using the intake flow and entered a string value on
    the Questions::OtherIncomeTypesController screen, I didn't see that string
    show up in the Hub (p2) and I didn't see it on the "Notes/Comments" of page 2 of
    the generated PDF either.
  • When no value was entered into the Questions::OtherIncomeTypesController
    screen, I still saw the prefix string (i.e., 'Other money received during the
    year includes:') populating into the "Notes/Comments" field in the Hub Page 2.
    I think we should just leave that field blank when other_income_types is
    empty/unfilled.
  • Also regarding the "Notes/Comments" field in the Hub Page 2: I couldn't
    clear/delete the prefix string from the text field. And if I held
    down the backspace key, there was some weirdness where it would keep
    repasting a 2nd copy of the prefix
    string into the field (see GIF below). I think that text field should be fully editable by a
    partner, including setting it to blank if desired.

GIF showing the backspace behavior:

hub-page-2-field-backspace hub-page-2-field-backspace

Good news, i think there's a simpler way to do all of this (without JavaScript etc). I think the logic needed can be placed into other_income_types_form.rb. My first thought is that something like this would do it:

if other_income_types is non-empty
  then cv_p2_notes_comments = prexix_string + other_income_types
else cv_p2_notes_comments = ''

There's a sorta-kinda similar thing happening in savings_options_form.rb, just as an example.

I love the JavaScript idea, I that that was cool actually! 🥞 , but yeah, i think at the end of the day, I think that can be backed out in favour of just adding some logic into the form class.

On a separate note, about the switch to using cfa_textarea: per a comment on https://codeforamerica.atlassian.net/browse/GYR1-680, it sounds like we're combining GYR1-680 with this one? If so, then I think edit_13614c_form_page3 has a few "Notes/Comments" fields that need updating too.

And definitely let me know if you think I missed / misunderstood something here.

@spompea-cfa Oh oops I didn't check the Questions::OtherIncomeTypesController thoroughly because the requirements of the jira ticket only lists populating it into the hub form and the pdf and I think I had missed that the field that they use on the other_income_types_form is different from the one that is on the hub editable 13614c other_income_types vs cv_p2_notes_comments.

Which brings us to a dilemma of which one to use. I'm leaning towards the original other_income_types since the cv_ fields refer to certified volunteer only although it does look like its technically under the "certified volunteer" section. Or I guess the other option is to keep them separate but to string them together somehow. What do you think?

So the way that the javascript is working is that it inserts it into the field if its not there but also removes the prefix on submit so that we are not actually saving the prefix into the the field. Thats why if you try to remove it it will insert it back into the page. It's not a bug, it's intentional but I agree it might be frustrating or confusing if someone want to remove it. I could instead just insert it upon page load instead of always listening to that element to see if its in there.

I don't understand how the option of only putting it into the other_income_types_form.rb would work since shouldn't the editable 13614c in the hub work as an online intake (aka when the client only fills out their info through a vita partner and doesn't go through the flow at all). Also going back to a page and forward would necessitate some checking if the prefix was already there to make sure we aren't inserting it more than once.

If we want to make this prefix editable then I guess we could just insert it anytime the value of other_income_types goes from nil to non-nil. But then there is more questions about letting the client edit it vs the user. I think there are a lot of fundamental questions about how this should work from the user/client facing side so I'll try to get on a call with Ryan later today to clarify.

Thanks so much for the review and all your extensive notes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants