mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
acl information render refactored
This commit is contained in:
parent
2d87533009
commit
f0761ec36b
@ -13,7 +13,7 @@ let AclInformation = React.createClass({
|
|||||||
]),
|
]),
|
||||||
aim: React.PropTypes.string
|
aim: React.PropTypes.string
|
||||||
},
|
},
|
||||||
render() {
|
getInfoText(title, info, example){
|
||||||
let titleStyle = {
|
let titleStyle = {
|
||||||
color: '#02B6A3',
|
color: '#02B6A3',
|
||||||
fontSize: '11px',
|
fontSize: '11px',
|
||||||
@ -37,12 +37,9 @@ let AclInformation = React.createClass({
|
|||||||
lineHeight: '15px',
|
lineHeight: '15px',
|
||||||
align: 'justify'
|
align: 'justify'
|
||||||
};
|
};
|
||||||
let enabledIndices = this.props.verbs;
|
|
||||||
let aim = this.props.aim;
|
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) {
|
||||||
if (aim === 'form') {
|
if (aim === 'form') {
|
||||||
return (<p style={paragraphStyle}>
|
return (<p style={paragraphStyle}>
|
||||||
@ -58,8 +55,12 @@ let AclInformation = React.createClass({
|
|||||||
else {
|
else {
|
||||||
console.log('Aim is required when you want to place information text');
|
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 sortedIndices = ['share', 'transfer', 'consign', 'loan', 'delete'];
|
||||||
let tempIndices = [];
|
let tempIndices = [];
|
||||||
for (let i = 0; i < sortedIndices.length; i++){
|
for (let i = 0; i < sortedIndices.length; i++){
|
||||||
@ -72,16 +73,13 @@ let AclInformation = React.createClass({
|
|||||||
}
|
}
|
||||||
enabledIndices = tempIndices;
|
enabledIndices = tempIndices;
|
||||||
if(Array.isArray(enabledIndices)) {
|
if(Array.isArray(enabledIndices)) {
|
||||||
rows = enabledIndices.map((i)=> {
|
return enabledIndices.map((i)=> {
|
||||||
return (createJSXTextSnippet(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
|
return (this.getInfoText(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
|
||||||
getLangText(exampleSentenceList[i]),
|
getLangText(exampleSentenceList[i])));
|
||||||
titleStyle, infoStyle, exampleStyle));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (typeof enabledIndices === 'string'){
|
else if (typeof enabledIndices === 'string'){
|
||||||
rows = (createJSXTextSnippet(getLangText(titleList[enabledIndices]), getLangText(infoSentenceList[enabledIndices]),
|
return (this.getInfoText(getLangText(titleList[enabledIndices]), getLangText(infoSentenceList[enabledIndices])));
|
||||||
getLangText(exampleSentenceList[enabledIndices]),
|
|
||||||
titleStyle, infoStyle, exampleStyle));
|
|
||||||
}
|
}
|
||||||
else if (typeof enabledIndices === 'undefined'){
|
else if (typeof enabledIndices === 'undefined'){
|
||||||
console.log('Verbs come undefined maybe you wrote verb instead of verbs?');
|
console.log('Verbs come undefined maybe you wrote verb instead of verbs?');
|
||||||
@ -89,7 +87,10 @@ let AclInformation = React.createClass({
|
|||||||
else {
|
else {
|
||||||
console.log('You need to supply an array of strings or string as verbs to AclInformation');
|
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>);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ let ModalWrapper = React.createClass({
|
|||||||
<span>
|
<span>
|
||||||
{trigger}
|
{trigger}
|
||||||
<Modal show={this.state.showModal} onHide={this.hide}>
|
<Modal show={this.state.showModal} onHide={this.hide}>
|
||||||
<Modal.Header style={modalHeaderAscribe} closeButton>
|
<Modal.Header closeButton>
|
||||||
<Modal.Title>
|
<Modal.Title>
|
||||||
{this.props.title}
|
{this.props.title}
|
||||||
</Modal.Title>
|
</Modal.Title>
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<div className="modal-body" style={modalBodyAscribe}>
|
<div className="modal-body" >
|
||||||
{this.renderChildren()}
|
{this.renderChildren()}
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
Loading…
Reference in New Issue
Block a user