1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

consign/unconsign

This commit is contained in:
diminator 2015-07-14 17:42:15 +02:00
parent 00d6ca9536
commit 9fa9db8352
8 changed files with 229 additions and 313 deletions

View File

@ -51,7 +51,12 @@ let AclButton = React.createClass({
return {
title: getLangText('Unconsign artwork'),
tooltip: getLangText('Have the owner manage his sales again'),
form: <UnConsignForm currentUser={ this.props.currentUser } editions={ this.props.pieceOrEditions }/>,
form: (
<UnConsignForm
message={this.getUnConsignMessage()}
id={this.getFormDataId()}
url={apiUrls.ownership_unconsigns}/>
),
handleSuccess: this.showNotification
};
}else if (this.props.action === 'acl_transfer') {
@ -144,6 +149,20 @@ ${this.props.currentUser.username}
${getLangText('I consign')}:
${this.getTitlesString()} ${getLangText('to you')}.
${getLangText('Truly yours')},
${this.props.currentUser.username}
`
);
},
// plz move to consign form
getUnConsignMessage(){
return (
`${getLangText('Hi')},
${getLangText('I un-consign')}:
${this.getTitlesString()} ${getLangText('from you')}.
${getLangText('Truly yours')},
${this.props.currentUser.username}
`

View File

@ -0,0 +1,47 @@
'use strict';
import React from 'react';
import Button from 'react-bootstrap/lib/Button';
import ModalWrapper from '../ascribe_modal/modal_wrapper';
import UnConsignRequestForm from './../ascribe_forms/form_unconsign_request';
import { getLangText } from '../../utils/lang_utils.js';
import apiUrls from '../../constants/api_urls';
let UnConsignRequestButton = React.createClass({
propTypes: {
currentUser: React.PropTypes.object.isRequired,
edition: React.PropTypes.object.isRequired,
handleSuccess: React.PropTypes.func.isRequired
},
render: function () {
return (
<ModalWrapper
button={
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
REQUEST UNCONSIGN
</Button>
}
handleSuccess={this.props.handleSuccess}
title='Request to Un-Consign'
tooltip='Ask the consignee to return the ownership of the work back to you'>
<UnConsignRequestForm
url={apiUrls.ownership_unconsigns_request}
id={{'bitcoin_id': this.props.edition.bitcoin_id}}
message={`${getLangText('Hi')},
${getLangText('I request you to un-consign')} \" ${this.props.edition.title} \".
${getLangText('Truly yours')},
${this.props.currentUser.username}`}/>
</ModalWrapper>
);
}
});
export default UnConsignRequestButton;

View File

@ -28,6 +28,7 @@ import EditionFurtherDetails from './further_details';
import RequestActionForm from './../ascribe_forms/form_request_action';
import EditionActions from '../../actions/edition_actions';
import AclButtonList from './../ascribe_buttons/acl_button_list';
import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button';
//import ReactS3FineUploader from './../ascribe_uploader/react_s3_fine_uploader';
@ -81,12 +82,13 @@ let Edition = React.createClass({
<hr/>
</div>
<EditionSummary
handleSuccess={this.props.loadEdition}
currentUser={this.state.currentUser}
edition={this.props.edition} />
<CollapsibleParagraph
title={getLangText('Certificate of Authenticity')}
show={this.props.edition.acl.acl_coa}>
show={this.props.edition.acl.acl_coa === true}>
<CoaDetails
edition={this.props.edition}/>
</CollapsibleParagraph>
@ -152,19 +154,20 @@ let Edition = React.createClass({
let EditionSummary = React.createClass({
propTypes: {
edition: React.PropTypes.object
edition: React.PropTypes.object,
handleSuccess: React.PropTypes.func,
currentUser: React.PropTypes.object
},
getTransferWithdrawData(){
return {'bitcoin_id': this.props.edition.bitcoin_id};
},
handleSuccess(){
EditionActions.fetchOne(this.props.edition.id);
},
showNotification(response){
this.handleSuccess();
let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
this.props.handleSuccess();
if (response){
let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
}
},
getStatus(){
let status = null;
@ -186,6 +189,7 @@ let EditionSummary = React.createClass({
if (this.props.edition.request_action && this.props.edition.request_action.length > 0){
actions = (
<RequestActionForm
currentUser={this.props.currentUser}
editions={ [this.props.edition] }
handleSuccess={this.showNotification}/>);
}
@ -205,6 +209,15 @@ let EditionSummary = React.createClass({
</Form>
);
}
let unconsignRequestButton = null;
if (this.props.edition.acl.acl_request_unconsign) {
unconsignRequestButton = (
<UnConsignRequestButton
currentUser={this.props.currentUser}
edition={this.props.edition}
handleSuccess={this.props.handleSuccess} />
);
}
actions = (
<Row>
<Col md={12}>
@ -212,8 +225,9 @@ let EditionSummary = React.createClass({
className="text-center ascribe-button-list"
availableAcls={this.props.edition.acl}
editions={[this.props.edition]}
handleSuccess={this.handleSuccess}>
handleSuccess={this.props.handleSuccess}>
{withdrawButton}
{unconsignRequestButton}
</AclButtonList>
</Col>
</Row>);

View File

@ -1,151 +1,8 @@
//'use strict';
//
//import React from 'react';
//
//import ApiUrls from '../../constants/api_urls';
//import FormMixin from '../../mixins/form_mixin';
//import InputText from './input_text';
//import InputTextArea from './input_textarea';
//import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
//import { getLangText } from '../../utils/lang_utils.js'
//
//let ConsignForm = React.createClass({
// mixins: [FormMixin],
//
//
// url() {
// return ApiUrls.ownership_consigns;
// },
//
// getFormData() {
// return {
// 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.getTitlesString().join('');
// let username = this.props.currentUser.username;
// let message =
//`${getLangText('Hi')},
//
//${getLangText('I consign')} :
//${title}${getLangText('to you')}.
//
//${getLangText('Truly yours')},
//${username}`;
//
// return (
// <form id="consign_modal_content" role="form" onSubmit={this.submit}>
// <input className="invisible" type="email" name="fake_consignee"/>
// <input className="invisible" type="password" name="fake_password"/>
// <InputText
// ref="consignee"
// placeHolder={getLangText('Consignee email')}
// required="required"
// type="email"
// submitted={this.state.submitted}/>
// <InputTextArea
// ref="consign_message"
// defaultValue={message}
// required=""
// />
// <InputText
// ref="password"
// placeHolder={getLangText('Password')}
// required="required"
// type="password"
// submitted={this.state.submitted}/>
// <ButtonSubmitOrClose
// text={getLangText('CONSIGN')}
// onClose={this.props.onRequestHide}
// submitted={this.state.submitted} />
// </form>
// );
// }
//});
////'use strict';
////
////import React from 'react';
////
////import ApiUrls from '../../constants/api_urls';
////import FormMixin from '../../mixins/form_mixin';
////import InputText from './input_text';
////import InputTextArea from './input_textarea';
////import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
////import { getLangText } from '../../utils/lang_utils.js'
////
////let TransferForm = React.createClass({
//// mixins: [FormMixin],
////
//// url() {
//// return ApiUrls.ownership_transfers;
//// },
////
//// getFormData() {
//// return {
//// 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 title = this.getTitlesString().join('');
//// let username = this.props.currentUser.username;
//// let message =
////`${getLangText('Hi')},
////
////${getLangText('I transfer ownership of')} :
////${title}${getLangText('to you')}.
////
////${getLangText('Truly yours')},
////${username}`;
////
//// return (
//// <form id="transfer_modal_content" role="form" onSubmit={this.submit}>
//// <input className="invisible" type="email" name="fake_transferee"/>
//// <input className="invisible" type="password" name="fake_password"/>
//// <InputText
//// ref="transferee"
//// placeHolder={getLangText('Transferee email')}
//// required="required"
//// type="email"
//// submitted={this.state.submitted}/>
//// <InputTextArea
//// ref="transfer_message"
//// defaultValue={message}
//// required=""
//// />
//// <InputText
//// ref="password"
//// placeHolder={getLangText('Password')}
//// required="required"
//// type="password"
//// submitted={this.state.submitted}/>
//// <div>
//// Make sure that display instructions and technology details are correct.
//// They cannot be edited after the transfer.
//// </div>
//// <ButtonSubmitOrClose
//// text={getLangText('TRANSFER')}
//// onClose={this.props.onRequestHide}
//// submitted={this.state.submitted} />
//// </form>
//// );
//// }
////});
////
'use strict';
import React from 'react';
import Button from 'react-bootstrap/lib/Button';
import Alert from 'react-bootstrap/lib/Alert';
import Form from './form';
import Property from './property';
@ -161,8 +18,6 @@ let ConsignForm = React.createClass({
url: React.PropTypes.string,
id: React.PropTypes.object,
message: React.PropTypes.string,
editions: React.PropTypes.array,
currentUser: React.PropTypes.object,
onRequestHide: React.PropTypes.func,
handleSuccess: React.PropTypes.func
},

View File

@ -7,6 +7,8 @@ import Alert from 'react-bootstrap/lib/Alert';
import apiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin';
import AclButton from './../ascribe_buttons/acl_button';
import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils.js';
@ -52,15 +54,31 @@ let RequestActionForm = React.createClass({
renderForm() {
let edition = this.props.editions[0];
let buttonAccept = (
<div id="request_accept"
onClick={this.handleRequest}
className='btn btn-default btn-sm ascribe-margin-1px'>{getLangText('ACCEPT')}
</div>);
if (edition.request_action === 'unconsign'){
console.log(this.props)
buttonAccept = (
<AclButton
availableAcls={{'acl_unconsign': true}}
action="acl_unconsign"
pieceOrEditions={this.props.editions}
currentUser={this.props.currentUser}
handleSuccess={this.props.handleSuccess} />
);
}
let buttons = (
<span>
<span>
<span>
<div id="request_accept" onClick={this.handleRequest} className='btn btn-default btn-sm ascribe-margin-1px'>{getLangText('ACCEPT')}</div>
</span>
<span>
<div id="request_deny" onClick={this.handleRequest} className='btn btn-danger btn-delete btn-sm ascribe-margin-1px'>{getLangText('REJECT')}</div>
</span>
{buttonAccept}
</span>
<span>
<div id="request_deny" onClick={this.handleRequest} className='btn btn-danger btn-delete btn-sm ascribe-margin-1px'>{getLangText('REJECT')}</div>
</span>
</span>
);
if (this.state.submitted){
buttons = (

View File

@ -1,76 +1,3 @@
//'use strict';
//
//import React from 'react';
//
//import ApiUrls from '../../constants/api_urls';
//import FormMixin from '../../mixins/form_mixin';
//import InputText from './input_text';
//import InputTextArea from './input_textarea';
//import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
//import { getLangText } from '../../utils/lang_utils.js'
//
//let TransferForm = React.createClass({
// mixins: [FormMixin],
//
// url() {
// return ApiUrls.ownership_transfers;
// },
//
// getFormData() {
// return {
// 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 title = this.getTitlesString().join('');
// let username = this.props.currentUser.username;
// let message =
//`${getLangText('Hi')},
//
//${getLangText('I transfer ownership of')} :
//${title}${getLangText('to you')}.
//
//${getLangText('Truly yours')},
//${username}`;
//
// return (
// <form id="transfer_modal_content" role="form" onSubmit={this.submit}>
// <input className="invisible" type="email" name="fake_transferee"/>
// <input className="invisible" type="password" name="fake_password"/>
// <InputText
// ref="transferee"
// placeHolder={getLangText('Transferee email')}
// required="required"
// type="email"
// submitted={this.state.submitted}/>
// <InputTextArea
// ref="transfer_message"
// defaultValue={message}
// required=""
// />
// <InputText
// ref="password"
// placeHolder={getLangText('Password')}
// required="required"
// type="password"
// submitted={this.state.submitted}/>
// <div>
// Make sure that display instructions and technology details are correct.
// They cannot be edited after the transfer.
// </div>
// <ButtonSubmitOrClose
// text={getLangText('TRANSFER')}
// onClose={this.props.onRequestHide}
// submitted={this.state.submitted} />
// </form>
// );
// }
//});
//
'use strict';
import React from 'react';

View File

@ -2,59 +2,75 @@
import React from 'react';
import ApiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin';
import InputText from './input_text';
import InputTextArea from './input_textarea';
import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
import { getLangText } from '../../utils/lang_utils.js'
import Button from 'react-bootstrap/lib/Button';
import Form from './form';
import Property from './property';
import InputTextAreaToggable from './input_textarea_toggable';
import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils.js';
let UnConsignForm = React.createClass({
mixins: [FormMixin],
url() {
return ApiUrls.ownership_unconsigns;
propTypes: {
url: React.PropTypes.string,
id: React.PropTypes.object,
message: React.PropTypes.string,
editions: React.PropTypes.array,
onRequestHide: React.PropTypes.func,
handleSuccess: React.PropTypes.func
},
getFormData() {
return {
bitcoin_id: this.getBitcoinIds().join(),
unconsign_message: this.refs.unconsign_message.state.value,
password: this.refs.password.state.value
};
getFormData(){
return this.props.id;
},
renderForm() {
let title = this.getTitlesString().join('');
let username = this.props.currentUser.username;
let message =
`${getLangText('Hi')},
${getLangText('I un-consign')}:
${title}${getLangText('from you')}.
${getLangText('Truly yours')},
${username}`;
render() {
return (
<form id="unconsign_modal_content" role="form" onSubmit={this.submit}>
<input className="invisible" type="email" name="fake_unconsignee"/>
<input className="invisible" type="password" name="fake_password"/>
<InputTextArea
ref="unconsign_message"
defaultValue={message}
required="" />
<InputText
ref="password"
placeHolder={getLangText('Password')}
required="required"
type="password"
submitted={this.state.submitted} />
<ButtonSubmitOrClose
text={getLangText('UNCONSIGN')}
onClose={this.props.onRequestHide}
submitted={this.state.submitted} />
</form>
<Form
ref='form'
url={this.props.url}
getFormData={this.getFormData}
handleSuccess={this.props.handleSuccess}
buttons={
<div className="modal-footer">
<p className="pull-right">
<Button
className="btn btn-default btn-sm ascribe-margin-1px"
type="submit">{getLangText('UNCONSIGN')}</Button>
<Button
className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
style={{marginLeft: '0'}}
onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</Button>
</p>
</div>}
spinner={
<div className="modal-footer">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_small.gif'} />
</div>}>
<Property
name='unconsign_message'
label={getLangText('Personal Message')}
editable={true}>
<InputTextAreaToggable
rows={1}
editable={true}
defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')}
required="required"/>
</Property>
<Property
name='password'
label={getLangText('Password')}>
<input
type="password"
placeholder={getLangText('Enter your password')}
required/>
</Property>
<hr />
</Form>
);
}
});

View File

@ -2,48 +2,68 @@
import React from 'react';
import ApiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin';
import InputTextArea from './input_textarea';
import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
import { getLangText } from '../../utils/lang_utils.js'
import Button from 'react-bootstrap/lib/Button';
import Alert from 'react-bootstrap/lib/Alert';
import Form from './form';
import Property from './property';
import InputTextAreaToggable from './input_textarea_toggable';
import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils.js';
let UnConsignRequestForm = React.createClass({
mixins: [FormMixin],
url() {
return ApiUrls.ownership_unconsigns_request;
propTypes: {
url: React.PropTypes.string,
id: React.PropTypes.object,
message: React.PropTypes.string,
onRequestHide: React.PropTypes.func,
handleSuccess: React.PropTypes.func
},
getFormData() {
return {
bitcoin_id: this.props.edition.bitcoin_id,
unconsign_request_message: this.refs.unconsign_request_message.state.value
};
getFormData(){
return this.props.id;
},
renderForm() {
let title = this.props.edition.title;
let username = this.props.currentUser.username;
let message =
`${getLangText('Hi')},
${getLangText('I request you to un-consign')} \" ${title} \".
${getLangText('Truly yours')},
${username}`;
render() {
return (
<form id="unconsign_request_modal_content" role="form" onSubmit={this.submit}>
<InputTextArea
ref="unconsign_request_message"
defaultValue={message}
required="" />
<ButtonSubmitOrClose
text={getLangText('UNCONSIGN REQUEST')}
onClose={this.props.onRequestHide}
submitted={this.state.submitted} />
</form>
<Form
ref='form'
url={this.props.url}
getFormData={this.getFormData}
handleSuccess={this.props.handleSuccess}
buttons={
<div className="modal-footer">
<p className="pull-right">
<Button
className="btn btn-default btn-sm ascribe-margin-1px"
type="submit">{getLangText('REQUEST UNCONSIGN')}</Button>
<Button
className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
style={{marginLeft: '0'}}
onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</Button>
</p>
</div>}
spinner={
<div className="modal-footer">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_small.gif'} />
</div>}>
<Property
name='unconsign_request_message'
label={getLangText('Personal Message')}
editable={true}>
<InputTextAreaToggable
rows={1}
editable={true}
defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')}
required="required"/>
</Property>
<hr />
</Form>
);
}
});