1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

refactor input textarea to use disabled instead of editable

This commit is contained in:
Tim Daubenschütz 2015-09-21 12:05:42 +02:00
parent a8976ca54a
commit c00e003aeb
21 changed files with 61 additions and 83 deletions

View File

@ -44,14 +44,13 @@ let Note = React.createClass({
<Form <Form
url={this.props.url} url={this.props.url}
getFormData={this.props.id} getFormData={this.props.id}
handleSuccess={this.showNotification}> handleSuccess={this.showNotification}
disabled={!this.props.editable}>
<Property <Property
name='note' name='note'
label={this.props.label} label={this.props.label}>
editable={this.props.editable}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={this.props.editable}
defaultValue={this.props.defaultValue} defaultValue={this.props.defaultValue}
placeholder={this.props.placeholder}/> placeholder={this.props.placeholder}/>
</Property> </Property>
@ -63,4 +62,4 @@ let Note = React.createClass({
} }
}); });
export default Note export default Note;

View File

@ -56,10 +56,10 @@ let ConsignForm = React.createClass({
<Property <Property
name='consign_message' name='consign_message'
label={getLangText('Personal Message')} label={getLangText('Personal Message')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
defaultValue={this.props.message} defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')} placeholder={getLangText('Enter a message...')}
required="required"/> required="required"/>

View File

@ -129,9 +129,11 @@ let ContractAgreementForm = React.createClass({
name='appendix' name='appendix'
checkboxLabel={getLangText('Add appendix to the contract')}> checkboxLabel={getLangText('Add appendix to the contract')}>
<span>{getLangText('Appendix')}</span> <span>{getLangText('Appendix')}</span>
{/* We're using disabled on a form here as PropertyCollapsible currently
does not support the disabled + overrideForm functionality */}
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true} disabled={false}
placeholder={getLangText('This will be appended to the contract selected above')}/> placeholder={getLangText('This will be appended to the contract selected above')}/>
</PropertyCollapsible> </PropertyCollapsible>
</Form> </Form>

View File

@ -256,10 +256,10 @@ let LoanForm = React.createClass({
name='loan_message' name='loan_message'
label={getLangText('Personal Message')} label={getLangText('Personal Message')}
editable={true} editable={true}
overrideForm={true}
hidden={!this.props.showPersonalMessage}> hidden={!this.props.showPersonalMessage}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
defaultValue={this.props.message} defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')} placeholder={getLangText('Enter a message...')}
required={this.props.showPersonalMessage ? 'required' : ''}/> required={this.props.showPersonalMessage ? 'required' : ''}/>

View File

@ -41,14 +41,13 @@ let PieceExtraDataForm = React.createClass({
ref='form' ref='form'
url={url} url={url}
handleSuccess={this.props.handleSuccess} handleSuccess={this.props.handleSuccess}
getFormData={this.getFormData}> getFormData={this.getFormData}
disabled={!this.props.editable}>
<Property <Property
name={this.props.name} name={this.props.name}
label={this.props.title} label={this.props.title}>
editable={this.props.editable}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={this.props.editable}
defaultValue={defaultValue} defaultValue={defaultValue}
placeholder={getLangText('Fill in%s', ' ') + this.props.title} placeholder={getLangText('Fill in%s', ' ') + this.props.title}
required="required"/> required="required"/>

View File

@ -112,7 +112,7 @@ let RegisterPieceForm = React.createClass({
isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile} isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile}
isFineUploaderActive={this.props.isFineUploaderActive} isFineUploaderActive={this.props.isFineUploaderActive}
onLoggedOut={this.props.onLoggedOut} onLoggedOut={this.props.onLoggedOut}
editable={this.props.isFineUploaderEditable} disabled={!this.props.isFineUploaderEditable}
enableLocalHashing={enableLocalHashing}/> enableLocalHashing={enableLocalHashing}/>
</Property> </Property>
<Property <Property

View File

@ -60,10 +60,10 @@ let ShareForm = React.createClass({
<Property <Property
name='share_message' name='share_message'
label='Personal Message' label='Personal Message'
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
defaultValue={this.props.message} defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')} placeholder={getLangText('Enter a message...')}
required="required"/> required="required"/>

View File

@ -45,20 +45,20 @@ let PieceSubmitToPrizeForm = React.createClass({
<Property <Property
name='artist_statement' name='artist_statement'
label={getLangText('Artist statement')} label={getLangText('Artist statement')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
placeholder={getLangText('Enter your statement')} placeholder={getLangText('Enter your statement')}
required="required"/> required="required"/>
</Property> </Property>
<Property <Property
name='work_description' name='work_description'
label={getLangText('Work description')} label={getLangText('Work description')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
placeholder={getLangText('Enter the description for your work')} placeholder={getLangText('Enter the description for your work')}
required="required"/> required="required"/>
</Property> </Property>

View File

@ -61,10 +61,10 @@ let TransferForm = React.createClass({
<Property <Property
name='transfer_message' name='transfer_message'
label={getLangText('Personal Message')} label={getLangText('Personal Message')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
defaultValue={this.props.message} defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')} placeholder={getLangText('Enter a message...')}
required="required"/> required="required"/>

View File

@ -50,10 +50,10 @@ let UnConsignForm = React.createClass({
<Property <Property
name='unconsign_message' name='unconsign_message'
label={getLangText('Personal Message')} label={getLangText('Personal Message')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
defaultValue={this.props.message} defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')} placeholder={getLangText('Enter a message...')}
required="required"/> required="required"/>

View File

@ -50,10 +50,10 @@ let UnConsignRequestForm = React.createClass({
<Property <Property
name='unconsign_request_message' name='unconsign_request_message'
label={getLangText('Personal Message')} label={getLangText('Personal Message')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
defaultValue={this.props.message} defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')} placeholder={getLangText('Enter a message...')}
required="required"/> required="required"/>

View File

@ -8,12 +8,14 @@ import AppConstants from '../../constants/application_constants';
import { getCookie } from '../../utils/fetch_api_utils'; import { getCookie } from '../../utils/fetch_api_utils';
let InputFileUploader = React.createClass({ let InputFineUploader = React.createClass({
propTypes: { propTypes: {
setIsUploadReady: React.PropTypes.func, setIsUploadReady: React.PropTypes.func,
isReadyForFormSubmission: React.PropTypes.func, isReadyForFormSubmission: React.PropTypes.func,
submitFileName: React.PropTypes.func, submitFileName: React.PropTypes.func,
areAssetsDownloadable: React.PropTypes.bool,
onClick: React.PropTypes.func, onClick: React.PropTypes.func,
keyRoutine: React.PropTypes.shape({ keyRoutine: React.PropTypes.shape({
url: React.PropTypes.string, url: React.PropTypes.string,
@ -33,7 +35,7 @@ let InputFileUploader = React.createClass({
// before login in // before login in
isFineUploaderActive: React.PropTypes.bool, isFineUploaderActive: React.PropTypes.bool,
onLoggedOut: React.PropTypes.func, onLoggedOut: React.PropTypes.func,
editable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool, enableLocalHashing: React.PropTypes.bool,
// provided by Property // provided by Property
@ -86,7 +88,7 @@ let InputFileUploader = React.createClass({
submitFile={this.submitFile} submitFile={this.submitFile}
setIsUploadReady={this.props.setIsUploadReady} setIsUploadReady={this.props.setIsUploadReady}
isReadyForFormSubmission={this.props.isReadyForFormSubmission} isReadyForFormSubmission={this.props.isReadyForFormSubmission}
areAssetsDownloadable={false} areAssetsDownloadable={this.props.areAssetsDownloadable}
areAssetsEditable={editable} areAssetsEditable={editable}
signature={{ signature={{
endpoint: AppConstants.serverUrl + 's3/signature/', endpoint: AppConstants.serverUrl + 's3/signature/',
@ -109,4 +111,4 @@ let InputFileUploader = React.createClass({
} }
}); });
export default InputFileUploader; export default InputFineUploader;

View File

@ -7,7 +7,7 @@ import TextareaAutosize from 'react-textarea-autosize';
let InputTextAreaToggable = React.createClass({ let InputTextAreaToggable = React.createClass({
propTypes: { propTypes: {
editable: React.PropTypes.bool.isRequired, disabled: React.PropTypes.bool,
rows: React.PropTypes.number.isRequired, rows: React.PropTypes.number.isRequired,
required: React.PropTypes.string, required: React.PropTypes.string,
defaultValue: React.PropTypes.string defaultValue: React.PropTypes.string
@ -54,7 +54,7 @@ let InputTextAreaToggable = React.createClass({
let className = 'form-control ascribe-textarea'; let className = 'form-control ascribe-textarea';
let textarea = null; let textarea = null;
if(this.props.editable) { if(!this.props.disabled) {
className = className + ' ascribe-textarea-editable'; className = className + ' ascribe-textarea-editable';
textarea = ( textarea = (
<TextareaAutosize <TextareaAutosize

View File

@ -84,10 +84,11 @@ let CoaVerifyForm = React.createClass({
</Property> </Property>
<Property <Property
name='signature' name='signature'
label="Signature"> label="Signature"
editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={3} rows={3}
editable={true}
placeholder={getLangText('Copy paste the signature on the bottom of your Certificate of Authenticity')} placeholder={getLangText('Copy paste the signature on the bottom of your Certificate of Authenticity')}
required/> required/>
</Property> </Property>

View File

@ -426,10 +426,10 @@ let PrizePieceDetails = React.createClass({
<Property <Property
name={data} name={data}
label={label} label={label}
editable={false}> editable={false}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={false}
defaultValue={this.props.piece.extra_data[data]}/> defaultValue={this.props.piece.extra_data[data]}/>
</Property>); </Property>);
} }

View File

@ -41,20 +41,20 @@ let PrizeRegisterPiece = React.createClass({
<Property <Property
name='artist_statement' name='artist_statement'
label={getLangText('Artist statement')} label={getLangText('Artist statement')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
placeholder={getLangText('Enter your statement')} placeholder={getLangText('Enter your statement')}
required="required"/> required="required"/>
</Property> </Property>
<Property <Property
name='work_description' name='work_description'
label={getLangText('Work description')} label={getLangText('Work description')}
editable={true}> editable={true}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={true}
placeholder={getLangText('Enter the description for your work')} placeholder={getLangText('Enter the description for your work')}
required="required"/> required="required"/>
</Property> </Property>

View File

@ -143,10 +143,10 @@ let CylandPieceDetails = React.createClass({
key={i} key={i}
name={data} name={data}
label={label} label={label}
editable={false}> editable={false}
overrideForm={true}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={false}
defaultValue={this.props.piece.extra_data[data]}/> defaultValue={this.props.piece.extra_data[data]}/>
</Property>); </Property>);
} }

View File

@ -92,21 +92,17 @@ let CylandAdditionalDataForm = React.createClass({
</div> </div>
<Property <Property
name='artist_bio' name='artist_bio'
label={getLangText('Artist Biography')} label={getLangText('Artist Biography')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
placeholder={getLangText('Enter the artist\'s biography...')} placeholder={getLangText('Enter the artist\'s biography...')}
required="required"/> required="required"/>
</Property> </Property>
<Property <Property
name='conceptual_overview' name='conceptual_overview'
label={getLangText('Conceptual Overview')} label={getLangText('Conceptual Overview')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
placeholder={getLangText('Enter a conceptual overview...')} placeholder={getLangText('Enter a conceptual overview...')}
required="required"/> required="required"/>
</Property> </Property>
@ -115,7 +111,6 @@ let CylandAdditionalDataForm = React.createClass({
submitFile={this.submitFile} submitFile={this.submitFile}
setIsUploadReady={this.setIsUploadReady} setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={formSubmissionValidation.fileOptional} isReadyForFormSubmission={formSubmissionValidation.fileOptional}
editable={!this.props.disabled}
pieceId={this.props.piece.id} pieceId={this.props.piece.id}
otherData={this.props.piece.other_data} otherData={this.props.piece.other_data}
multiple={true}/> multiple={true}/>

View File

@ -185,7 +185,9 @@ let IkonotvPieceDetails = React.createClass({
title={getLangText('Further Details')} title={getLangText('Further Details')}
show={true} show={true}
defaultExpanded={true}> defaultExpanded={true}>
<Form ref='form'> <Form
ref='form'
disabled={!this.props.piece.acl.acl_edit}>
{Object.keys(this.props.piece.extra_data).map((data, i) => { {Object.keys(this.props.piece.extra_data).map((data, i) => {
let label = data.replace('_', ' '); let label = data.replace('_', ' ');
return ( return (
@ -193,11 +195,9 @@ let IkonotvPieceDetails = React.createClass({
key={i} key={i}
name={data} name={data}
label={label} label={label}
hidden={!this.props.piece.extra_data[data]} hidden={!this.props.piece.extra_data[data]}>
editable={false}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={false}
defaultValue={this.props.piece.extra_data[data]}/> defaultValue={this.props.piece.extra_data[data]}/>
</Property>); </Property>);
} }

View File

@ -91,41 +91,33 @@ let IkonotvArtistDetailsForm = React.createClass({
</div> </div>
<Property <Property
name='artist_website' name='artist_website'
label={getLangText('Artist Website')} label={getLangText('Artist Website')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.artist_website} defaultValue={this.props.piece.extra_data.artist_website}
placeholder={getLangText('The artist\'s website if present...')}/> placeholder={getLangText('The artist\'s website if present...')}/>
</Property> </Property>
<Property <Property
name='gallery_website' name='gallery_website'
label={getLangText('Website of related Gallery, Museum, etc.')} label={getLangText('Website of related Gallery, Museum, etc.')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.gallery_website} defaultValue={this.props.piece.extra_data.gallery_website}
placeholder={getLangText('The website of any related Gallery or Museum')}/> placeholder={getLangText('The website of any related Gallery or Museum')}/>
</Property> </Property>
<Property <Property
name='additional_websites' name='additional_websites'
label={getLangText('Additional Websites/Publications')} label={getLangText('Additional Websites/Publications')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.additional_websites} defaultValue={this.props.piece.extra_data.additional_websites}
placeholder={getLangText('Enter additional Websites/Publications if any')}/> placeholder={getLangText('Enter additional Websites/Publications if any')}/>
</Property> </Property>
<Property <Property
name='conceptual_overview' name='conceptual_overview'
label={getLangText('Short text about the Artist')} label={getLangText('Short text about the Artist')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.conceptual_overview} defaultValue={this.props.piece.extra_data.conceptual_overview}
placeholder={getLangText('Enter a short bio about the Artist')} placeholder={getLangText('Enter a short bio about the Artist')}
/> />

View File

@ -89,61 +89,49 @@ let IkonotvArtworkDetailsForm = React.createClass({
</div> </div>
<Property <Property
name='medium' name='medium'
label={getLangText('Medium')} label={getLangText('Medium')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.medium} defaultValue={this.props.piece.extra_data.medium}
placeholder={getLangText('The medium of the file (i.e. photo, video, other, ...)')}/> placeholder={getLangText('The medium of the file (i.e. photo, video, other, ...)')}/>
</Property> </Property>
<Property <Property
name='size_duration' name='size_duration'
label={getLangText('Size/Duration')} label={getLangText('Size/Duration')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.size_duration} defaultValue={this.props.piece.extra_data.size_duration}
placeholder={getLangText('The size of the file in MB or the duration of the movie')}/> placeholder={getLangText('The size of the file in MB or the duration of the movie')}/>
</Property> </Property>
<Property <Property
name='copyright' name='copyright'
label={getLangText('Copyright')} label={getLangText('Copyright')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.copyright} defaultValue={this.props.piece.extra_data.copyright}
placeholder={getLangText('Which copyright is attached to this work?')}/> placeholder={getLangText('Which copyright is attached to this work?')}/>
</Property> </Property>
<Property <Property
name='courtesy_of' name='courtesy_of'
label={getLangText('Courtesy of')} label={getLangText('Courtesy of')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.courtesy_of} defaultValue={this.props.piece.extra_data.courtesy_of}
placeholder={getLangText('The current owner of the artwork')}/> placeholder={getLangText('The current owner of the artwork')}/>
</Property> </Property>
<Property <Property
name='copyright_of_photography' name='copyright_of_photography'
label={getLangText('Copyright of Photography')} label={getLangText('Copyright of Photography')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.copyright_of_photography} defaultValue={this.props.piece.extra_data.copyright_of_photography}
placeholder={getLangText('Who should be attributed for the photography?')}/> placeholder={getLangText('Who should be attributed for the photography?')}/>
</Property> </Property>
<Property <Property
name='additional_details' name='additional_details'
label={getLangText('Additional Details about the artwork')} label={getLangText('Additional Details about the artwork')}>
editable={!this.props.disabled}>
<InputTextAreaToggable <InputTextAreaToggable
rows={1} rows={1}
editable={!this.props.disabled}
defaultValue={this.props.piece.extra_data.additional_details} defaultValue={this.props.piece.extra_data.additional_details}
placeholder={getLangText('Insert artwork overview')}/> placeholder={getLangText('Insert artwork overview')}/>
</Property> </Property>