diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 2675d804..9d2af633 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -242,7 +242,9 @@ let EditionSummary = React.createClass({ actions = ( ); } diff --git a/js/components/ascribe_detail/further_details.js b/js/components/ascribe_detail/further_details.js index d206a3be..9fc5bf15 100644 --- a/js/components/ascribe_detail/further_details.js +++ b/js/components/ascribe_detail/further_details.js @@ -82,6 +82,7 @@ let FurtherDetails = React.createClass({ setIsUploadReady={this.setIsUploadReady} isReadyForFormSubmission={isReadyForFormSubmission} editable={this.props.editable} + overrideForm={true} pieceId={this.props.pieceId} otherData={this.props.otherData} multiple={true}/> diff --git a/js/components/ascribe_detail/further_details_fileuploader.js b/js/components/ascribe_detail/further_details_fileuploader.js index 2b04a210..a6eea898 100644 --- a/js/components/ascribe_detail/further_details_fileuploader.js +++ b/js/components/ascribe_detail/further_details_fileuploader.js @@ -30,6 +30,7 @@ let FurtherDetailsFileuploader = React.createClass({ }, render() { + console.log(this.props) // Essentially there a three cases important to the fileuploader // // 1. there is no other_data => do not show the fileuploader at all diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index dc8e5569..bb528a56 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -151,11 +151,15 @@ let PieceContainer = React.createClass({ }, getActions(){ - if (this.state.piece.request_action && this.state.piece.request_action.length > 0) { + if (this.state.piece && + this.state.piece.request_action && + this.state.piece.request_action.length > 0) { return ( ); } else { diff --git a/js/components/ascribe_forms/form_request_action.js b/js/components/ascribe_forms/form_request_action.js index cc4ad88a..3b98a637 100644 --- a/js/components/ascribe_forms/form_request_action.js +++ b/js/components/ascribe_forms/form_request_action.js @@ -16,40 +16,49 @@ import { getLangText } from '../../utils/lang_utils.js'; let RequestActionForm = React.createClass({ propTypes: { - editions: React.PropTypes.arrayOf(React.PropTypes.object), + pieceOrEditions: React.PropTypes.oneOfType([ + React.PropTypes.object, + React.PropTypes.array + ]).isRequired, + requestAction: React.PropTypes.string, + requestUser: React.PropTypes.string, currentUser: React.PropTypes.object, handleSuccess: React.PropTypes.func }, + isPiece(){ + return this.props.pieceOrEditions.constructor !== Array; + }, + getUrls() { - let edition = this.props.editions[0]; let urls = {}; - - if (edition.request_action === 'consign'){ + if (this.props.requestAction === 'consign'){ urls.accept = ApiUrls.ownership_consigns_confirm; urls.deny = ApiUrls.ownership_consigns_deny; - } else if (edition.request_action === 'unconsign'){ + } else if (this.props.requestAction === 'unconsign'){ urls.accept = ApiUrls.ownership_unconsigns; urls.deny = ApiUrls.ownership_unconsigns_deny; - } else if (edition.request_action === 'loan'){ + } else if (this.props.requestAction === 'loan' && !this.isPiece()){ urls.accept = ApiUrls.ownership_loans_confirm; urls.deny = ApiUrls.ownership_loans_deny; + } else if (this.props.requestAction === 'loan' && this.isPiece()){ + urls.accept = ApiUrls.ownership_loans_pieces_confirm; + urls.deny = ApiUrls.ownership_loans_pieces_deny; } return urls; }, - getBitcoinIds(){ - return this.props.editions.map(function(edition){ - return edition.bitcoin_id; - }); - }, - - getFormData() { - return { - bitcoin_id: this.getBitcoinIds().join() - }; + getFormData(){ + if (this.isPiece()) { + return {piece_id: this.props.pieceOrEditions.id}; + } + else { + return {bitcoin_id: this.props.pieceOrEditions.map(function(edition){ + return edition.bitcoin_id; + }).join()}; + } }, showNotification(option, action, owner) { @@ -66,8 +75,7 @@ let RequestActionForm = React.createClass({ }, getContent() { - let edition = this.props.editions[0]; - let message = edition.owner + ' ' + getLangText('requests you') + ' ' + edition.request_action + ' ' + getLangText('this edition%s', '.'); + let message = this.props.requestUser + ' ' + getLangText('requests you') + ' ' + this.props.requestAction + ' ' + getLangText('this edition%s', '.'); return ( @@ -77,14 +85,12 @@ let RequestActionForm = React.createClass({ }, getAcceptButtonForm(urls) { - let edition = this.props.editions[0]; - - if(edition.request_action === 'unconsign') { + if(this.props.requestAction === 'unconsign') { return ( ); @@ -93,7 +99,9 @@ let RequestActionForm = React.createClass({