mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
request form on piece level
bug fix cyland piece endpoint bug fix otherDataUploader editable
This commit is contained in:
parent
7a09b863b5
commit
3b27238adf
@ -242,7 +242,9 @@ let EditionSummary = React.createClass({
|
||||
actions = (
|
||||
<RequestActionForm
|
||||
currentUser={this.props.currentUser}
|
||||
editions={ [this.props.edition] }
|
||||
pieceOrEditions={ [this.props.edition] }
|
||||
requestAction={this.props.edition.request_action}
|
||||
requestUser={this.props.edition.owner}
|
||||
handleSuccess={this.showNotification}/>);
|
||||
}
|
||||
|
||||
|
@ -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}/>
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
<RequestActionForm
|
||||
currentUser={this.state.currentUser}
|
||||
editions={ [this.state.piece] }
|
||||
pieceOrEditions={ this.state.piece }
|
||||
requestAction={this.state.piece.request_action}
|
||||
requestUser={this.state.piece.user_registered}
|
||||
handleSuccess={this.showNotification}/>);
|
||||
}
|
||||
else {
|
||||
|
@ -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 (
|
||||
<span>
|
||||
@ -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 (
|
||||
<AclButton
|
||||
availableAcls={{'acl_unconsign': true}}
|
||||
action="acl_unconsign"
|
||||
pieceOrEditions={this.props.editions}
|
||||
pieceOrEditions={this.props.pieceOrEditions}
|
||||
currentUser={this.props.currentUser}
|
||||
handleSuccess={this.props.handleSuccess} />
|
||||
);
|
||||
@ -93,7 +99,9 @@ let RequestActionForm = React.createClass({
|
||||
<Form
|
||||
url={urls.accept}
|
||||
getFormData={this.getFormData}
|
||||
handleSuccess={this.showNotification(getLangText('accepted'), edition.request_action, edition.owner)}
|
||||
handleSuccess={
|
||||
this.showNotification(getLangText('accepted'), this.props.requestAction, this.props.requestUser)
|
||||
}
|
||||
isInline={true}
|
||||
className='inline pull-right'>
|
||||
<button
|
||||
@ -107,8 +115,6 @@ let RequestActionForm = React.createClass({
|
||||
},
|
||||
|
||||
getButtonForm() {
|
||||
let edition = this.props.editions[0];
|
||||
|
||||
let urls = this.getUrls();
|
||||
let acceptButtonForm = this.getAcceptButtonForm(urls);
|
||||
|
||||
@ -118,7 +124,9 @@ let RequestActionForm = React.createClass({
|
||||
url={urls.deny}
|
||||
isInline={true}
|
||||
getFormData={this.getFormData}
|
||||
handleSuccess={this.showNotification(getLangText('denied'), edition.request_action, edition.owner)}
|
||||
handleSuccess={
|
||||
this.showNotification(getLangText('denied'), this.props.requestAction, this.props.requestUser)
|
||||
}
|
||||
className='inline pull-right'>
|
||||
<button
|
||||
type="submit"
|
||||
|
@ -30,6 +30,8 @@ let ApiUrls = {
|
||||
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
|
||||
'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/',
|
||||
'ownership_loans_pieces': AppConstants.apiEndpoint + 'ownership/loans/pieces/',
|
||||
'ownership_loans_pieces_confirm': AppConstants.apiEndpoint + 'ownership/loans/pieces/confirm/',
|
||||
'ownership_loans_pieces_deny': AppConstants.apiEndpoint + 'ownership/loans/pieces/deny/',
|
||||
'ownership_loans_editions': AppConstants.apiEndpoint + 'ownership/loans/editions/',
|
||||
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/editions/confirm/',
|
||||
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/editions/deny/',
|
||||
|
Loading…
Reference in New Issue
Block a user