From 88ff4b55d69f046dbbf9fed093e62b9b3078b2ff Mon Sep 17 00:00:00 2001 From: diminator Date: Fri, 10 Jul 2015 20:00:35 +0200 Subject: [PATCH] acl buttons and share forms for pieces/editions --- js/components/ascribe_buttons/acl_button.js | 14 +-- .../ascribe_buttons/acl_button_list.js | 10 +- js/components/ascribe_detail/piece.js | 88 ++++++++++++--- .../ascribe_forms/form_share_email.js | 103 ++++++++++++------ js/constants/api_urls.js | 2 +- 5 files changed, 155 insertions(+), 62 deletions(-) diff --git a/js/components/ascribe_buttons/acl_button.js b/js/components/ascribe_buttons/acl_button.js index c1a63265..e054a23c 100644 --- a/js/components/ascribe_buttons/acl_button.js +++ b/js/components/ascribe_buttons/acl_button.js @@ -13,14 +13,14 @@ import AppConstants from '../../constants/application_constants'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; -import { getLangText } from '../../utils/lang_utils.js' +import { getLangText } from '../../utils/lang_utils.js'; let AclButton = React.createClass({ propTypes: { action: React.PropTypes.oneOf(AppConstants.aclList).isRequired, availableAcls: React.PropTypes.array.isRequired, - editions: React.PropTypes.array.isRequired, + pieceOrEditions: React.PropTypes.array.isRequired, currentUser: React.PropTypes.object, handleSuccess: React.PropTypes.func.isRequired, className: React.PropTypes.string @@ -31,7 +31,7 @@ let AclButton = React.createClass({ return { title: getLangText('Consign artwork'), tooltip: getLangText('Have someone else sell the artwork'), - form: , + form: , handleSuccess: this.showNotification }; } @@ -39,14 +39,14 @@ let AclButton = React.createClass({ return { title: getLangText('Unconsign artwork'), tooltip: getLangText('Have the owner manage his sales again'), - form: , + form: , handleSuccess: this.showNotification }; }else if (this.props.action === 'transfer') { return { title: getLangText('Transfer artwork'), tooltip: getLangText('Transfer the ownership of the artwork'), - form: , + form: , handleSuccess: this.showNotification }; } @@ -54,7 +54,7 @@ let AclButton = React.createClass({ return { title: getLangText('Loan artwork'), tooltip: getLangText('Loan your artwork for a limited period of time'), - form: , + form: , handleSuccess: this.showNotification }; } @@ -62,7 +62,7 @@ let AclButton = React.createClass({ return { title: getLangText('Share artwork'), tooltip: getLangText('Share the artwork'), - form: , + form: , handleSuccess: this.showNotification }; } diff --git a/js/components/ascribe_buttons/acl_button_list.js b/js/components/ascribe_buttons/acl_button_list.js index ae639aa4..07003d11 100644 --- a/js/components/ascribe_buttons/acl_button_list.js +++ b/js/components/ascribe_buttons/acl_button_list.js @@ -39,31 +39,31 @@ let AclButtonList = React.createClass({ diff --git a/js/components/ascribe_detail/piece.js b/js/components/ascribe_detail/piece.js index 14ab1de5..b04b511e 100644 --- a/js/components/ascribe_detail/piece.js +++ b/js/components/ascribe_detail/piece.js @@ -7,14 +7,30 @@ import Col from 'react-bootstrap/lib/Col'; import CollapsibleParagraph from './../ascribe_collapsible/collapsible_paragraph'; +import DetailProperty from './detail_property'; + import FurtherDetails from './further_details'; -//import UserActions from '../../actions/user_actions'; -//import UserStore from '../../stores/user_store'; +import UserActions from '../../actions/user_actions'; +import UserStore from '../../stores/user_store'; import MediaContainer from './media_container'; import Header from './header'; +import Form from './../ascribe_forms/form'; +import Property from './../ascribe_forms/property'; + +import RequestActionForm from './../ascribe_forms/form_request_action'; +import EditionActions from '../../actions/edition_actions'; +import AclButtonList from './../ascribe_buttons/acl_button_list'; + + +import GlobalNotificationModel from '../../models/global_notification_model'; +import GlobalNotificationActions from '../../actions/global_notification_actions'; + +import apiUrls from '../../constants/api_urls'; +import { getLangText } from '../../utils/lang_utils'; + /** * This is the component that implements display-specific functionality */ @@ -24,22 +40,22 @@ let Piece = React.createClass({ loadPiece: React.PropTypes.func }, - //getInitialState() { - // return UserStore.getState(); - //}, - // - //componentDidMount() { - // UserStore.listen(this.onChange); - // UserActions.fetchCurrentUser(); - //}, - // - //componentWillUnmount() { - // UserStore.unlisten(this.onChange); - //}, - // - //onChange(state) { - // this.setState(state); - //}, + getInitialState() { + return UserStore.getState(); + }, + + componentDidMount() { + UserStore.listen(this.onChange); + UserActions.fetchCurrentUser(); + }, + + componentWillUnmount() { + UserStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); + }, render() { @@ -52,6 +68,9 @@ let Piece = React.createClass({
+ -1 @@ -72,4 +91,37 @@ let Piece = React.createClass({ } }); +let PieceSummary = React.createClass({ + propTypes: { + piece: React.PropTypes.object + }, + + getActions(){ + //let actions = ( + // + // + // + // + // ); + //return actions; + return null; + }, + render() { + return ( +
+ +
+ {this.getActions()} +
+
+ ); + + } +}); + + export default Piece; diff --git a/js/components/ascribe_forms/form_share_email.js b/js/components/ascribe_forms/form_share_email.js index e10492d4..8c01cf6a 100644 --- a/js/components/ascribe_forms/form_share_email.js +++ b/js/components/ascribe_forms/form_share_email.js @@ -3,29 +3,45 @@ 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 Form from './form'; +import Property from './property'; +import InputTextAreaToggable from './input_textarea_toggable'; +import Button from 'react-bootstrap/lib/Button'; + +import AppConstants from '../../constants/application_constants'; +import { getLangText } from '../../utils/lang_utils.js'; let ShareForm = React.createClass({ - mixins: [FormMixin], - - url() { - return ApiUrls.ownership_shares; + propTypes: { + editions: React.PropTypes.array, + currentUser: React.PropTypes.object }, getFormData() { return { - bitcoin_id: this.getBitcoinIds().join(), - share_emails: this.refs.share_emails.state.value, - share_message: this.refs.share_message.state.value + bitcoin_id: this.getBitcoinIds().join() }; }, + handleSuccess(response){ + if ('handleSuccess' in this.props){ + this.props.handleSuccess(response); + } + }, + getBitcoinIds(){ + return this.props.editions.map(function(edition){ + return edition.bitcoin_id; + }); + }, - renderForm() { + getTitlesString(){ + return this.props.editions.map(function(edition){ + return '- \"' + edition.title + ', ' + getLangText('edition') + ' ' + edition.edition_number + '\"\n'; + }); + }, + + render() { let title = this.getTitlesString().join(''); let username = this.props.currentUser.username; let message = @@ -36,25 +52,50 @@ ${title}${getLangText('with you')}. ${getLangText('Truly yours')}, ${username}`; - return ( -
- - - - +
+

+ + +

+ } + spinner={ +
+ +
+ } + > + + + + + + +
); } }); diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index 040d37ba..b5d9a9eb 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -25,7 +25,7 @@ let apiUrls = { 'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/', 'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/', 'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/contract/', - 'ownership_shares': AppConstants.apiEndpoint + 'ownership/shares/', + 'ownership_shares_editions': AppConstants.apiEndpoint + 'ownership/shares/editions/', 'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/', 'ownership_transfers_withdraw': AppConstants.apiEndpoint + 'ownership/transfers/withdraw/', 'ownership_unconsigns': AppConstants.apiEndpoint + 'ownership/unconsigns/',