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:
parent
f5c76af6cb
commit
8b335cfb07
@ -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;
|
||||
|
@ -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()
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -91,7 +91,7 @@ let UploadButton = React.createClass({
|
||||
return (
|
||||
<span>
|
||||
<Glyphicon glyph="ok" />
|
||||
{' ' + truncateTextAtCharIndex(uploadedFile.name, 20)}
|
||||
{' ' + truncateTextAtCharIndex(uploadedFile.name, 40)}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
|
@ -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}`;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user