mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
information button gets the active buttons and shows i only relevant info (Tim I didn't set the arrays as props because it would require more work and fills the memory and are not going to be reused, gc should delete them)
This commit is contained in:
parent
f2d02179a1
commit
03680bd830
@ -44,7 +44,7 @@ let AclButtonList = React.createClass({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div id='aclbuttonlist' className={this.props.className}>
|
||||||
<span style={this.props.buttonsStyle}>
|
<span style={this.props.buttonsStyle}>
|
||||||
<AclButton
|
<AclButton
|
||||||
availableAcls={this.props.availableAcls}
|
availableAcls={this.props.availableAcls}
|
||||||
|
@ -9,8 +9,11 @@ import { getLangText } from '../../utils/lang_utils';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
|
|
||||||
let AclInformationButton = React.createClass({
|
let AclInformationButton = React.createClass({
|
||||||
getDefaultProps() {
|
getInitialState() {
|
||||||
let rows = [];
|
return {isVisible: false};
|
||||||
|
},
|
||||||
|
componentDidMount() {
|
||||||
|
//let rows = [];
|
||||||
let titleStyle = {
|
let titleStyle = {
|
||||||
color: '#02B6A3',
|
color: '#02B6A3',
|
||||||
fontSize: '11px',
|
fontSize: '11px',
|
||||||
@ -35,7 +38,7 @@ let AclInformationButton = React.createClass({
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let enabledIndices = this.props.verbs;
|
||||||
let titleList = ['TRANSFER', 'CONSIGN', 'LOAN', 'SHARE', 'DELETE'];
|
let titleList = ['TRANSFER', 'CONSIGN', 'LOAN', 'SHARE', 'DELETE'];
|
||||||
|
|
||||||
let infoSentenceList = [
|
let infoSentenceList = [
|
||||||
@ -63,7 +66,6 @@ let AclInformationButton = React.createClass({
|
|||||||
|
|
||||||
'(e.g. an artist uploaded the wrong file and doesn\'t want it cluttering his Wallet, so he Deletes it)'];
|
'(e.g. an artist uploaded the wrong file and doesn\'t want it cluttering his Wallet, so he Deletes it)'];
|
||||||
|
|
||||||
console.log('Now will initialize the rows prop inside default props');
|
|
||||||
|
|
||||||
let createJSXTextSnippet = function(title, info, example){
|
let createJSXTextSnippet = function(title, info, example){
|
||||||
return (<p style={paragraphStyle}> <span style={titleStyle}> {title} </span>
|
return (<p style={paragraphStyle}> <span style={titleStyle}> {title} </span>
|
||||||
@ -71,30 +73,33 @@ let AclInformationButton = React.createClass({
|
|||||||
<span style={exampleStyle}> {example} </span> </p>);
|
<span style={exampleStyle}> {example} </span> </p>);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.rows = enabledIndices.map((i)=>{
|
||||||
|
return (createJSXTextSnippet(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
|
||||||
|
getLangText(exampleSentenceList[i]),
|
||||||
|
titleStyle, infoStyle, exampleStyle));
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
for (let i = 0; i < titleList.length; i++){
|
for (let i = 0; i < titleList.length; i++){
|
||||||
rows.push(createJSXTextSnippet(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
|
rows.push(createJSXTextSnippet(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
|
||||||
getLangText(exampleSentenceList[i]),
|
getLangText(exampleSentenceList[i]),
|
||||||
titleStyle, infoStyle, exampleStyle));
|
titleStyle, infoStyle, exampleStyle));
|
||||||
}
|
}
|
||||||
return {
|
*/
|
||||||
rows: rows,
|
|
||||||
dropdownButtonStyle: {
|
this.dropdownButtonStyle = {
|
||||||
background: 'none',
|
background: 'none',
|
||||||
color: 'black',
|
color: 'black',
|
||||||
padding: 0,
|
padding: 0,
|
||||||
border: 'none'
|
border: 'none'
|
||||||
},
|
};
|
||||||
dropdownListStyle: {
|
this.dropdownListStyle = {
|
||||||
textAlign: 'justify',
|
textAlign: 'justify',
|
||||||
width: '80.8%',
|
width: '80.8%',
|
||||||
border: '1px solid #CCC',
|
border: '1px solid #CCC',
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
padding: '0.5em'
|
padding: '0.5em'
|
||||||
}
|
};
|
||||||
};
|
|
||||||
},
|
|
||||||
getInitialState() {
|
|
||||||
return {isVisible: false};
|
|
||||||
},
|
},
|
||||||
onOff() {
|
onOff() {
|
||||||
if (!this.state.isVisible) {
|
if (!this.state.isVisible) {
|
||||||
@ -106,17 +111,15 @@ let AclInformationButton = React.createClass({
|
|||||||
},
|
},
|
||||||
showInformation() {
|
showInformation() {
|
||||||
if (this.state.isVisible) {
|
if (this.state.isVisible) {
|
||||||
return this.props.rows;
|
return this.rows;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<Button
|
<Button style = {this.dropdownButtonStyle} className="glyphicon glyphicon-question-sign" onClick={this.onOff} />
|
||||||
style={this.props.dropdownButtonStyle}
|
|
||||||
className="glyphicon glyphicon-question-sign" onClick={this.onOff} />
|
|
||||||
<div
|
<div
|
||||||
style={this.props.dropdownListStyle}
|
style={this.dropdownListStyle}
|
||||||
className={classnames({'hidden': !this.state.isVisible})}>
|
className={classnames({'hidden': !this.state.isVisible})}>
|
||||||
{this.showInformation()}
|
{this.showInformation()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -244,7 +244,20 @@ let EditionSummary = React.createClass({
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
|
getVerbList(){
|
||||||
|
let verbsToCheck = ['acl_transfer', 'acl_consign', 'acl_loan', 'acl_share', 'acl_delete'];
|
||||||
|
let verbListIndices = [];
|
||||||
|
let acl = this.props.edition.acl;
|
||||||
|
Object.keys(acl).forEach((key) => {
|
||||||
|
let index = verbsToCheck.indexOf(key);
|
||||||
|
if (acl[key] === true && index !== -1) {
|
||||||
|
verbListIndices.push(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log('Here are the verbs to open');
|
||||||
|
console.log(verbListIndices);
|
||||||
|
return verbListIndices;
|
||||||
|
},
|
||||||
getActions(){
|
getActions(){
|
||||||
let actions = null;
|
let actions = null;
|
||||||
if (this.props.edition &&
|
if (this.props.edition &&
|
||||||
@ -295,7 +308,7 @@ let EditionSummary = React.createClass({
|
|||||||
handleSuccess={this.props.handleDeleteSuccess}
|
handleSuccess={this.props.handleDeleteSuccess}
|
||||||
editions={[this.props.edition]}/>
|
editions={[this.props.edition]}/>
|
||||||
{unconsignRequestButton}
|
{unconsignRequestButton}
|
||||||
<AclInformationButton/>
|
<AclInformationButton verbs = {this.getVerbList()}/>
|
||||||
</AclButtonList>
|
</AclButtonList>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>);
|
</Row>);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user