Fundraiser login & ActionForm bug fix #1096
Conversation
app/javascript/packs/fundraiser.js
Outdated
@@ -88,3 +88,5 @@ window.mountFundraiser = function(root: string, data: MountFundraiserOptions) { | |||
}); | |||
} | |||
}; | |||
|
|||
window.storeDispatch = dispatch; |
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.
Had you intended on keeping this global?
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.
yeah, I need to expose the store to our petition backbone app. Is there any other way to do this?
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.
Left a comment on the other PR: the redux store is in window.champaign.store
so you'll have access to store.dispatch()
, store.getState()
, store.subscribe()
, etc.
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.
good idea, I'll change it
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 store was already in window.champaign.store
. Changing the code to use that.
prefill() { | ||
const data = {}; | ||
for (const field of this.props.fields) { | ||
data[field.name] = | ||
this.getPrefillValue(field.name) || field.default_value; | ||
data[field.name] = this.props.formValues[field.name] |
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.
Did you mean this.props.formValues ? ... : ...
here? It seems from the former getPrefillValue
that the prop might be undefined
/ null
.
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.
ouch! good catch.
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, it's already there! I was confused. The ternary operator expands to multiple lines, check the following 2 lines.
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.
Yeah, but the first line tries to access a property (but the object could be undefined).
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.
Although I'm not sure if it's intended or just being overprotective? formValues
is always an object in the reducer.
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.
Ideally the store should make sure that formValues is always an object, but right now it's not doing that. I'll add the check.
@@ -159,15 +154,15 @@ export class MemberDetailsForm extends Component { | |||
onSubmit={this.submit.bind(this)} | |||
className="form--big action-form" | |||
> | |||
{this.props.fields.map((field, ii) => | |||
{this.props.fields.map((field, ii) => ( |
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.
Seems like ii
is unused here (although that was also there from the previous version, but worth cleaning up)
@@ -130,12 +132,13 @@ export class FundraiserView extends Component { | |||
} | |||
fields={fields} | |||
outstandingFields={outstandingFields} | |||
prefillValues={formValues} | |||
formValues={formValues} |
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.
👍
60d7855
to
8b4c2be
Compare
0ae042d
to
e46d9aa
Compare
Added
login_member
action to fundraiser store. This allows the member information to be set after the component has been initialized.Modified
action_form.js
to publish the form data after being submitted.Fixed bug that caused
action_form
to submit wrong values. The action form prefilling logic was broken, and was actually modifying the DOM in a wrong way (specifically checkboxes and radio buttons). The radio buttons, check boxes and textareas prefilling doesn't work (and wasn't working before either).