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 ( -
diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index df3aac3f..46626f2d 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -14,6 +14,7 @@ let apiUrls = { 'edition_delete': AppConstants.apiEndpoint + 'editions/${edition_id}/', 'edition_remove_from_collection': AppConstants.apiEndpoint + 'ownership/shares/${edition_id}/', 'editions_list': AppConstants.apiEndpoint + 'pieces/${piece_id}/editions/', + 'licenses': AppConstants.apiEndpoint + 'ownership/licenses/', 'note_notes': AppConstants.apiEndpoint + 'note/notes/', 'note_edition': AppConstants.apiEndpoint + 'note/edition_notes/', 'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/', diff --git a/js/fetchers/license_fetcher.js b/js/fetchers/license_fetcher.js new file mode 100644 index 00000000..6b0cada0 --- /dev/null +++ b/js/fetchers/license_fetcher.js @@ -0,0 +1,14 @@ +'use strict'; + +import requests from '../utils/requests'; + +let LicenseFetcher = { + /** + * Fetch the available licenses from the API (might be bound to the subdomain e.g. cc.ascribe.io). + */ + fetch() { + return requests.get('licenses', {'subdomain': window.location.host.split('.')[0]}); + } +}; + +export default LicenseFetcher; diff --git a/js/stores/license_store.js b/js/stores/license_store.js new file mode 100644 index 00000000..42a6bfb5 --- /dev/null +++ b/js/stores/license_store.js @@ -0,0 +1,18 @@ +'use strict'; + +import alt from '../alt'; +import LicenseActions from '../actions/license_actions'; + + +class LicenseStore { + constructor() { + this.licenses = {}; + this.bindActions(LicenseActions); + } + + onUpdateLicenses(licenses) { + this.licenses = licenses; + } +} + +export default alt.createStore(LicenseStore, 'LicenseStore'); diff --git a/sass/ascribe_settings.scss b/sass/ascribe_settings.scss index 8e136338..bbd6dc77 100644 --- a/sass/ascribe_settings.scss +++ b/sass/ascribe_settings.scss @@ -127,3 +127,9 @@ padding: 0; } } + +.ascribe-property-footer{ + font-size: 0.8em; + margin-top: 10px; + width: 100%; +} \ No newline at end of file