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

Merge branch 'AD-419-decouple-piece-registration-from-' of bitbucket.org:ascribe/onion into AD-419-decouple-piece-registration-from-

This commit is contained in:
Tim Daubenschütz 2015-07-14 12:19:41 +02:00
commit 9b663c64b2
6 changed files with 205 additions and 74 deletions

View File

@ -50,10 +50,21 @@ let AclButton = React.createClass({
handleSuccess: this.showNotification handleSuccess: this.showNotification
}; };
}else if (this.props.action === 'acl_transfer') { }else if (this.props.action === 'acl_transfer') {
//return {
// title: getLangText('Transfer artwork'),
// tooltip: getLangText('Transfer the ownership of the artwork'),
// form: <TransferForm currentUser={ this.props.currentUser } editions={ this.props.pieceOrEditions }/>,
// handleSuccess: this.showNotification
//};
return { return {
title: getLangText('Transfer artwork'), title: getLangText('Transfer artwork'),
tooltip: getLangText('Transfer the ownership of the artwork'), tooltip: getLangText('Transfer the ownership of the artwork'),
form: <TransferForm currentUser={ this.props.currentUser } editions={ this.props.pieceOrEditions }/>, form: (
<TransferForm
message={this.getTransferMessage()}
id={this.getFormDataId()}
url={apiUrls.ownership_transfers}/>
),
handleSuccess: this.showNotification handleSuccess: this.showNotification
}; };
} }
@ -112,11 +123,24 @@ let AclButton = React.createClass({
} }
}, },
// plz move to share form
getTransferMessage(){
return (
`${getLangText('Hi')},
${getLangText('I transfer ownership of')}:
${this.getTitlesString()} ${getLangText('to you')}.
${getLangText('Truly yours')},
${this.props.currentUser.username}
`
);
},
// plz move to share form // plz move to share form
getShareMessage(){ getShareMessage(){
return ( return (
` `${getLangText('Hi')},
${getLangText('Hi')},
${getLangText('I am sharing')}: ${getLangText('I am sharing')}:
${this.getTitlesString()} ${getLangText('with you')}. ${this.getTitlesString()} ${getLangText('with you')}.

View File

@ -6,6 +6,7 @@ import Router from 'react-router';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import Button from 'react-bootstrap/lib/Button';
import UserActions from '../../actions/user_actions'; import UserActions from '../../actions/user_actions';
import UserStore from '../../stores/user_store'; import UserStore from '../../stores/user_store';
@ -172,18 +173,9 @@ let EditionSummary = React.createClass({
status = <EditionDetailProperty label="STATUS" value={ statusStr }/>; status = <EditionDetailProperty label="STATUS" value={ statusStr }/>;
if (this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer){ if (this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer){
status = ( status = (
<Form
url={apiUrls.ownership_transfers_withdraw} <EditionDetailProperty label="STATUS" value={ statusStr } />
getFormData={this.getTransferWithdrawData}
handleSuccess={this.showNotification}>
<EditionDetailProperty label="STATUS" value={ statusStr }>
<button
type="submit"
className="pull-right btn btn-default btn-sm">
WITHDRAW
</button>
</EditionDetailProperty>
</Form>
); );
} }
} }
@ -197,7 +189,22 @@ let EditionSummary = React.createClass({
editions={ [this.props.edition] } editions={ [this.props.edition] }
handleSuccess={this.showNotification}/>); handleSuccess={this.showNotification}/>);
} }
else { else {
let withdrawButton = null;
if (this.props.edition.status.length > 0 && this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer) {
withdrawButton = (
<Form
url={apiUrls.ownership_transfers_withdraw}
getFormData={this.getTransferWithdrawData}
handleSuccess={this.showNotification}
className='inline'>
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
WITHDRAW TRANSFER
</Button>
</Form>
);
}
actions = ( actions = (
<Row> <Row>
<Col md={12}> <Col md={12}>
@ -205,7 +212,9 @@ let EditionSummary = React.createClass({
className="text-center ascribe-button-list" className="text-center ascribe-button-list"
availableAcls={this.props.edition.acl} availableAcls={this.props.edition.acl}
editions={[this.props.edition]} editions={[this.props.edition]}
handleSuccess={this.handleSuccess} /> handleSuccess={this.handleSuccess}>
{withdrawButton}
</AclButtonList>
</Col> </Col>
</Row>); </Row>);
} }

View File

@ -8,7 +8,7 @@ import apiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin'; import FormMixin from '../../mixins/form_mixin';
import AppConstants from '../../constants/application_constants'; import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils.js' import { getLangText } from '../../utils/lang_utils.js';
let RequestActionForm = React.createClass({ let RequestActionForm = React.createClass({
mixins: [FormMixin], mixins: [FormMixin],

View File

@ -1,72 +1,165 @@
//'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'; 'use strict';
import React from 'react'; import React from 'react';
import ApiUrls from '../../constants/api_urls'; import Button from 'react-bootstrap/lib/Button';
import FormMixin from '../../mixins/form_mixin'; import Alert from 'react-bootstrap/lib/Alert';
import InputText from './input_text';
import InputTextArea from './input_textarea'; import Form from './form';
import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close'; import Property from './property';
import { getLangText } from '../../utils/lang_utils.js' import InputTextAreaToggable from './input_textarea_toggable';
import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils.js';
let TransferForm = React.createClass({ let TransferForm = React.createClass({
mixins: [FormMixin], propTypes: {
url: React.PropTypes.string,
url() { id: React.PropTypes.object,
return ApiUrls.ownership_transfers; message: React.PropTypes.string,
}, editions: React.PropTypes.array,
currentUser: React.PropTypes.object,
getFormData() { onRequestHide: React.PropTypes.func,
return { handleSuccess: React.PropTypes.func
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() { getFormData(){
let title = this.getTitlesString().join(''); return this.props.id;
let username = this.props.currentUser.username; },
let message =
`${getLangText('Hi')},
${getLangText('I transfer ownership of')} : render() {
${title}${getLangText('to you')}.
${getLangText('Truly yours')},
${username}`;
return ( return (
<form id="transfer_modal_content" role="form" onSubmit={this.submit}> <Form
<input className="invisible" type="email" name="fake_transferee"/> ref='form'
<input className="invisible" type="password" name="fake_password"/> url={this.props.url}
<InputText getFormData={this.getFormData}
ref="transferee" handleSuccess={this.props.handleSuccess}
placeHolder={getLangText('Transferee email')} buttons={
required="required" <div className="modal-footer">
type="email" <p className="pull-right">
submitted={this.state.submitted}/> <Button
<InputTextArea className="btn btn-default btn-sm ascribe-margin-1px"
ref="transfer_message" type="submit">TRANSFER</Button>
defaultValue={message} <Button
required="" className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
/> style={{marginLeft: '0'}}
<InputText onClick={this.props.onRequestHide}>CLOSE</Button>
ref="password" </p>
placeHolder={getLangText('Password')} </div>}
required="required" spinner={
type="password" <div className="modal-footer">
submitted={this.state.submitted}/> <img src={AppConstants.baseUrl + 'static/img/ascribe_animated_small.gif'} />
<div> </div>}>
Make sure that display instructions and technology details are correct. <Property
name='transferee'
label={getLangText('Email')}>
<input
type="email"
placeholder={getLangText('Email of the transferee')}
required/>
</Property>
<Property
name='transfer_message'
label='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 />
<br />
<Alert bsStyle='warning'>
Make sure that display instructions and technology details are correct.<br/>
They cannot be edited after the transfer. They cannot be edited after the transfer.
</div> </Alert>
<ButtonSubmitOrClose </Form>
text={getLangText('TRANSFER')}
onClose={this.props.onRequestHide}
submitted={this.state.submitted} />
</form>
); );
} }
}); });

View File

@ -32,6 +32,7 @@ let InputTextAreaToggable = React.createClass({
className={className} className={className}
value={this.state.value} value={this.state.value}
rows={this.props.rows} rows={this.props.rows}
maxRows={10}
required={this.props.required} required={this.props.required}
onChange={this.handleChange} onChange={this.handleChange}
onBlur={this.props.onBlur} onBlur={this.props.onBlur}

View File

@ -58,6 +58,10 @@ hr {
.no-padding{ .no-padding{
padding: 0; padding: 0;
} }
.inline{
display: inline;
}
.navbar-default { .navbar-default {
border: none; border: none;
border-left:0; border-left:0;