diff --git a/javascripts/src/components/common/ProgressableButton.tsx b/javascripts/src/components/common/ProgressableButton.tsx index 80a940ed..b174945b 100644 --- a/javascripts/src/components/common/ProgressableButton.tsx +++ b/javascripts/src/components/common/ProgressableButton.tsx @@ -26,13 +26,13 @@ class ProgressableButton extends React.Component { if (this.props.inProgress){ ourData.title = this.props.titleOnProgress || this.props.title ourData.disabled = ourData.disabled || this.props.disableOnProgress - ourData.prefix = + ourData.prefix = } let props = _.omit(this.props, ['title', 'disableOnProgress', 'titleOnProgress', 'inProgress']) - return ; } } diff --git a/javascripts/src/components/registration_page/NonprofitInfoForm.tsx b/javascripts/src/components/registration_page/NonprofitInfoForm.tsx index 51b8eb39..522e4708 100644 --- a/javascripts/src/components/registration_page/NonprofitInfoForm.tsx +++ b/javascripts/src/components/registration_page/NonprofitInfoForm.tsx @@ -6,6 +6,7 @@ import {Field, FieldDefinition} from "../../../../types/mobx-react-form"; import {BasicField} from "../common/fields"; import {ThreeColumnFields, TwoColumnFields} from "../common/layout"; import {Validations} from "../../lib/vjf_rules"; +import ProgressableButton from "../common/ProgressableButton"; export interface NonprofitInfoFormProps { @@ -71,8 +72,7 @@ class NonprofitInfoForm extends React.Component - + } } diff --git a/javascripts/src/components/registration_page/UserInfoForm.tsx b/javascripts/src/components/registration_page/UserInfoForm.tsx index 934db052..8098a977 100644 --- a/javascripts/src/components/registration_page/UserInfoForm.tsx +++ b/javascripts/src/components/registration_page/UserInfoForm.tsx @@ -6,6 +6,8 @@ import {Validations} from "../../lib/vjf_rules"; import {Field, FieldDefinition} from "mobx-react-form"; import {TwoColumnFields} from "../common/layout"; import {BasicField} from "../common/fields"; +import ProgressableButton from "../common/ProgressableButton"; +import {areWeOrAnyParentSubmitting} from "../../lib/houdini_form"; export const FieldDefinitions : Array = [ { @@ -53,9 +55,12 @@ class UserInfoForm extends React.Component - + ; } } diff --git a/javascripts/src/lib/houdini_form.ts b/javascripts/src/lib/houdini_form.ts index 7c821da6..17afc0e5 100644 --- a/javascripts/src/lib/houdini_form.ts +++ b/javascripts/src/lib/houdini_form.ts @@ -1,5 +1,5 @@ // License: LGPL-3.0-or-later -import {Form} from "mobx-react-form"; +import {Field, Form} from "mobx-react-form"; import {action, runInAction} from 'mobx' import validator = require("validator") import * as _ from 'lodash' @@ -17,6 +17,20 @@ export class HoudiniForm extends Form { } +export function areWeOrAnyParentSubmitting(f:Field|Form ) : boolean +{ + let currentItem: Field|Form = f + let isSubmitting:boolean = f.submitting + while (!isSubmitting && currentItem && !(currentItem instanceof Form)){ + currentItem = currentItem.container() + isSubmitting = currentItem.submitting + } + + return isSubmitting +} + + + interface PathToFormField { [props: string]: string @@ -84,4 +98,6 @@ export class StaticFormToErrorAndBackConverter { }) }) } -} \ No newline at end of file +} + + diff --git a/types/mobx-react-form/index.d.ts b/types/mobx-react-form/index.d.ts index f70ef499..4f6c3bb3 100644 --- a/types/mobx-react-form/index.d.ts +++ b/types/mobx-react-form/index.d.ts @@ -79,7 +79,7 @@ export declare class Field implements Base, FieldProperties, FieldMethods, Field clear(); - container(): Form + container(): Form |Field del(key: any);