mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +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
|
* everything is valid
|
||||||
*/
|
*/
|
||||||
_hasRefErrors(refToValidate) {
|
_hasRefErrors(refToValidate) {
|
||||||
let error = [];
|
let errors = Object
|
||||||
|
|
||||||
Object
|
|
||||||
.keys(refToValidate)
|
.keys(refToValidate)
|
||||||
.forEach((constraintKey) => {
|
.reduce((a, constraintKey) => {
|
||||||
const contraintValue = refToValidate[constraintKey];
|
const contraintValue = refToValidate[constraintKey];
|
||||||
|
|
||||||
if(!contraintValue) {
|
if(!contraintValue) {
|
||||||
switch(constraintKey) {
|
switch(constraintKey) {
|
||||||
case 'min' || 'max':
|
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;
|
break;
|
||||||
case 'pattern':
|
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;
|
break;
|
||||||
case 'required':
|
case 'required':
|
||||||
error.push(getLangText('This field is required'));
|
a.push(getLangText('This field is required'));
|
||||||
break;
|
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.required = required ? value : true;
|
||||||
refToValidate.pattern = pattern && typeof value === 'string' ? value.match(pattern) : true;
|
refToValidate.pattern = pattern && typeof value === 'string' ? value.match(pattern) : true;
|
||||||
refToValidate.max = type === 'number' ? parseInt(value) <= max : true;
|
refToValidate.max = type === 'number' ? parseInt(value, 10) <= max : true;
|
||||||
refToValidate.min = type === 'number' ? parseInt(value) >= min : true;
|
refToValidate.min = type === 'number' ? parseInt(value, 10) >= min : true;
|
||||||
|
|
||||||
const validatedRef = this._hasRefErrors(refToValidate);
|
const validatedRef = this._hasRefErrors(refToValidate);
|
||||||
validatedFormInputs[refName] = validatedRef;
|
validatedFormInputs[refName] = validatedRef;
|
||||||
|
@ -181,9 +181,7 @@ let Property = React.createClass({
|
|||||||
|
|
||||||
setErrors(errors){
|
setErrors(errors){
|
||||||
this.setState({
|
this.setState({
|
||||||
errors: errors.map((error) => {
|
errors: errors.pop()
|
||||||
return <span className="pull-right" key={error}>{error}</span>;
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ let UploadButton = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<Glyphicon glyph="ok" />
|
<Glyphicon glyph="ok" />
|
||||||
{' ' + truncateTextAtCharIndex(uploadedFile.name, 20)}
|
{' ' + truncateTextAtCharIndex(uploadedFile.name, 40)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,7 +80,6 @@ export function getCookie(name) {
|
|||||||
export function setCookie(key, value, days) {
|
export function setCookie(key, value, days) {
|
||||||
const exdate = moment();
|
const exdate = moment();
|
||||||
exdate.add(days, 'days');
|
exdate.add(days, 'days');
|
||||||
console.log(exdate.utc());
|
|
||||||
value = window.escape(value) + ((days === null) ? '' : `; expires= ${exdate.utc()}`);
|
value = window.escape(value) + ((days === null) ? '' : `; expires= ${exdate.utc()}`);
|
||||||
document.cookie = `${key}=${value}`;
|
document.cookie = `${key}=${value}`;
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,8 @@ $pr--button-color: $pr--nav-fg-prim-color;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ascribe-property {
|
.ascribe-property {
|
||||||
> p {
|
> p > span:not(> .span) {
|
||||||
> span {
|
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user