2015-05-27 14:35:33 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
2015-06-01 18:59:47 +02:00
|
|
|
import ConsignForm from './ascribe_forms/form_consign';
|
|
|
|
import TransferForm from './ascribe_forms/form_transfer';
|
|
|
|
import LoanForm from './ascribe_forms/form_loan';
|
|
|
|
import ShareForm from './ascribe_forms/form_share_email';
|
|
|
|
import ModalWrapper from './ascribe_modal/modal_wrapper';
|
2015-05-27 14:35:33 +02:00
|
|
|
import AppConstants from '../constants/application_constants';
|
|
|
|
|
|
|
|
let AclButton = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
|
2015-05-27 15:49:12 +02:00
|
|
|
availableAcls: React.PropTypes.array.isRequired,
|
2015-06-01 18:59:47 +02:00
|
|
|
editions: React.PropTypes.array.isRequired,
|
2015-06-02 11:38:18 +02:00
|
|
|
currentUser: React.PropTypes.object,
|
|
|
|
handleSuccess: React.PropTypes.func.isRequired
|
2015-05-27 14:35:33 +02:00
|
|
|
},
|
|
|
|
|
2015-06-01 18:59:47 +02:00
|
|
|
actionProperties(){
|
|
|
|
if (this.props.action == 'consign'){
|
|
|
|
return {
|
|
|
|
title: "Consign artwork",
|
|
|
|
tooltip: "Have someone else sell the artwork",
|
|
|
|
form: <ConsignForm />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.props.action == 'transfer') {
|
|
|
|
return {
|
|
|
|
title: "Transfer artwork",
|
|
|
|
tooltip: "Transfer the ownership of the artwork",
|
|
|
|
form: <TransferForm />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.props.action == 'loan'){
|
|
|
|
return {
|
|
|
|
title: "Loan artwork",
|
|
|
|
tooltip: "Loan your artwork for a limited period of time",
|
|
|
|
form: <LoanForm />}
|
|
|
|
}
|
|
|
|
else if (this.props.action == 'share'){
|
|
|
|
return {
|
|
|
|
title: "Share artwork",
|
|
|
|
tooltip: "Share the artwork",
|
|
|
|
form: <ShareForm />}
|
|
|
|
}
|
|
|
|
},
|
2015-05-27 14:35:33 +02:00
|
|
|
render() {
|
|
|
|
let shouldDisplay = this.props.availableAcls.indexOf(this.props.action) > -1;
|
2015-06-01 18:59:47 +02:00
|
|
|
let aclProps = this.actionProperties();
|
2015-05-27 14:35:33 +02:00
|
|
|
return (
|
2015-06-01 18:59:47 +02:00
|
|
|
<ModalWrapper
|
|
|
|
button={
|
|
|
|
<div className={shouldDisplay ? 'btn btn-default btn-sm' : 'hidden'}>
|
|
|
|
{this.props.action.toUpperCase()}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
currentUser={ this.props.currentUser }
|
2015-06-02 11:38:18 +02:00
|
|
|
editions={ this.props.editions }
|
|
|
|
handleSuccess={ this.props.handleSuccess }
|
2015-06-01 18:59:47 +02:00
|
|
|
title={ aclProps.title }
|
|
|
|
tooltip={ aclProps.tooltip }>
|
|
|
|
{ aclProps.form }
|
|
|
|
</ModalWrapper>
|
2015-05-27 14:35:33 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default AclButton;
|