From 8d9df43339b09d96497762031964a62d139017e5 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 15 Jan 2016 17:17:34 +0100 Subject: [PATCH] Clean up whitelabel AdditionalDataForms --- .../cyland_additional_data_form.js | 38 ++--- .../ikonotv_detail/ikonotv_piece_container.js | 1 + .../ikonotv_artist_details_form.js | 51 +++---- .../ikonotv_artwork_details_form.js | 62 ++++---- .../market_additional_data_form.js | 141 ++++++++++-------- 5 files changed, 155 insertions(+), 138 deletions(-) diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js b/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js index 93cc515a..b4f20872 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js @@ -23,9 +23,10 @@ import { formSubmissionValidation } from '../../../../../ascribe_uploader/react_ let CylandAdditionalDataForm = React.createClass({ propTypes: { - handleSuccess: React.PropTypes.func, piece: React.PropTypes.object.isRequired, + disabled: React.PropTypes.bool, + handleSuccess: React.PropTypes.func, isInline: React.PropTypes.bool }, @@ -42,13 +43,13 @@ let CylandAdditionalDataForm = React.createClass({ }, handleSuccess() { - let notification = new GlobalNotificationModel(getLangText('Further details successfully updated'), 'success', 10000); + const notification = new GlobalNotificationModel(getLangText('Further details successfully updated'), 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); }, getFormData() { - let extradata = {}; - let formRefs = this.refs.form.refs; + const extradata = {}; + const formRefs = this.refs.form.refs; // Put additional fields in extra data object Object @@ -71,10 +72,13 @@ let CylandAdditionalDataForm = React.createClass({ }, render() { - let { piece, isInline, disabled, handleSuccess, location } = this.props; - let buttons, spinner, heading; + const { disabled, handleSuccess, isInline, piece } = this.props; - if(!isInline) { + let buttons; + let spinner; + let heading; + + if (!isInline) { buttons = ( ); @@ -74,7 +76,7 @@ let IkonotvArtistDetailsForm = React.createClass({ spinner = (

- +

); @@ -88,13 +90,13 @@ let IkonotvArtistDetailsForm = React.createClass({ ); } - if (this.props.piece && this.props.piece.id && this.props.piece.extra_data) { + if (piece.id && piece.extra_data) { return ( + expanded={!disabled || !!piece.extra_data.artist_website}> + defaultValue={piece.extra_data.artist_website} + placeholder={getLangText('The artist\'s website if present...')} /> + expanded={!disabled || !!piece.extra_data.gallery_website}> + defaultValue={piece.extra_data.gallery_website} + placeholder={getLangText('The website of any related Gallery or Museum')} /> + expanded={!disabled || !!piece.extra_data.additional_websites}> + defaultValue={piece.extra_data.additional_websites} + placeholder={getLangText('Enter additional Websites/Publications if any')} /> + expanded={!disabled || !!piece.extra_data.conceptual_overview}> + defaultValue={piece.extra_data.conceptual_overview} + placeholder={getLangText('Enter a short bio about the Artist')} /> ); diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_forms/ikonotv_artwork_details_form.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_forms/ikonotv_artwork_details_form.js index bcf6830d..9c2c3e33 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_forms/ikonotv_artwork_details_form.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_forms/ikonotv_artwork_details_form.js @@ -20,11 +20,10 @@ import { getLangText } from '../../../../../../utils/lang_utils'; let IkonotvArtworkDetailsForm = React.createClass({ propTypes: { - handleSuccess: React.PropTypes.func, piece: React.PropTypes.object.isRequired, disabled: React.PropTypes.bool, - + handleSuccess: React.PropTypes.func, isInline: React.PropTypes.bool }, @@ -35,8 +34,8 @@ let IkonotvArtworkDetailsForm = React.createClass({ }, getFormData() { - let extradata = {}; - let formRefs = this.refs.form.refs; + const extradata = {}; + const formRefs = this.refs.form.refs; // Put additional fields in extra data object Object @@ -53,20 +52,23 @@ let IkonotvArtworkDetailsForm = React.createClass({ }, handleSuccess() { - let notification = new GlobalNotificationModel('Artwork details successfully updated', 'success', 10000); + const notification = new GlobalNotificationModel('Artwork details successfully updated', 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); }, render() { - let buttons, spinner, heading; - let { isInline, handleSuccess } = this.props; + const { disabled, isInline, handleSuccess, piece } = this.props; + + let buttons; + let spinner; + let heading; if (!isInline) { buttons = ( ); @@ -74,7 +76,7 @@ let IkonotvArtworkDetailsForm = React.createClass({ spinner = (

- +

); @@ -88,13 +90,13 @@ let IkonotvArtworkDetailsForm = React.createClass({ ); } - if (this.props.piece && this.props.piece.id && this.props.piece.extra_data) { + if (piece.id && piece.extra_data) { return (
+ expanded={!disabled || !!piece.extra_data.medium}> + defaultValue={piece.extra_data.medium} + placeholder={getLangText('The medium of the file (i.e. photo, video, other, ...)')} /> + expanded={!disabled || !!piece.extra_data.size_duration}> + defaultValue={piece.extra_data.size_duration} + placeholder={getLangText('Size in centimeters. Duration in minutes.')} /> + expanded={!disabled || !!piece.extra_data.copyright}> + defaultValue={piece.extra_data.copyright} + placeholder={getLangText('Which copyright is attached to this work?')} /> + expanded={!disabled || !!piece.extra_data.courtesy_of}> + defaultValue={piece.extra_data.courtesy_of} + placeholder={getLangText('The current owner of the artwork')} /> + expanded={!disabled || !!piece.extra_data.copyright_of_photography}> + defaultValue={piece.extra_data.copyright_of_photography} + placeholder={getLangText('Who should be attributed for the photography?')} /> + expanded={!disabled || !!piece.extra_data.additional_details}> + defaultValue={piece.extra_data.additional_details} + placeholder={getLangText('Insert artwork overview')} /> ); diff --git a/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js b/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js index e5eb25fe..c8c1dae4 100644 --- a/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js +++ b/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js @@ -109,7 +109,7 @@ let MarketAdditionalDataForm = React.createClass({ render() { const { editable, - extraData, + extraData = {}, isInline, handleSuccess, otherData, @@ -118,8 +118,9 @@ let MarketAdditionalDataForm = React.createClass({ showNotification, submitLabel } = this.props; - let buttons, heading; - let spinner = ; + let buttons; + let heading; + let spinner; if (!isInline) { buttons = ( @@ -134,7 +135,7 @@ let MarketAdditionalDataForm = React.createClass({ spinner = (

- {spinner} +

); @@ -148,68 +149,76 @@ let MarketAdditionalDataForm = React.createClass({ ) : null; } - return ( -
- {heading} - - - - - - - - - - - - - - - ); + if (pieceId) { + return ( +
+ {heading} + + + + + + + + + + + + + + + ); + } else { + return ( +
+ +
+ ); + } } });