From 9630d043db757ba7e89d1ae6953a1ba25a303b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 12 Aug 2015 09:52:51 +0200 Subject: [PATCH] first slide cyland archive submission --- js/components/ascribe_forms/form.js | 1 - js/components/register_piece.js | 6 +- .../cyland/cyland_register_piece.js | 158 +++++++++++++----- 3 files changed, 119 insertions(+), 46 deletions(-) diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index 0b8d9994..2b956a7e 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -103,7 +103,6 @@ let Form = React.createClass({ if ('getFormData' in this.props){ data = mergeOptionsWithDuplicates(data, this.props.getFormData()); } - console.log(data); return data; }, diff --git a/js/components/register_piece.js b/js/components/register_piece.js index 4fbff2b9..229592b0 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -1,14 +1,11 @@ 'use strict'; import React from 'react'; - import Router from 'react-router'; + import Col from 'react-bootstrap/lib/Col'; import Row from 'react-bootstrap/lib/Row'; -import LicenseActions from '../actions/license_actions'; -import LicenseStore from '../stores/license_store'; - import WhitelabelActions from '../actions/whitelabel_actions'; import WhitelabelStore from '../stores/whitelabel_store'; @@ -20,7 +17,6 @@ import UserStore from '../stores/user_store'; import GlobalNotificationModel from '../models/global_notification_model'; import GlobalNotificationActions from '../actions/global_notification_actions'; -import Property from './ascribe_forms/property'; import PropertyCollapsible from './ascribe_forms/property_collapsible'; import RegisterPieceForm from './ascribe_forms/form_register_piece'; diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js index a5ff79b3..a1f76b6e 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -1,55 +1,133 @@ 'use strict'; import React from 'react'; -import RegisterPiece from '../../../../register_piece'; +import Router from 'react-router'; + +import Col from 'react-bootstrap/lib/Col'; +import Row from 'react-bootstrap/lib/Row'; + +import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece'; + import Property from '../../../../ascribe_forms/property'; import InputTextAreaToggable from '../../../../ascribe_forms/input_textarea_toggable'; import InputCheckbox from '../../../../ascribe_forms/input_checkbox'; -import { getLangText } from '../../../../../utils/lang_utils'; +import PieceListStore from '../../../../../stores/piece_list_store'; +import PieceListActions from '../../../../../actions/piece_list_actions'; +import UserStore from '../../../../../stores/user_store'; +import UserActions from '../../../../../actions/user_actions'; + +import GlobalNotificationModel from '../../../../../models/global_notification_model'; +import GlobalNotificationActions from '../../../../../actions/global_notification_actions'; + +import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; + +import { getLangText } from '../../../../../utils/lang_utils'; +import { mergeOptions } from '../../../../../utils/general_utils'; let CylandRegisterPiece = React.createClass({ + + getInitialState(){ + return mergeOptions( + UserStore.getState(), + PieceListStore.getState(), + { + selectedLicense: 0, + isFineUploaderActive: false + }); + }, + + mixins: [Router.Navigation], + + componentDidMount() { + PieceListStore.listen(this.onChange); + UserStore.listen(this.onChange); + }, + + componentWillUnmount() { + PieceListStore.unlisten(this.onChange); + UserStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); + + if(this.state.currentUser && this.state.currentUser.email) { + // we should also make the fineuploader component editable again + this.setState({ + isFineUploaderActive: true + }); + } + }, + + handleSuccess(response){ + let notification = new GlobalNotificationModel(response.notification, 'success', 10000); + GlobalNotificationActions.appendGlobalNotification(notification); + + // once the user was able to register a piece successfully, we need to make sure to keep + // the piece list up to date + PieceListActions.fetchPieceList( + this.state.page, + this.state.pageSize, + this.state.searchTerm, + this.state.orderBy, + this.state.orderAsc, + this.state.filterBy + ); + + this.transitionTo('piece', {pieceId: response.piece.id}); + }, + + changeSlide() { + // only transition to the login store, if user is not logged in + // ergo the currentUser object is not properly defined + if(this.state.currentUser && !this.state.currentUser.email) { + this.onLoggedOut(); + } + }, + + // basically redirects to the second slide (index: 1), when the user is not logged in + onLoggedOut() { + this.transitionTo('login'); + }, + render() { return ( - - - - - - - - - - - {' ' + getLangText('I agree to the Terms of Service the art price') + ' '} - ( - {getLangText('read')} - ) - - - - + +
+ + + + + + + {' ' + getLangText('I agree to the Terms of Service the art price') + ' '} + ( + {getLangText('read')} + ) + + + + + + +
+
+ {/* next slide */} +
+
); } });