mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-02-07 01:15:51 +05:30
Move FormModel to components/ui/form. Fixed el typechecking in ref callback
This commit is contained in:
parent
82416f788f
commit
e1f16d7346
@ -5,7 +5,7 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
|
|
||||||
import AuthError from 'components/auth/authError/AuthError';
|
import AuthError from 'components/auth/authError/AuthError';
|
||||||
import { userShape } from 'components/user/User';
|
import { userShape } from 'components/user/User';
|
||||||
import Form from 'models/Form';
|
import { FormModel } from 'components/ui/form';
|
||||||
|
|
||||||
export default class BaseAuthBody extends Component {
|
export default class BaseAuthBody extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
@ -32,7 +32,7 @@ export default class BaseAuthBody extends Component {
|
|||||||
|
|
||||||
onClearErrors = this.context.clearErrors;
|
onClearErrors = this.context.clearErrors;
|
||||||
|
|
||||||
form = new Form();
|
form = new FormModel();
|
||||||
|
|
||||||
bindField = this.form.bindField.bind(this.form);
|
bindField = this.form.bindField.bind(this.form);
|
||||||
serialize = this.form.serialize.bind(this.form);
|
serialize = this.form.serialize.bind(this.form);
|
||||||
|
@ -4,8 +4,7 @@ import { FormattedMessage as Message } from 'react-intl';
|
|||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
import { Input, Button, Checkbox, Form } from 'components/ui/form';
|
import { Input, Button, Checkbox, Form, FormModel } from 'components/ui/form';
|
||||||
import FormModel from 'models/Form';
|
|
||||||
|
|
||||||
import styles from 'components/profile/profileForm.scss';
|
import styles from 'components/profile/profileForm.scss';
|
||||||
import messages from './ChangePassword.messages';
|
import messages from './ChangePassword.messages';
|
||||||
@ -14,7 +13,7 @@ export default class ChangePassword extends Component {
|
|||||||
static displayName = 'ChangePassword';
|
static displayName = 'ChangePassword';
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
form: PropTypes.instanceOf(FormModel).isRequired,
|
form: PropTypes.instanceOf(FormModel),
|
||||||
onSubmit: PropTypes.func.isRequired
|
onSubmit: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
|
|
||||||
import { FormattedMessage as Message } from 'react-intl';
|
import { FormattedMessage as Message } from 'react-intl';
|
||||||
|
|
||||||
import FormModel from 'models/Form';
|
import { Form, Button, Input, FormModel } from 'components/ui/form';
|
||||||
import { Form, Button, Input } from 'components/ui/form';
|
|
||||||
|
|
||||||
import messages from './PasswordRequestForm.messages';
|
import messages from './PasswordRequestForm.messages';
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import FormModel from 'models/Form';
|
import FormModel from './FormModel';
|
||||||
|
|
||||||
import styles from './form.scss';
|
import styles from './form.scss';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import FormInputComponent from 'components/ui/form/FormInputComponent';
|
import FormInputComponent from './FormInputComponent';
|
||||||
|
|
||||||
export default class Form {
|
export default class FormModel {
|
||||||
fields = {};
|
fields = {};
|
||||||
errors = {};
|
errors = {};
|
||||||
|
|
||||||
@ -18,8 +18,8 @@ export default class Form {
|
|||||||
const props = {
|
const props = {
|
||||||
name,
|
name,
|
||||||
ref: (el) => {
|
ref: (el) => {
|
||||||
if (!(el instanceof FormInputComponent)) {
|
if (el && !(el instanceof FormInputComponent)) {
|
||||||
throw new Error('Expected a component from components/ui/form module');
|
throw new Error('Expected FormInputComponent component');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fields[name] = el;
|
this.fields[name] = el;
|
@ -2,10 +2,12 @@ import Input from './Input';
|
|||||||
import Checkbox from './Checkbox';
|
import Checkbox from './Checkbox';
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
import Form from './Form';
|
import Form from './Form';
|
||||||
|
import FormModel from './FormModel';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Input,
|
Input,
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Form
|
Form,
|
||||||
|
FormModel
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
|
||||||
import accounts from 'services/api/accounts';
|
import accounts from 'services/api/accounts';
|
||||||
import FormModel from 'models/Form';
|
import { FormModel } from 'components/ui/form';
|
||||||
import ChangePassword from 'components/profile/changePassword/ChangePassword';
|
import ChangePassword from 'components/profile/changePassword/ChangePassword';
|
||||||
import PasswordRequestForm from 'components/profile/passwordRequestForm/PasswordRequestForm';
|
import PasswordRequestForm from 'components/profile/passwordRequestForm/PasswordRequestForm';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user