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-

Conflicts:
	js/components/ascribe_table/table_item_acl_filtered.js
This commit is contained in:
Tim Daubenschütz 2015-07-14 14:46:30 +02:00
commit adf4630efd
6 changed files with 251 additions and 72 deletions

View File

@ -162,11 +162,9 @@ let AccordionListItemTableEditions = React.createClass({
new ColumnModel( new ColumnModel(
(item) => { (item) => {
let content = item.acl; let content = item.acl;
if (item.request_action) {
content = [item.request_action + ' request'];
}
return { return {
'content': content 'content': content,
'requestAction': item.request_action
}; }, }; },
'acl', 'acl',
getLangText('Actions'), getLangText('Actions'),

View File

@ -38,7 +38,12 @@ let AclButton = React.createClass({
return { return {
title: getLangText('Consign artwork'), title: getLangText('Consign artwork'),
tooltip: getLangText('Have someone else sell the artwork'), tooltip: getLangText('Have someone else sell the artwork'),
form: <ConsignForm currentUser={ this.props.currentUser } editions={ this.props.pieceOrEditions }/>, form: (
<ConsignForm
message={this.getConsignMessage()}
id={this.getFormDataId()}
url={apiUrls.ownership_consigns}/>
),
handleSuccess: this.showNotification handleSuccess: this.showNotification
}; };
} }
@ -50,12 +55,6 @@ 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'),
@ -123,7 +122,7 @@ let AclButton = React.createClass({
} }
}, },
// plz move to share form // plz move to transfer form
getTransferMessage(){ getTransferMessage(){
return ( return (
`${getLangText('Hi')}, `${getLangText('Hi')},
@ -131,6 +130,20 @@ let AclButton = React.createClass({
${getLangText('I transfer ownership of')}: ${getLangText('I transfer ownership of')}:
${this.getTitlesString()} ${getLangText('to you')}. ${this.getTitlesString()} ${getLangText('to you')}.
${getLangText('Truly yours')},
${this.props.currentUser.username}
`
);
},
// plz move to consign form
getConsignMessage(){
return (
`${getLangText('Hi')},
${getLangText('I consign')}:
${this.getTitlesString()} ${getLangText('to you')}.
${getLangText('Truly yours')}, ${getLangText('Truly yours')},
${this.props.currentUser.username} ${this.props.currentUser.username}
` `

View File

@ -1,69 +1,229 @@
//'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'; '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 ConsignForm = React.createClass({ let ConsignForm = React.createClass({
mixins: [FormMixin], propTypes: {
url: React.PropTypes.string,
id: React.PropTypes.object,
url() { message: React.PropTypes.string,
return ApiUrls.ownership_consigns; editions: React.PropTypes.array,
currentUser: React.PropTypes.object,
onRequestHide: React.PropTypes.func,
handleSuccess: React.PropTypes.func
}, },
getFormData(){ getFormData(){
return { return this.props.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() { render() {
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 ( return (
<form id="consign_modal_content" role="form" onSubmit={this.submit}> <Form
<input className="invisible" type="email" name="fake_consignee"/> ref='form'
<input className="invisible" type="password" name="fake_password"/> url={this.props.url}
<InputText getFormData={this.getFormData}
ref="consignee" handleSuccess={this.props.handleSuccess}
placeHolder={getLangText('Consignee email')} buttons={
required="required" <div className="modal-footer">
<p className="pull-right">
<Button
className="btn btn-default btn-sm ascribe-margin-1px"
type="submit">{getLangText('CONSIGN')}</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='consignee'
label={getLangText('Email')}>
<input
type="email" type="email"
submitted={this.state.submitted}/> placeholder={getLangText('Email of the consignee')}
<InputTextArea required/>
ref="consign_message" </Property>
defaultValue={message} <Property
required="" name='consign_message'
/> label={getLangText('Personal Message')}
<InputText editable={true}>
ref="password" <InputTextAreaToggable
placeHolder={getLangText('Password')} rows={1}
required="required" editable={true}
defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')}
required="required"/>
</Property>
<Property
name='password'
label={getLangText('Password')}>
<input
type="password" type="password"
submitted={this.state.submitted}/> placeholder={getLangText('Enter your password')}
<ButtonSubmitOrClose required/>
text={getLangText('CONSIGN')} </Property>
onClose={this.props.onRequestHide} <hr />
submitted={this.state.submitted} /> </Form>
</form>
); );
} }
}); });

View File

@ -72,7 +72,7 @@ let RequestActionForm = React.createClass({
return ( return (
<Alert bsStyle='warning'> <Alert bsStyle='warning'>
<div style={{textAlign: 'center'}}> <div style={{textAlign: 'center'}}>
<div>{ edition.owner } {getFormData('requests you')} { edition.request_action } {getLangText('this edition%s', '.')}&nbsp;&nbsp;</div> <div>{ edition.owner } {getLangText('requests you')} { edition.request_action } {getLangText('this edition%s', '.')}&nbsp;&nbsp;</div>
{buttons} {buttons}
</div> </div>
</Alert> </Alert>

View File

@ -115,11 +115,11 @@ let TransferForm = React.createClass({
<p className="pull-right"> <p className="pull-right">
<Button <Button
className="btn btn-default btn-sm ascribe-margin-1px" className="btn btn-default btn-sm ascribe-margin-1px"
type="submit">TRANSFER</Button> type="submit">{getLangText('TRANSFER')}</Button>
<Button <Button
className="btn btn-danger btn-delete btn-sm ascribe-margin-1px" className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
style={{marginLeft: '0'}} style={{marginLeft: '0'}}
onClick={this.props.onRequestHide}>CLOSE</Button> onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</Button>
</p> </p>
</div>} </div>}
spinner={ spinner={
@ -136,7 +136,7 @@ let TransferForm = React.createClass({
</Property> </Property>
<Property <Property
name='transfer_message' name='transfer_message'
label='Personal Message' label={getLangText('Personal Message')}
editable={true}> editable={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}

View File

@ -5,11 +5,19 @@ import React from 'react';
let TableItemAclFiltered = React.createClass({ let TableItemAclFiltered = React.createClass({
propTypes: { propTypes: {
content: React.PropTypes.object.isRequired content: React.PropTypes.object,
requestAction: React.PropTypes.string
}, },
render() { render() {
var availableAcls = ['acl_consign', 'acl_loan', 'acl_transfer', 'acl_view', 'acl_share', 'acl_unshare', 'acl_delete']; var availableAcls = ['acl_consign', 'acl_loan', 'acl_transfer', 'acl_view', 'acl_share', 'acl_unshare', 'acl_delete'];
if (this.props.requestAction){
return (
<span>
{this.props.requestAction + ' request pending'}
</span>
);
}
let filteredAcls = Object.keys(this.props.content).filter((key) => { let filteredAcls = Object.keys(this.props.content).filter((key) => {
return availableAcls.indexOf(key) > -1 && this.props.content[key]; return availableAcls.indexOf(key) > -1 && this.props.content[key];