From dc3d024f8d614d23418fb8294ae6d048d79a962d Mon Sep 17 00:00:00 2001 From: ddejongh Date: Tue, 2 Jun 2015 11:38:18 +0200 Subject: [PATCH] bulk transfer part 1 --- js/components/acl_button.js | 10 ++--- js/components/ascribe_forms/form_consign.js | 8 ++-- js/components/ascribe_forms/form_transfer.js | 19 +++++---- js/components/ascribe_modal/modal_wrapper.js | 15 +++++-- .../piece_list_toolbar.js | 14 +++++-- js/components/edition.js | 40 +++++++++---------- js/mixins/form_mixin.js | 14 +++++-- 7 files changed, 72 insertions(+), 48 deletions(-) diff --git a/js/components/acl_button.js b/js/components/acl_button.js index 65af1e18..5f2a0708 100644 --- a/js/components/acl_button.js +++ b/js/components/acl_button.js @@ -12,11 +12,8 @@ let AclButton = React.createClass({ action: React.PropTypes.oneOf(AppConstants.aclList).isRequired, availableAcls: React.PropTypes.array.isRequired, editions: React.PropTypes.array.isRequired, - currentUser: React.PropTypes.object - }, - - actionFunction() { - this.props.actionFunction(this.props.action); + currentUser: React.PropTypes.object, + handleSuccess: React.PropTypes.func.isRequired }, actionProperties(){ @@ -58,7 +55,8 @@ let AclButton = React.createClass({ } currentUser={ this.props.currentUser } - edition={ this.props.editions[0] } + editions={ this.props.editions } + handleSuccess={ this.props.handleSuccess } title={ aclProps.title } tooltip={ aclProps.tooltip }> { aclProps.form } diff --git a/js/components/ascribe_forms/form_consign.js b/js/components/ascribe_forms/form_consign.js index 708ab70e..dbb1eee0 100644 --- a/js/components/ascribe_forms/form_consign.js +++ b/js/components/ascribe_forms/form_consign.js @@ -16,19 +16,21 @@ let ConsignForm = React.createClass({ }, getFormData() { return { - bitcoin_id: this.props.edition.bitcoin_id, + bitcoin_id: this.getBitcoinIds().join(), consignee: this.refs.consignee.state.value, consign_message: this.refs.consign_message.state.value, password: this.refs.password.state.value } }, + renderForm() { - let title = this.props.edition.title; + let title = this.getTitlesString().join(""); let username = this.props.currentUser.username; let message = `Hi, -I consign \" ${title} \" to you. +I consign : +${title}to you. Truly yours, ${username}`; diff --git a/js/components/ascribe_forms/form_transfer.js b/js/components/ascribe_forms/form_transfer.js index 28e86db3..c724edd0 100644 --- a/js/components/ascribe_forms/form_transfer.js +++ b/js/components/ascribe_forms/form_transfer.js @@ -18,19 +18,24 @@ let TransferForm = React.createClass({ }, getFormData() { return { - bitcoin_id: this.props.edition.bitcoin_id, + bitcoin_id: this.getBitcoinIds().join(), transferee: this.refs.transferee.state.value, transfer_message: this.refs.transfer_message.state.value, password: this.refs.password.state.value } }, renderForm() { - let message = "Hi,\n" + - "\n" + - "I transfer ownership of \"" + this.props.edition.title + "\" to you.\n" + - "\n" + - "Truly yours,\n" + - this.props.currentUser.username; + let title = this.getTitlesString().join(""); + let username = this.props.currentUser.username; + let message = +`Hi, + +I transfer ownership of : +${title}to you. + +Truly yours, +${username}`; + return (
diff --git a/js/components/ascribe_modal/modal_wrapper.js b/js/components/ascribe_modal/modal_wrapper.js index 83a60c64..a5d20389 100644 --- a/js/components/ascribe_modal/modal_wrapper.js +++ b/js/components/ascribe_modal/modal_wrapper.js @@ -17,8 +17,10 @@ let ModalWrapper = React.createClass({ + editions={this.props.editions} + currentUser={this.props.currentUser} + handleSuccess={this.props.handleSuccess} + > {this.props.children} }> @@ -33,12 +35,17 @@ let ModalWrapper = React.createClass({ let ModalBody = React.createClass({ mixins : [ModalMixin], + handleSuccess(){ + this.props.handleSuccess(); + this.props.onRequestHide(); + }, renderChildren() { return ReactAddons.Children.map(this.props.children, (child, i) => { return ReactAddons.addons.cloneWithProps(child, { - edition: this.props.edition, + editions: this.props.editions, currentUser: this.props.currentUser, - onRequestHide: this.onRequestHide + onRequestHide: this.onRequestHide, + handleSuccess: this.handleSuccess }); }); }, diff --git a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js index 30a30ecb..dc6fad19 100644 --- a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js +++ b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js @@ -80,7 +80,9 @@ let PieceListToolbar = React.createClass({ clearAllSelections() { EditionListActions.clearAllEditionSelections(); }, + handleSuccess(){ + }, render() { let availableAcls = this.getAvailableAcls(); let editions = this.fetchSelectedEditionList(); @@ -107,23 +109,27 @@ let PieceListToolbar = React.createClass({ + handleSuccess={this.handleSuccess}/> + handleSuccess={this.handleSuccess}/> + handleSuccess={this.handleSuccess}/> + handleSuccess={this.handleSuccess}/> diff --git a/js/components/edition.js b/js/components/edition.js index 92bf5c77..9d0352de 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -1,13 +1,8 @@ import React from 'react'; import ResourceViewer from './ascribe_media/resource_viewer'; -import LoanModalButton from './ascribe_modal/modal_loan'; -import ModalWrapper from './ascribe_modal/modal_wrapper'; -import ConsignForm from './ascribe_forms/form_consign.js'; -import UnConsignModalButton from './ascribe_modal/modal_unconsign'; -import UnConsignRequestModalButton from './ascribe_modal/modal_unconsign_request'; -import TransferModalButton from './ascribe_modal/modal_transfer'; -import ShareModalButton from './ascribe_modal/modal_share'; +import EditionActions from '../actions/edition_actions' +import AclButton from './acl_button' /** * This is the component that implements display-specific functionality @@ -49,7 +44,9 @@ let EditionHeader = React.createClass({ }); let EditionDetails = React.createClass({ - + handleSuccess(){ + EditionActions.fetchOne(this.props.edition.id); + }, render() { return (
@@ -58,19 +55,20 @@ let EditionDetails = React.createClass({
- - CONSIGN
} - currentUser={ this.props.currentUser } - edition={ this.props.edition } - title="Consign artwork" - tooltip="Have someone else sell the artwork"> - - - - - - + +
); diff --git a/js/mixins/form_mixin.js b/js/mixins/form_mixin.js index 65983653..aa58c8a8 100644 --- a/js/mixins/form_mixin.js +++ b/js/mixins/form_mixin.js @@ -1,6 +1,5 @@ import React from 'react'; -import EditionActions from '../actions/edition_actions' import AppConstants from '../constants/application_constants' import AlertDismissable from '../components/ascribe_forms/alert' @@ -34,8 +33,7 @@ export const FormMixin = { handleResponse(response){ let submitted = false; if (response.status >= 200 && response.status < 300){ - EditionActions.fetchOne(this.props.edition.id); - this.props.onRequestHide(); + this.props.handleSuccess(); submitted = true; } else if (response.status >= 400 && response.status < 500) { @@ -57,6 +55,16 @@ export const FormMixin = { } } }, + getBitcoinIds(){ + return this.props.editions.map(function(edition){ + return edition.bitcoin_id + }) + }, + getTitlesString(){ + return this.props.editions.map(function(edition){ + return '- \"' + edition.title + ', edition ' + edition.edition_number + '\"\n' + }) + }, render(){ let alert = null; if (this.state.status >= 500){