1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Include feedback from PR

This commit is contained in:
Tim Daubenschütz 2015-11-13 09:48:22 +01:00
parent f5c76af6cb
commit 8b335cfb07
5 changed files with 15 additions and 20 deletions

View File

@ -276,29 +276,29 @@ let Form = React.createClass({
* everything is valid
*/
_hasRefErrors(refToValidate) {
let error = [];
Object
let errors = Object
.keys(refToValidate)
.forEach((constraintKey) => {
.reduce((a, constraintKey) => {
const contraintValue = refToValidate[constraintKey];
if(!contraintValue) {
switch(constraintKey) {
case 'min' || 'max':
error.push(getLangText('The field you defined is not in the valid range'));
a.push(getLangText('The field you defined is not in the valid range'));
break;
case 'pattern':
error.push(getLangText('The value you defined is not matching the valid pattern'));
a.push(getLangText('The value you defined is not matching the valid pattern'));
break;
case 'required':
error.push(getLangText('This field is required'));
a.push(getLangText('This field is required'));
break;
}
}
});
return error.length ? error : false;
return a;
}, []);
return errors.length ? errors : false;
},
/**
@ -335,8 +335,8 @@ let Form = React.createClass({
refToValidate.required = required ? value : true;
refToValidate.pattern = pattern && typeof value === 'string' ? value.match(pattern) : true;
refToValidate.max = type === 'number' ? parseInt(value) <= max : true;
refToValidate.min = type === 'number' ? parseInt(value) >= min : true;
refToValidate.max = type === 'number' ? parseInt(value, 10) <= max : true;
refToValidate.min = type === 'number' ? parseInt(value, 10) >= min : true;
const validatedRef = this._hasRefErrors(refToValidate);
validatedFormInputs[refName] = validatedRef;

View File

@ -181,9 +181,7 @@ let Property = React.createClass({
setErrors(errors){
this.setState({
errors: errors.map((error) => {
return <span className="pull-right" key={error}>{error}</span>;
})
errors: errors.pop()
});
},

View File

@ -91,7 +91,7 @@ let UploadButton = React.createClass({
return (
<span>
<Glyphicon glyph="ok" />
{' ' + truncateTextAtCharIndex(uploadedFile.name, 20)}
{' ' + truncateTextAtCharIndex(uploadedFile.name, 40)}
</span>
);
} else {

View File

@ -80,7 +80,6 @@ export function getCookie(name) {
export function setCookie(key, value, days) {
const exdate = moment();
exdate.add(days, 'days');
console.log(exdate.utc());
value = window.escape(value) + ((days === null) ? '' : `; expires= ${exdate.utc()}`);
document.cookie = `${key}=${value}`;
}

View File

@ -93,10 +93,8 @@ $pr--button-color: $pr--nav-fg-prim-color;
}
.ascribe-property {
> p {
> span {
text-transform: capitalize;
}
> p > span:not(> .span) {
text-transform: capitalize;
}
}
}