Merged heads

This commit is contained in:
Philipp Czora
2018-08-02 13:50:13 +02:00
3 changed files with 23 additions and 13 deletions

View File

@@ -30,7 +30,9 @@
"label": "Edit" "label": "Edit"
}, },
"group-form": { "group-form": {
"submit": "Submit" "submit": "Submit",
"name-error": "Group name is invalid",
"description-error": "Description is invalid"
}, },
"delete-group-button": { "delete-group-button": {
"label": "Delete", "label": "Delete",

View File

@@ -93,8 +93,9 @@ class Paginator extends React.Component<Props> {
if (page + 1 < pageTotal) { if (page + 1 < pageTotal) {
links.push(this.renderPageButton(page + 1, "next")); links.push(this.renderPageButton(page + 1, "next"));
links.push(this.seperator());
} }
if(page+2 < pageTotal) //if there exists pages between next and last
links.push(this.seperator());
if (page < pageTotal) { if (page < pageTotal) {
links.push(this.renderLastButton()); links.push(this.renderLastButton());
} }

View File

@@ -44,19 +44,25 @@ class GroupForm extends React.Component<Props, State> {
} }
} }
onSubmit = (event: Event) => { isFalsy(value) {
event.preventDefault(); if (!value) {
this.props.submitForm(this.state.group); return true;
}; }
return false;
}
isValid = () => { isValid = () => {
const group = this.state.group; const group = this.state.group;
return !(this.state.nameValidationError || group.name); return !(
this.state.nameValidationError ||
this.isFalsy(group.name) ||
this.isFalsy(group.description)
);
}; };
submit = (event: Event) => { submit = (event: Event) => {
event.preventDefault(); event.preventDefault();
if (this.isValid) { if (this.isValid()) {
this.props.submitForm(this.state.group); this.props.submitForm(this.state.group);
} }
}; };
@@ -69,24 +75,25 @@ class GroupForm extends React.Component<Props, State> {
nameField = ( nameField = (
<InputField <InputField
label={t("group.name")} label={t("group.name")}
errorMessage="group name invalid" // TODO: i18n errorMessage={t("group-form.name-error")}
onChange={this.handleGroupNameChange} onChange={this.handleGroupNameChange}
value={group.name} value={group.name}
validationError={this.state.nameValidationError} validationError={this.state.nameValidationError}
/> />
); );
} }
return ( return (
<form onSubmit={this.onSubmit}> <form onSubmit={this.submit}>
{nameField} {nameField}
<InputField <InputField
label={t("group.description")} label={t("group.description")}
errorMessage="" errorMessage={t("group-form.description-error")}
onChange={this.handleDescriptionChange} onChange={this.handleDescriptionChange}
value={group.description} value={group.description}
validationError={false} validationError={false}
/> />
<SubmitButton label={t("group-form.submit")} loading={loading}/> <SubmitButton disabled={!this.isValid()} label={t("group-form.submit")} loading={loading}/>
</form> </form>
); );
} }