Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

implements the income question change in the demographic survey #555

Merged
merged 10 commits into from
May 20, 2021

Conversation

hamilton
Copy link
Contributor

@hamilton hamilton commented Apr 21, 2021

closes #496. We'll hold on this until (1) we can get the product owner to give a thumbs up and (2) we have a PR up for the schema.

A demo of this is viewable here.

Checklist for reviewer:

  • The description should reference a bug or github issue, if relevant.
  • There must be a CHANGELOG.md entry for any non-test change.
  • Any change to the NPM commands must be carefully reviewed to make sure it won't break the Add-ons pipeline.
  • Any version increase must follow the release process.

@hamilton hamilton changed the title [hold] implements the income question change to be free-form [hold] implements the income question change in the demographic survey Apr 21, 2021
@hamilton hamilton requested a review from knowtheory April 28, 2021 15:35
@knowtheory knowtheory changed the title [hold] implements the income question change in the demographic survey implements the income question change in the demographic survey Apr 29, 2021
@hamilton hamilton requested a review from rhelmer April 29, 2021 17:59
Copy link
Contributor

@rhelmer rhelmer left a comment

Choose a reason for hiding this comment

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

Just nits, looks OK to me. I'm concerned that we need to ratchet our eslint rules up a bit but I will tackle that in a separate issue (we already have one where vscode isn't aligning to what our CI is doing based on the same eslint config I'd like to figure out)

src/routes/demographics/Content.svelte Outdated Show resolved Hide resolved
src/routes/demographics/Content.svelte Outdated Show resolved Hide resolved
src/routes/demographics/Content.svelte Outdated Show resolved Hide resolved
src/routes/demographics/survey-tools.js Outdated Show resolved Hide resolved
src/routes/demographics/survey-tools.js Outdated Show resolved Hide resolved
@hamilton hamilton force-pushed the income-question-change branch from 2f64bff to c639f34 Compare April 30, 2021 03:37
@hamilton hamilton requested a review from rhelmer April 30, 2021 23:00
Copy link
Contributor

@rhelmer rhelmer left a comment

Choose a reason for hiding this comment

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

The formatting functions themselves, plus tests, all lgtm. It also seems to work fine locally. I think some of the more Svelte-specific conventions are a little over my head still, but I like how generic it is.

$: if ($store && $store.demographicsData) {
intermediateResults = formatAnswersForDisplay(schema, { ...$store.demographicsData }, inputFormatters);
}
$: console.log(intermediateResults)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave this?

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 sure didn't.

@@ -0,0 +1,161 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not necessarily opposed to it, but why should this live here vs. in the svelte tests?




/** This Svelte action will format an input element on input, focus, and blur events.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but why does it only format on these events, and not as the user types? Wondering if that is a stylistic choice or just pragmatic. I can see the argument for not modifying input while the user is interacting.

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 believe input is when it formats (which is when the user types / copy-pastes). @changecourse's requirements were to prevent inputs that shouldn't exist (like letters in a number field) instead of showing an error on incorrect input. I tried breaking the experience implemented here in various ways but was unsuccessful. This ultimately felt like the best way to control the nature of the inputs appropriate for (1) the form version of the answers (what should the entered-in format look like when the input field is not active, e.g. $100,000 is what we see vs 100000 or 100000), (2) the edit version of the answers (we don't want the currency fields while typing to have the dollar sign and commas), and (3) the response version of the answers (what should the data look like when it goes to the servers?) These three things may all be different, hence this formatter.

@@ -1,7 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Contributor

@rhelmer rhelmer May 5, 2021

Choose a reason for hiding this comment

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

Is there a PR up for the schema change ? It's nice to have it split out to its own JSON, how easily can we compare it to what's actually loaded on the server side?

I'm presuming that it is https://github.com/mozilla-services/mozilla-pipeline-schemas/blob/main/schemas/pioneer-core/demographic-survey/demographic-survey.1.schema.json, in which case I guess it's not trivially comparable :) Maybe something to consider for the future.

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 agree. There is not a PR out and this schema is really just for the purposes of formatting (probably the wrong wording here). This part of the code base will probably be refactored when a real frontend engineer takes over this part of the codebase. It's not the most confusing setup ever, but it was slapped together pretty quickly and it'd be better to use an actual json schema approach or whatever.

@rhelmer rhelmer merged commit 2a752df into mozilla-rally:master May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement demographic survey form fields for Income Brackets
3 participants