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

Whinepad: Let 0 be defaultValue of rating for a new record #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions whinepad2/js/source/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ type Props = {
};

class Form extends Component {

props: Props;

getData(): Object {
let data: Object = {};
this.props.fields.forEach((field: FormInputField) =>
this.props.fields.forEach((field: FormInputField) =>
data[field.id] = this.refs[field.id].getValue()
);
return data;
}

render() {
return (
<form className="Form">{this.props.fields.map((field: FormInputField) => {
const prefilled: FormInputFieldValue = (this.props.initialData && this.props.initialData[field.id]) || '';
const prefilled: ?FormInputFieldValue = this.props.initialData && this.props.initialData[field.id];
if (!this.props.readonly) {
return (
<div className="FormRow" key={field.id}>
Expand Down
8 changes: 4 additions & 4 deletions whinepad2/js/source/components/FormInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export type FormInputField = {
};

class FormInput extends Component {

props: FormInputField;

static defaultProps = {
type: 'input',
};
Expand All @@ -41,7 +41,7 @@ class FormInput extends Component {
return (
<input
{...common}
type="number"
type="number"
defaultValue={this.props.defaultValue || new Date().getFullYear()} />
);
case 'suggest':
Expand All @@ -50,7 +50,7 @@ class FormInput extends Component {
return (
<Rating
{...common}
defaultValue={parseInt(this.props.defaultValue, 10)} />
defaultValue={this.props.defaultValue} />
);
case 'text':
return <textarea {...common} />;
Expand Down
12 changes: 6 additions & 6 deletions whinepad3/js/source/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ type Props = {
};

class Form extends Component {

fields: Array<Object>;
initialData: ?Object;

constructor(props: Props) {
super(props);
this.fields = CRUDStore.getSchema();
if ('recordId' in this.props) {
this.initialData = CRUDStore.getRecord(this.props.recordId);
}
}

getData(): Object {
let data: Object = {};
this.fields.forEach((field: FormInputField) =>
this.fields.forEach((field: FormInputField) =>
data[field.id] = this.refs[field.id].getValue()
);
return data;
}

render() {
return (
<form className="Form">{this.fields.map((field: FormInputField) => {
const prefilled: FormInputFieldValue = (this.initialData && this.initialData[field.id]) || '';
const prefilled: ?FormInputFieldValue = this.initialData && this.initialData[field.id];
if (!this.props.readonly) {
return (
<div className="FormRow" key={field.id}>
Expand Down
10 changes: 5 additions & 5 deletions whinepad3/js/source/components/FormInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export type FormInputField = {
};

class FormInput extends Component {

props: FormInputField;

static defaultProps = {
type: 'input',
};

getValue(): FormInputFieldValue {
return 'value' in this.refs.input
? this.refs.input.value
Expand All @@ -41,7 +41,7 @@ class FormInput extends Component {
return (
<input
{...common}
type="number"
type="number"
defaultValue={this.props.defaultValue || new Date().getFullYear()} />
);
case 'suggest':
Expand All @@ -50,7 +50,7 @@ class FormInput extends Component {
return (
<Rating
{...common}
defaultValue={parseInt(this.props.defaultValue, 10)} />
defaultValue={this.props.defaultValue} />
);
case 'text':
return <textarea {...common} />;
Expand Down