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

Merge pull request #156 from ascribe/AG-114-show-visual-add-for-cosign-wallet-uneditable-works

AG-114 Show visual aid for uneditable works in consign wallet
This commit is contained in:
Brett Sun 2016-02-10 13:40:26 +01:00
commit dcdae7b7b1
5 changed files with 125 additions and 44 deletions

View File

@ -94,19 +94,19 @@ let Edition = React.createClass({
<CollapsibleParagraph
title={getLangText('Provenance/Ownership History')}
show={edition.ownership_history && edition.ownership_history.length}>
show={!!(edition.ownership_history && edition.ownership_history.length)}>
<HistoryIterator history={edition.ownership_history} />
</CollapsibleParagraph>
<CollapsibleParagraph
title={getLangText('Consignment History')}
show={edition.consign_history && edition.consign_history.length > 0}>
show={!!(edition.consign_history && edition.consign_history.length)}>
<HistoryIterator history={edition.consign_history} />
</CollapsibleParagraph>
<CollapsibleParagraph
title={getLangText('Loan History')}
show={edition.loan_history && edition.loan_history.length > 0}>
show={!!(edition.loan_history && edition.loan_history.length)}>
<HistoryIterator history={edition.loan_history} />
</CollapsibleParagraph>
@ -128,14 +128,14 @@ let Edition = React.createClass({
defaultValue={edition.public_note ? edition.public_note : null}
placeholder={getLangText('Enter your comments ...')}
editable={!!edition.acl.acl_edit}
show={!!edition.public_note || !!edition.acl.acl_edit}
show={!!(edition.public_note && edition.acl.acl_edit)}
successMessage={getLangText('Public edition note saved')}
url={ApiUrls.note_public_edition}
currentUser={currentUser} />
</CollapsibleParagraph>
<CollapsibleParagraph
title={getLangText('Further Details')}
show={edition.acl.acl_edit || Object.keys(edition.extra_data).length || edition.other_data.length}>
show={!!(edition.acl.acl_edit || Object.keys(edition.extra_data).length || edition.other_data.length)}>
<FurtherDetailsType
editable={edition.acl.acl_edit}
pieceId={edition.parent}

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import classNames from 'classnames';
import Modal from 'react-bootstrap/lib/Modal';
@ -16,6 +17,7 @@ let ModalWrapper = React.createClass({
React.PropTypes.string
]).isRequired,
bodyClassNames: React.PropTypes.string,
handleCancel: React.PropTypes.func,
handleSuccess: React.PropTypes.func,
trigger: React.PropTypes.element
@ -70,7 +72,7 @@ let ModalWrapper = React.createClass({
},
render() {
const { trigger, title } = this.props;
const { bodyClassNames, trigger, title } = this.props;
// If the trigger component exists, we add the ModalWrapper's show() to its onClick method.
// The trigger component should, in most cases, be a button.
@ -88,13 +90,15 @@ let ModalWrapper = React.createClass({
return (
<span>
{clonedTrigger}
<Modal show={this.state.showModal} onHide={this.handleCancel}>
<Modal
onHide={this.handleCancel}
show={this.state.showModal}>
<Modal.Header closeButton>
<Modal.Title>
{title}
</Modal.Title>
</Modal.Header>
<div className="modal-body" >
<div className={classNames('modal-body', bodyClassNames)}>
{this.renderChildren()}
</div>
</Modal>

View File

@ -7,6 +7,8 @@ import EditionActions from '../../../../../../actions/edition_actions';
import MarketAdditionalDataForm from '../market_forms/market_additional_data_form';
import MarketErrorConsignUnavailable from '../market_error_consign_unavailable';
import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory';
import ConsignForm from '../../../../../ascribe_forms/form_consign';
@ -40,7 +42,7 @@ let MarketSubmitButton = React.createClass({
},
other_data: otherData } = edition;
return artistBio && displayInstructions && technologyDetails && workDescription && otherData.length;
return !!(artistBio && displayInstructions && technologyDetails && workDescription && otherData.length);
}
return false;
@ -54,11 +56,13 @@ let MarketSubmitButton = React.createClass({
return editions.reduce((details, curEdition) => {
return {
solePieceId: details.solePieceId === curEdition.parent ? details.solePieceId : null,
canEdit: details.canEdit && curEdition.acl.acl_edit,
canSubmit: details.canSubmit && this.canEditionBeSubmitted(curEdition)
};
}, {
solePieceId: editions.length > 0 ? editions[0].parent : null,
canSubmit: this.canEditionBeSubmitted(editions[0])
solePieceId: editions.length ? editions[0].parent : null,
canEdit: true,
canSubmit: true
});
},
@ -84,7 +88,7 @@ let MarketSubmitButton = React.createClass({
handleSuccess,
whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.props;
const { solePieceId, canSubmit } = this.getAggregateEditionDetails();
const { solePieceId, canEdit, canSubmit } = this.getAggregateEditionDetails();
const message = getAclFormMessage({
aclName: 'acl_consign',
entities: editions,
@ -117,44 +121,61 @@ let MarketSubmitButton = React.createClass({
);
if (solePieceId && !canSubmit) {
return (
<AclProxy
aclObject={availableAcls}
aclName='acl_consign'>
<ModalWrapper
trigger={triggerButton}
handleSuccess={this.handleAdditionalDataSuccess}
title={getLangText('Add additional information')}>
<MarketAdditionalDataForm
extraData={extraData}
otherData={otherData}
pieceId={solePieceId}
submitLabel={getLangText('Continue to consignment')} />
</ModalWrapper>
if (canEdit) {
return (
<AclProxy
aclObject={availableAcls}
aclName='acl_consign'>
<ModalWrapper
handleSuccess={this.handleAdditionalDataSuccess}
title={getLangText('Add additional information')}
trigger={triggerButton}>
<MarketAdditionalDataForm
extraData={extraData}
otherData={otherData}
pieceId={solePieceId}
submitLabel={getLangText('Continue to consignment')} />
</ModalWrapper>
<ModalWrapper
ref="consignModal"
handleCancel={this.refreshEdition}
handleSuccess={(...params) => {
if (typeof handleSuccess === 'function') {
handleSuccess(...params);
}
<ModalWrapper
ref="consignModal"
handleCancel={this.refreshEdition}
handleSuccess={(...params) => {
if (typeof handleSuccess === 'function') {
handleSuccess(...params);
}
this.refreshEdition();
}}
title={getLangText('Consign artwork')}>
{consignForm}
</ModalWrapper>
</AclProxy>
);
this.refreshEdition();
}}
title={getLangText('Consign artwork')}>
{consignForm}
</ModalWrapper>
</AclProxy>
);
} else {
return (
<AclProxy
aclObject={availableAcls}
aclName='acl_consign'>
<ModalWrapper
bodyClassNames='modal-body-text'
trigger={triggerButton}
title={getLangText("Oops, we can't let you consign %s", editions.length > 1 ? 'these Editions' : 'this Edition')}>
<MarketErrorConsignUnavailable
editions={editions}
whitelabelName={whitelabelName} />
</ModalWrapper>
</AclProxy>
)
}
} else {
return (
<AclProxy
show={availableAcls.acl_consign && canSubmit}>
<ModalWrapper
trigger={triggerButton}
handleSuccess={handleSuccess}
title={getLangText('Consign artwork to %s', whitelabelName)}>
title={getLangText('Consign artwork to %s', whitelabelName)}
trigger={triggerButton}>
{consignForm}
</ModalWrapper>
</AclProxy>

View File

@ -0,0 +1,52 @@
'use strict';
import React from 'react';
import { getLangText } from '../../../../../utils/lang_utils';
const MarketErrorConsignUnavailable = React.createClass({
propTypes: {
editions: React.PropTypes.array.isRequired,
whitelabelName: React.PropTypes.string.isRequired,
handleSuccess: React.PropTypes.func
},
contactOnIntercom() {
window.Intercom('showNewMessage', getLangText("Hi, I'm having problems consigning to %s", this.props.whitelabelName));
},
render() {
const { editions, handleSuccess, whitelabelName } = this.props;
const multipleEditions = editions.length > 1;
return (
<div>
<p>{getLangText("Well, it looks like you've caught us in a bit of a bind!")}</p>
<p>
{getLangText('As a prerequisite, %s requires you to provide additional details before they will ' +
"consider your consignment request. However, it looks like the %s that you're trying " +
"to consign can't be edited anymore. Most likely, another Edition of the same work was " +
'previously transferred by you or another person.',
whitelabelName,
multipleEditions ? 'Editions' : 'Edition')
}
</p>
<p>
{getLangText("Unfortunately, this means that we're unable to let you consign %s.",
multipleEditions ? 'these Editions' : 'this Edition')}
{getLangText('If this seems incorrect, or if you would still like to consign %s to %s, please ',
multipleEditions ? 'these Editions' : 'this Edition',
whitelabelName)}
<strong><a style={{ cursor: 'pointer' }} onClick={this.contactOnIntercom}>{getLangText('contact us')}</a></strong>.
</p>
<button className='btn btn-default btn-wide' onClick={handleSuccess}>
{getLangText('OK')}
</button>
</div>
);
}
});
export default MarketErrorConsignUnavailable;

View File

@ -1,5 +1,9 @@
.modal-body {
padding-top:0;
padding-top: 0;
&.modal-body-text {
padding-top: 10px;
}
}
.modal-header {