1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
This commit is contained in:
Brett Sun 2016-01-15 17:18:17 +01:00
parent 4c4e5e0004
commit e84206149c

View File

@ -3,8 +3,11 @@
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import EditionActions from '../../../../../../actions/edition_actions';
import PieceActions from '../../../../../../actions/piece_actions'; import PieceActions from '../../../../../../actions/piece_actions';
import PieceStore from '../../../../../../stores/piece_store'; import PieceStore from '../../../../../../stores/piece_store';
import WhitelabelActions from '../../../../../../actions/whitelabel_actions'; import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
import WhitelabelStore from '../../../../../../stores/whitelabel_store'; import WhitelabelStore from '../../../../../../stores/whitelabel_store';
@ -75,26 +78,6 @@ let MarketSubmitButton = React.createClass({
return false; return false;
}, },
getAdditionalDataForm() {
const { piece } = this.state;
if (piece.id) {
return (
<MarketAdditionalDataForm
extraData={piece.extra_data}
otherData={piece.other_data}
pieceId={piece.id}
submitLabel={getLangText('Continue to consignment')} />
);
} else {
return (
<div className="fullpage-spinner">
<AscribeSpinner color='dark-blue' size='lg'/>
</div>
);
}
},
getAggregateEditionDetails() { getAggregateEditionDetails() {
const { editions } = this.props; const { editions } = this.props;
@ -115,9 +98,13 @@ let MarketSubmitButton = React.createClass({
return getAclFormDataId(false, this.props.editions); return getAclFormDataId(false, this.props.editions);
}, },
handleAdditionalDataSuccess(pieceId) { handleAdditionalDataSuccess() {
// Fetch newly updated piece to update the views // Fetch newly updated piece and edition to update the views
PieceActions.fetchPiece(pieceId); PieceActions.fetchPiece(this.state.piece.id);
if (this.props.editions.length === 1) {
EditionActions.fetchEdition(this.props.editions[0].bitcoin_id);
}
this.refs.consignModal.show(); this.refs.consignModal.show();
}, },
@ -137,7 +124,7 @@ let MarketSubmitButton = React.createClass({
render() { render() {
const { availableAcls, currentUser, className, editions, handleSuccess } = this.props; const { availableAcls, currentUser, className, editions, handleSuccess } = this.props;
const { whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state; const { piece, whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state;
const { solePieceId, canSubmit } = this.getAggregateEditionDetails(); const { solePieceId, canSubmit } = this.getAggregateEditionDetails();
const message = getAclFormMessage({ const message = getAclFormMessage({
aclName: 'acl_consign', aclName: 'acl_consign',
@ -174,9 +161,13 @@ let MarketSubmitButton = React.createClass({
aclName='acl_consign'> aclName='acl_consign'>
<ModalWrapper <ModalWrapper
trigger={triggerButton} trigger={triggerButton}
handleSuccess={() => this.handleAdditionalDataSuccess(solePieceId)} handleSuccess={() => this.handleAdditionalDataSuccess()}
title={getLangText('Add additional information')}> title={getLangText('Add additional information')}>
{this.getAdditionalDataForm()} <MarketAdditionalDataForm
extraData={piece.extra_data}
otherData={piece.other_data}
pieceId={piece.id}
submitLabel={getLangText('Continue to consignment')} />
</ModalWrapper> </ModalWrapper>
<ModalWrapper <ModalWrapper