Upstream sync

This commit is contained in:
Senad Uka
2018-05-30 08:52:10 +02:00
parent 8e52651172
commit 04debaf3e9
14 changed files with 540 additions and 233 deletions

View File

@@ -8,61 +8,70 @@ const defaultDialogHeight = 100; //px
const dialogHeightPerLine = 25; //px
export class ValidationErrorsInfoDialog extends React.Component {
state = {
constructor(props) {
super(props)
this.props = props;
this.state = {
open: this.props.open,
}
componentWillReceiveProps(newProps){
this.setState({open: newProps.open});
}
handleOpen = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
this.props.onDismiss();
};
render() {
const actions = [
<FlatButton
label="Dismiss"
primary={true}
onClick={this.handleClose}
/>,
];
return (
<div className="container">
{
this.state.open &&
<Dialog
title={this.props.title ? this.props.title : 'Error'}
isDraggable={this.props.draggable ? this.props.draggable : false}
buttons={actions}
hasCloseIcon={false}
modal={this.props.modal ? this.props.modal : false}
height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine}
>
{this.props.errorMessages.map(errorMessage=>{
const oneValidationMessage = (<span><a>{errorMessage.message}</a><br /></span>);
const oneValidationMessageWithTab = (<span><li style={{marginLeft:2 + "em"}}>{errorMessage.message}</li></span>);
if (errorMessage.field_name === "password-tab"){
return oneValidationMessageWithTab;
} else{
return oneValidationMessage;
}
})}
</Dialog>
}
</div>
);
title: "Errors",
}
}
module.exports = ValidationErrorsInfoDialog;
componentWillReceiveProps(newProps) {
let title = this.state.title;
if (newProps.errorTitle) {
title = newProps.errorTitle;
}
this.setState({ open: newProps.open, title: title });
}
handleOpen = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
this.props.onDismiss();
};
render() {
const actions = [
<FlatButton
label="Dismiss"
primary={true}
onClick={this.handleClose}
/>,
];
return (
<div className="container">
{
this.state.open &&
<Dialog
title={this.props.title ? this.props.title : 'Error'}
isDraggable={this.props.draggable ? this.props.draggable : false}
buttons={actions}
hasCloseIcon={false}
modal={this.props.modal ? this.props.modal : false}
height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine}
>
{this.props.errorMessages.map(errorMessage => {
const oneValidationMessage = (<span><a>{errorMessage.message}</a><br /></span>);
const oneValidationMessageWithTab = (<span><li style={{ marginLeft: 2 + "em" }}>{errorMessage.message}</li></span>);
if (errorMessage.field_name === "password-tab") {
return oneValidationMessageWithTab;
} else {
return oneValidationMessage;
}
})}
</Dialog>
}
</div>
);
}
}
module.exports = ValidationErrorsInfoDialog;