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

acl information render refactored

This commit is contained in:
Cevo 2015-10-14 12:16:49 +02:00
parent 2d87533009
commit f0761ec36b
2 changed files with 31 additions and 30 deletions

View File

@ -13,7 +13,7 @@ let AclInformation = React.createClass({
]),
aim: React.PropTypes.string
},
render() {
getInfoText(title, info, example){
let titleStyle = {
color: '#02B6A3',
fontSize: '11px',
@ -37,12 +37,9 @@ let AclInformation = React.createClass({
lineHeight: '15px',
align: 'justify'
};
let enabledIndices = this.props.verbs;
let aim = this.props.aim;
let titleList = informationTexts.title;
let infoSentenceList = informationTexts.informationSentence;
let exampleSentenceList = informationTexts.exampleSentence;
let createJSXTextSnippet = function(title, info, example){
if (aim) {
if (aim === 'form') {
return (<p style={paragraphStyle}>
@ -58,8 +55,12 @@ let AclInformation = React.createClass({
else {
console.log('Aim is required when you want to place information text');
}
};
let rows = null;
},
produceInformationBlock(){
let enabledIndices = this.props.verbs;
let titleList = informationTexts.title;
let infoSentenceList = informationTexts.informationSentence;
let exampleSentenceList = informationTexts.exampleSentence;
let sortedIndices = ['share', 'transfer', 'consign', 'loan', 'delete'];
let tempIndices = [];
for (let i = 0; i < sortedIndices.length; i++){
@ -72,16 +73,13 @@ let AclInformation = React.createClass({
}
enabledIndices = tempIndices;
if(Array.isArray(enabledIndices)) {
rows = enabledIndices.map((i)=> {
return (createJSXTextSnippet(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
getLangText(exampleSentenceList[i]),
titleStyle, infoStyle, exampleStyle));
return enabledIndices.map((i)=> {
return (this.getInfoText(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
getLangText(exampleSentenceList[i])));
});
}
else if (typeof enabledIndices === 'string'){
rows = (createJSXTextSnippet(getLangText(titleList[enabledIndices]), getLangText(infoSentenceList[enabledIndices]),
getLangText(exampleSentenceList[enabledIndices]),
titleStyle, infoStyle, exampleStyle));
return (this.getInfoText(getLangText(titleList[enabledIndices]), getLangText(infoSentenceList[enabledIndices])));
}
else if (typeof enabledIndices === 'undefined'){
console.log('Verbs come undefined maybe you wrote verb instead of verbs?');
@ -89,7 +87,10 @@ let AclInformation = React.createClass({
else {
console.log('You need to supply an array of strings or string as verbs to AclInformation');
}
return (<span>{rows}</span>);
},
render() {
console.log('Creation of information block');
return (<span>{this.produceInformationBlock()}</span>);
}
});

View File

@ -72,12 +72,12 @@ let ModalWrapper = React.createClass({
<span>
{trigger}
<Modal show={this.state.showModal} onHide={this.hide}>
<Modal.Header style={modalHeaderAscribe} closeButton>
<Modal.Header closeButton>
<Modal.Title>
{this.props.title}
</Modal.Title>
</Modal.Header>
<div className="modal-body" style={modalBodyAscribe}>
<div className="modal-body" >
{this.renderChildren()}
</div>
</Modal>