Skip to content

Commit

Permalink
prevent users from modifying data on submit
Browse files Browse the repository at this point in the history
  • Loading branch information
jannakha committed Aug 14, 2017
1 parent 13f95b1 commit 3406ded
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 28 deletions.
51 changes: 31 additions & 20 deletions src/modules/PublicationForm/components/Forms/BookForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PropTypes from 'prop-types';
export default class BookForm extends Component {

static propTypes = {
submitting: PropTypes.bool,
vocabId: PropTypes.number
}

Expand All @@ -23,38 +24,48 @@ export default class BookForm extends Component {
<StandardCard title={txt.information.title} help={txt.information.help}>
<div className="columns" style={{marginTop: '-12px'}}>
<div className="column">
<Field component={TextField}
autoFocus
name="rek_title"
type="text"
fullWidth
multiLine
rows={1}
floatingLabelText={txt.information.fieldLabels.bookTitle}
validate={[validation.required]}
style={{marginBottom: '-12px'}}
/>
<Field
component={TextField}
autoFocus
disabled={this.props.submitting}
name="rek_title"
type="text"
fullWidth
multiLine
rows={1}
floatingLabelText={txt.information.fieldLabels.bookTitle}
validate={[validation.required]}
style={{marginBottom: '-12px'}} />
</div>
</div>
<div className="columns">
<div className="column">
<Field component={PublicationSubtypeField}
name="rek_subtype"
vocabId={this.props.vocabId}
className="requiredField"
locale={{label: txt.information.fieldLabels.subtype}}
validate={[validation.required]}
/>
<Field
component={PublicationSubtypeField}
name="rek_subtype"
disabled={this.props.submitting}
vocabId={this.props.vocabId}
className="requiredField"
locale={{label: txt.information.fieldLabels.subtype}}
validate={[validation.required]} />
</div>
</div>
</StandardCard>

<StandardCard title={txt.authors.title} help={txt.authors.help}>
<Field component={ContributorsEditorField} name="authors" locale={{contributorSuffix: txt.authors.suffix}}/>
<Field
component={ContributorsEditorField}
name="authors"
locale={{contributorSuffix: txt.authors.suffix}}
disabled={this.props.submitting} />
</StandardCard>

<StandardCard title={txt.editors.title} help={txt.editors.help}>
<Field component={ContributorsEditorField} name="editors" locale={{contributorSuffix: txt.editors.suffix}}/>
<Field
component={ContributorsEditorField}
name="editors"
locale={{contributorSuffix: txt.editors.suffix}}
disabled={this.props.submitting} />
</StandardCard>

</div>
Expand Down
37 changes: 30 additions & 7 deletions src/modules/PublicationForm/components/Forms/JournalArticleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {validation, locale} from 'config';

export default class JournalArticleForm extends Component {
static propTypes = {
submitting: PropTypes.bool,
vocabId: PropTypes.number
};

Expand All @@ -26,6 +27,7 @@ export default class JournalArticleForm extends Component {
<div className="columns" style={{marginTop: '-12px'}}>
<div className="column">
<Field component={TextField}
disabled={this.props.submitting}
autoFocus
name="rek_title"
type="text"
Expand All @@ -42,6 +44,7 @@ export default class JournalArticleForm extends Component {
<div className="columns">
<div className="column is-half">
<Field component={TextField}
disabled={this.props.submitting}
name="fez_record_search_key_journal_name.rek_journal_name"
type="text"
className="requiredField"
Expand All @@ -52,6 +55,7 @@ export default class JournalArticleForm extends Component {
</div>
<div className="column">
<Field component={ PartialDateField }
disabled={this.props.submitting}
name="rek_date"
allowPartial
className="requiredField"
Expand All @@ -62,6 +66,7 @@ export default class JournalArticleForm extends Component {
<div className="column">
<Field component={PublicationSubtypeField}
name="rek_subtype"
disabled={this.props.submitting}
vocabId={this.props.vocabId}
className="requiredField"
locale={{label: txt.information.fieldLabels.subtype}}
Expand All @@ -72,7 +77,11 @@ export default class JournalArticleForm extends Component {
</StandardCard>

<StandardCard title={txt.authors.title} help={txt.authors.help}>
<Field component={ContributorsEditorField} name="authors" locale={{contributorSuffix: txt.authors.suffix}} />
<Field component={ContributorsEditorField}
name="authors"
locale={{contributorSuffix: txt.authors.suffix}}
disabled={this.props.submitting}
/>
</StandardCard>

<StandardCard title={txt.optional.title} help={txt.optional.help}>
Expand All @@ -81,45 +90,59 @@ export default class JournalArticleForm extends Component {
<Field component={TextField}
name="fez_record_search_key_volume_number.rek_volume_number" type="text"
fullWidth
disabled={this.props.submitting}
floatingLabelText={txt.optional.fieldLabels.volume}/>
</div>
<div className="column">
<Field component={TextField} name="fez_record_search_key_issue_number.rek_issue_number"
type="text" fullWidth
disabled={this.props.submitting}
floatingLabelText={txt.optional.fieldLabels.issue}/>
</div>

<div className="column">
<Field component={TextField} name="fez_record_search_key_start_page.rek_start_page"
type="text" fullWidth
type="text"
fullWidth
disabled={this.props.submitting}
floatingLabelText={txt.optional.fieldLabels.startPage}/>
</div>
<div className="column">
<Field component={TextField} name="fez_record_search_key_end_page.rek_end_page"
type="text" fullWidth
type="text"
fullWidth
disabled={this.props.submitting}
floatingLabelText={txt.optional.fieldLabels.endPage}/>
</div>
</div>
<div className="columns">
<div className="column">
<Field component={TextField}
name="fez_record_search_key_article_number.rek_article_number"
type="text" fullWidth multiLine
type="text"
fullWidth
disabled={this.props.submitting}
floatingLabelText={txt.optional.fieldLabels.articleNumber}/>
</div>
</div>
<div className="columns">
<div className="column">
<Field component={TextField} name="fez_record_search_key_notes.rek_notes" type="text"
fullWidth multiLine
rows={1} floatingLabelText={txt.optional.fieldLabels.notes}/>
<Field component={TextField}
name="fez_record_search_key_notes.rek_notes"
type="text"
disabled={this.props.submitting}
fullWidth
multiLine
rows={1}
floatingLabelText={txt.optional.fieldLabels.notes}/>
</div>
</div>
<div className="columns">
<div className="column">
<Field component={TextField}
name="rek_link"
type="text"
disabled={this.props.submitting}
fullWidth
floatingLabelText={txt.optional.fieldLabels.url}
validate={[validation.url, validation.maxLength255]}
Expand Down
9 changes: 8 additions & 1 deletion src/modules/PublicationForm/components/PublicationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ export default class PublicationForm extends Component {
const filteredPublicationType = publicationTypeId ?
this.publicationTypes.filter((item) => { return item.id === publicationTypeId; }) : null;
return filteredPublicationType && filteredPublicationType.length > 0 && filteredPublicationType[0].formComponent ?
React.createElement(filteredPublicationType[0].formComponent, {vocabId: filteredPublicationType[0].vocabId}) : null;
React.createElement(
filteredPublicationType[0].formComponent,
{
vocabId: filteredPublicationType[0].vocabId,
submitting: this.props.submitting
})
:
null;
};

render() {
Expand Down

0 comments on commit 3406ded

Please sign in to comment.