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

stylistic changes to save button #27

Merged
Merged
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
11 changes: 11 additions & 0 deletions htdocs/css/direct-entry.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ label {
align-items: center;
font-size: 2em;
}

#save {
margin: auto;
display: block;
color: white;
background-color: #08245b;
}

#warning {
color: red;
}
15 changes: 9 additions & 6 deletions jsx/InstrumentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { SelectElement, RadioGroupLabels, RadioGroupElement, CheckboxGroupElement
* The meta and elements passed to this component must already be 'localized'
* (see ./lib/localize-instrument).
*/
const InstrumentForm = ({meta, elements, showRequired, errorMessage, onUpdate, onSave}) => {
const InstrumentForm = ({meta, elements, showRequired, errorMessage, onUpdate, onSave, saveText, saveWarning}) => {
return (
<div>
<div id="instrument-error">
Expand All @@ -19,7 +19,7 @@ const InstrumentForm = ({meta, elements, showRequired, errorMessage, onUpdate, o
renderElement(element, index, onUpdate, showRequired && element.Options.RequireResponse)
))
}
<SaveButton onClick={onSave}/>
<SaveButton onClick={onSave} saveText={saveText} saveWarning={saveWarning}/>
</div>
);
};
Expand Down Expand Up @@ -145,11 +145,14 @@ function renderDate(element, key, onUpdate, isRequired) {
)
}

const SaveButton = ({onClick}) => {
const SaveButton = ({onClick, saveText, saveWarning}) => {
return (
<button onClick={onClick} type="button" className="btn btn-default btn-lg">
<span className="" aria-hidden="true"></span> Save
</button>
<div>
<button onClick={onClick} id="save" type="button" className="btn btn-default btn-lg">
<span className="" aria-hidden="true"></span> {saveText}
</button>
<p id="warning"><center>{saveWarning}</center></p>
</div>
);
}

Expand Down
26 changes: 23 additions & 3 deletions jsx/InstrumentFormContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,32 @@ class InstrumentFormContainer extends React.Component {
data: this.props.initialData,
localizedInstrument: localizeInstrument(this.props.instrument, this.props.lang),
showRequired: false,
errorMessage: null
errorMessage: null,
};

this.updateInstrumentData = this.updateInstrumentData.bind(this);
this.incompleteRequiredFieldExists = this.incompleteRequiredFieldExists.bind(this);
this.onSaveButtonClick = this.onSaveButtonClick.bind(this);
}

getSaveText(lang) {
switch(lang) {
case 'en-ca':
return 'Save';
case 'fr-ca':
return 'Enregistrer';
}
}

getSaveWarning(lang) {
switch(lang) {
case 'en-ca':
return 'You cannot modify your answers after clicking this button. Please ensure all answers are correct.';
case 'fr-ca':
return 'Vous ne pouvez pas modifier vos réponses après avoir cliqué sur ce bouton. Assurez-vous que toutes les réponses sont correctes.';
}
}

/**
* This function is called when the user inputs or updates an instrument
* field. It is responsible for updating `state.data`, which involves not
Expand Down Expand Up @@ -186,7 +204,7 @@ class InstrumentFormContainer extends React.Component {

render() {
const { data, localizedInstrument } = this.state;
const { context, options } = this.props;
const { context, options, lang } = this.props;

return (
<InstrumentForm
Expand All @@ -202,6 +220,8 @@ class InstrumentFormContainer extends React.Component {
errorMessage={this.state.errorMessage}
onUpdate={this.updateInstrumentData}
onSave={this.onSaveButtonClick}
saveText={this.getSaveText(lang)}
saveWarning={this.getSaveWarning(lang)}
/>
);
}
Expand Down