bulk transfer part 1

This commit is contained in:
ddejongh 2015-06-02 11:38:18 +02:00
parent cbecbf44ad
commit dc3d024f8d
7 changed files with 72 additions and 48 deletions

View File

@ -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({
</div>
}
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 }

View File

@ -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}`;

View File

@ -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 (
<form id="transfer_modal_content" role="form" onSubmit={this.submit}>
<input className="invisible" type="email" name="fake_transferee"/>

View File

@ -17,8 +17,10 @@ let ModalWrapper = React.createClass({
<ModalTrigger modal={
<ModalBody
title={this.props.title}
edition={this.props.edition}
currentUser={this.props.currentUser}>
editions={this.props.editions}
currentUser={this.props.currentUser}
handleSuccess={this.props.handleSuccess}
>
{this.props.children}
</ModalBody>
}>
@ -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
});
});
},

View File

@ -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({
<AclButton
availableAcls={availableAcls}
action="transfer"
currentUser={this.state.currentUser}
editions={editions}
currentUser={this.state.currentUser}/>
handleSuccess={this.handleSuccess}/>
<AclButton
availableAcls={availableAcls}
action="consign"
currentUser={this.state.currentUser}
editions={editions}
currentUser={this.state.currentUser}/>
handleSuccess={this.handleSuccess}/>
<AclButton
availableAcls={availableAcls}
action="loan"
currentUser={this.state.currentUser}
editions={editions}
currentUser={this.state.currentUser}/>
handleSuccess={this.handleSuccess}/>
<AclButton
availableAcls={availableAcls}
action="share"
currentUser={this.state.currentUser}
editions={editions}
currentUser={this.state.currentUser}/>
handleSuccess={this.handleSuccess}/>
</div>
</div>
</div>

View File

@ -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 (
<div className="ascribe-detail-header">
@ -58,19 +55,20 @@ let EditionDetails = React.createClass({
<EditionDetailProperty label="id" value={ this.props.edition.bitcoin_id } />
<EditionDetailProperty label="owner" value={ this.props.edition.owner } />
<br/>
<LoanModalButton edition={ this.props.edition } currentUser={ this.props.currentUser }/>
<ModalWrapper
button={<div className="btn btn-ascribe-inv">CONSIGN</div>}
currentUser={ this.props.currentUser }
edition={ this.props.edition }
title="Consign artwork"
tooltip="Have someone else sell the artwork">
<ConsignForm />
</ModalWrapper>
<UnConsignModalButton edition={ this.props.edition } currentUser={ this.props.currentUser }/>
<UnConsignRequestModalButton edition={ this.props.edition } currentUser={ this.props.currentUser }/>
<TransferModalButton edition={ this.props.edition } currentUser={ this.props.currentUser }/>
<ShareModalButton edition={ this.props.edition } currentUser={ this.props.currentUser }/>
<AclButton
availableAcls={["transfer"]}
action="transfer"
editions={[this.props.edition]}
currentUser={this.props.currentUser}
handleSuccess={this.handleSuccess}
/>
<AclButton
availableAcls={["consign"]}
action="consign"
editions={[this.props.edition]}
currentUser={this.props.currentUser}
handleSuccess={this.handleSuccess}
/>
<hr/>
</div>
);

View File

@ -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){