diff --git a/js/components/ascribe_detail/further_details.js b/js/components/ascribe_detail/further_details.js index 3a5c0b90..e8bf5d3b 100644 --- a/js/components/ascribe_detail/further_details.js +++ b/js/components/ascribe_detail/further_details.js @@ -5,21 +5,15 @@ import React from 'react'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; - import Form from './../ascribe_forms/form'; -import Property from './../ascribe_forms/property'; import PieceExtraDataForm from './../ascribe_forms/form_piece_extradata'; -import ReactS3FineUploader from './../ascribe_uploader/react_s3_fine_uploader'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; -import ApiUrls from '../../constants/api_urls'; -import AppConstants from '../../constants/application_constants'; - -import { getCookie } from '../../utils/fetch_api_utils'; +import FurtherDetailsFileuploader from './further_details_fileuploader'; let FurtherDetails = React.createClass({ propTypes: { @@ -90,93 +84,21 @@ let FurtherDetails = React.createClass({ editable={this.props.editable} pieceId={this.props.pieceId} extraData={this.props.extraData} /> - +
+ + ); } }); -let FileUploader = React.createClass({ - propTypes: { - pieceId: React.PropTypes.number, - otherData: React.PropTypes.object, - setIsUploadReady: React.PropTypes.func, - submitKey: React.PropTypes.func, - isReadyForFormSubmission: React.PropTypes.func, - editable: React.PropTypes.bool - }, - render() { - // Essentially there a three cases important to the fileuploader - // - // 1. there is no other_data => do not show the fileuploader at all - // 2. there is other_data, but user has no edit rights => show fileuploader but without action buttons - // 3. both other_data and editable are defined or true => show fileuploade with all action buttons - if (!this.props.editable && !this.props.otherData){ - return null; - } - return ( -
- - - -
-
- ); - } -}); export default FurtherDetails; diff --git a/js/components/ascribe_detail/further_details_fileuploader.js b/js/components/ascribe_detail/further_details_fileuploader.js new file mode 100644 index 00000000..5d9cd5fd --- /dev/null +++ b/js/components/ascribe_detail/further_details_fileuploader.js @@ -0,0 +1,95 @@ +'use strict'; + +import React from 'react'; + +import Property from './../ascribe_forms/property'; + +import ReactS3FineUploader from './../ascribe_uploader/react_s3_fine_uploader'; + +import ApiUrls from '../../constants/api_urls'; +import AppConstants from '../../constants/application_constants'; + +import { getCookie } from '../../utils/fetch_api_utils'; + +let FurtherDetailsFileuploader = React.createClass({ + propTypes: { + pieceId: React.PropTypes.number, + otherData: React.PropTypes.object, + setIsUploadReady: React.PropTypes.func, + submitKey: React.PropTypes.func, + isReadyForFormSubmission: React.PropTypes.func, + editable: React.PropTypes.bool, + multiple: React.PropTypes.bool + }, + + getDefaultProps() { + return { + multiple: false + }; + }, + + render() { + // Essentially there a three cases important to the fileuploader + // + // 1. there is no other_data => do not show the fileuploader at all + // 2. there is other_data, but user has no edit rights => show fileuploader but without action buttons + // 3. both other_data and editable are defined or true => show fileuploade with all action buttons + if (!this.props.editable && !this.props.otherData){ + return null; + } + return ( + + + + ); + } +}); + +export default FurtherDetailsFileuploader; \ No newline at end of file diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index f319c363..a96f12b9 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -2,6 +2,8 @@ import React from 'react'; +import classnames from 'classnames'; + import Button from 'react-bootstrap/lib/Button'; import Form from './form'; @@ -20,12 +22,25 @@ import { getLangText } from '../../utils/lang_utils'; let LoanForm = React.createClass({ propTypes: { + fullform: React.PropTypes.bool, + email: React.PropTypes.string, + gallery: React.PropTypes.string, + startdate: React.PropTypes.string, + enddate: React.PropTypes.string, + showPersonalMessage: React.PropTypes.bool, + url: React.PropTypes.string, id: React.PropTypes.object, message: React.PropTypes.string, handleSuccess: React.PropTypes.func }, + getDefaultProps() { + return { + fullform: false + }; + }, + getInitialState() { return LoanContractStore.getState(); }, @@ -87,60 +102,87 @@ let LoanForm = React.createClass({ } }, - render() { + getButtons() { + if(this.props.fullform) { + return ( + + ); + } else { + return ( +
+

+ +

+
+ ); + } + }, + render() { return (
-

- -

- } + buttons={this.getButtons()} spinner={
}> +
+

Loan

+
+ onBlur={this.handleOnBlur} + editable={!this.props.email}> + label={getLangText('Gallery/exhibition (optional)')} + editable={!this.props.gallery}> + label={getLangText('Start date')} + hidden={!this.props.startdate}> + label={getLangText('End date')} + hidden={!this.props.enddate}> + editable={true} + hidden={this.props.showPersonalMessage}> { + extradata[fieldName] = formRefs[fieldName].state.value; + }); + + return { + extradata: extradata, + piece_id: this.props.piece.id + }; + }, + + setIsUploadReady(isReady) { + this.setState({ + isUploadReady: isReady + }); + }, + + isReadyForFormSubmission() { + return true; + }, + + render() { + if(this.props.piece && this.props.piece.id) { + return ( + + {getLangText('Proceed to loan')} + + } + spinner={ +
+ +
+ }> + + + + + + + + + ); + } else { + return First register the piece.; + } + } +}); + +export default CylandAdditionalDataForm; \ No newline at end of file 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 a1f76b6e..cb842df9 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -9,7 +9,6 @@ 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 PieceListStore from '../../../../../stores/piece_list_store'; @@ -18,36 +17,51 @@ import PieceListActions from '../../../../../actions/piece_list_actions'; import UserStore from '../../../../../stores/user_store'; import UserActions from '../../../../../actions/user_actions'; +import PieceStore from '../../../../../stores/piece_store'; +import PieceActions from '../../../../../actions/piece_actions'; + import GlobalNotificationModel from '../../../../../models/global_notification_model'; import GlobalNotificationActions from '../../../../../actions/global_notification_actions'; +import CylandAdditionalDataForm from '../ascribe_forms/cyland_additional_data_form'; + +import LoanForm from '../../../../ascribe_forms/form_loan'; + import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; +import ApiUrls from '../../../../../constants/api_urls'; + import { getLangText } from '../../../../../utils/lang_utils'; -import { mergeOptions } from '../../../../../utils/general_utils'; +import { mergeOptions, dateToString } from '../../../../../utils/general_utils'; +import { getAclFormMessage } from '../../../../../utils/form_utils'; let CylandRegisterPiece = React.createClass({ + mixins: [Router.Navigation], + getInitialState(){ return mergeOptions( UserStore.getState(), PieceListStore.getState(), + PieceStore.getState(), { selectedLicense: 0, isFineUploaderActive: false }); }, - mixins: [Router.Navigation], - componentDidMount() { PieceListStore.listen(this.onChange); UserStore.listen(this.onChange); + PieceStore.listen(this.onChange); + + UserActions.fetchCurrentUser(); }, componentWillUnmount() { PieceListStore.unlisten(this.onChange); UserStore.unlisten(this.onChange); + PieceStore.unlisten(this.onChange); }, onChange(state) { @@ -61,9 +75,7 @@ let CylandRegisterPiece = React.createClass({ } }, - handleSuccess(response){ - let notification = new GlobalNotificationModel(response.notification, 'success', 10000); - GlobalNotificationActions.appendGlobalNotification(notification); + handleRegisterSuccess(response){ // once the user was able to register a piece successfully, we need to make sure to keep // the piece list up to date @@ -76,7 +88,16 @@ let CylandRegisterPiece = React.createClass({ this.state.filterBy ); - this.transitionTo('piece', {pieceId: response.piece.id}); + // also start loading the piece for the next step + if(response && response.piece) { + PieceActions.updatePiece(response.piece); + } + + this.refs.slidesContainer.setSlideNum(1); + }, + + handleAdditionalDataSuccess() { + this.refs.slidesContainer.setSlideNum(2); }, changeSlide() { @@ -93,11 +114,14 @@ let CylandRegisterPiece = React.createClass({ }, render() { + + let today = new Date(); + let datetimeWhenWeAllWillBeFlyingCoolHoverboardsAndDinosaursWillLiveAgain = new Date(); + datetimeWhenWeAllWillBeFlyingCoolHoverboardsAndDinosaursWillLiveAgain.setFullYear(3000); + return ( -
+
{' ' + getLangText('I agree to the Terms of Service the art price') + ' '} - ( + ( {getLangText('read')} ) @@ -125,7 +149,28 @@ let CylandRegisterPiece = React.createClass({
- {/* next slide */} + + + + + +
+
+ + + + +
); diff --git a/js/utils/general_utils.js b/js/utils/general_utils.js index 4dfda21d..85472fea 100644 --- a/js/utils/general_utils.js +++ b/js/utils/general_utils.js @@ -178,3 +178,25 @@ function _mergeOptions(obj1, obj2) { export function escapeHTML(s) { return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML; } + +/** + * Converts a date object to a string. + * Taken from: http://stackoverflow.com/a/4929629/1263876 + * @param {date} date a javascript date + * @return {string} a string, in format: DD-MM-YYY + */ +export function dateToString(date) { + var dd = date.getDate(); + var mm = date.getMonth() + 1; //January is 0! + var yyyy = date.getFullYear(); + + if(dd < 10) { + dd = '0' + dd; + } + + if(mm < 10) { + mm = '0' + mm; + } + + return dd + '-' + mm + '-' + yyyy; +} \ No newline at end of file