diff --git a/js/actions/license_actions.js b/js/actions/license_actions.js new file mode 100644 index 00000000..358c158a --- /dev/null +++ b/js/actions/license_actions.js @@ -0,0 +1,25 @@ +'use strict'; + +import alt from '../alt'; +import LicenseFetcher from '../fetchers/license_fetcher'; + + +class LicenseActions { + constructor() { + this.generateActions( + 'updateLicenses' + ); + } + + fetchLicense() { + LicenseFetcher.fetch() + .then((res) => { + this.actions.updateLicenses(res.licenses); + }) + .catch((err) => { + console.log(err); + }); + } +} + +export default alt.createActions(LicenseActions); diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index 319214c1..e6db5405 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -130,15 +130,17 @@ let Form = React.createClass({ }, renderChildren() { return ReactAddons.Children.map(this.props.children, (child) => { - return ReactAddons.addons.cloneWithProps(child, { - handleChange: this.handleChangeChild, - ref: child.props.name - }); + if (child) { + return ReactAddons.addons.cloneWithProps(child, { + handleChange: this.handleChangeChild, + ref: child.props.name + }); + } }); }, render() { return ( -
); } + let footer = null; + if (this.props.footer){ + footer = ( +
+ {this.props.footer} +
); + } return (
{ this.props.label} {this.renderChildren()} + {footer}
diff --git a/js/components/header.js b/js/components/header.js index b2e70f81..e4233a06 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -61,14 +61,17 @@ let Header = React.createClass({ }, getPoweredBy(){ - return ( -
- - powered by - ascribe - - -
); + if (this.state.whitelabel.logo) { + return ( +
+ + powered by + ascribe + + +
); + } + return null; }, onChange(state) { this.setState(state); diff --git a/js/components/register_piece.js b/js/components/register_piece.js index a9414a23..0e12f95e 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -7,6 +7,9 @@ import AppConstants from '../constants/application_constants'; import Router from 'react-router'; +import LicenseActions from '../actions/license_actions'; +import LicenseStore from '../stores/license_store'; + import GlobalNotificationModel from '../models/global_notification_model'; import GlobalNotificationActions from '../actions/global_notification_actions'; @@ -19,15 +22,32 @@ import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader'; import DatePicker from 'react-datepicker/dist/react-datepicker'; +import { mergeOptions } from '../utils/general_utils'; let RegisterPiece = React.createClass( { mixins: [Router.Navigation], getInitialState(){ - return { - digitalWorkKey: null, - isUploadReady: false - }; + return mergeOptions( + LicenseStore.getState(), + { + digitalWorkKey: null, + uploadStatus: false, + selectedLicense: 0 + }); + }, + + componentDidMount() { + LicenseActions.fetchLicense(); + LicenseStore.listen(this.onChange); + }, + + componentWillUnmount() { + LicenseStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); }, handleSuccess(){ @@ -59,12 +79,43 @@ let RegisterPiece = React.createClass( { isReadyForFormSubmission(files) { files = files.filter((file) => file.status !== 'deleted' && file.status !== 'canceled'); - if(files.length > 0 && files[0].status === 'upload successful') { + if (files.length > 0 && files[0].status === 'upload successful') { return true; } else { return false; } }, + onLicenseChange(event){ + console.log(this.state.licenses[event.target.selectedIndex].url); + this.setState({selectedLicense: event.target.selectedIndex}); + }, + getLicenses() { + if (this.state.licenses && this.state.licenses.length > 0) { + return ( + + Learn more about this license + }> + + ); + } + return null; + }, render() { return ( @@ -76,7 +127,7 @@ let RegisterPiece = React.createClass( { url={apiUrls.pieces_list} getFormData={this.getFormData} handleSuccess={this.handleSuccess} - buttons={