mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Small fixes for components using pieces and editions
This commit is contained in:
parent
3e67e2d2ee
commit
7a53d539a6
@ -90,7 +90,7 @@ let EditionContainer = React.createClass({
|
|||||||
const { edition, currentUser, coaMeta } = this.state;
|
const { edition, currentUser, coaMeta } = this.state;
|
||||||
const { actionPanelButtonListType, furtherDetailsType } = this.props;
|
const { actionPanelButtonListType, furtherDetailsType } = this.props;
|
||||||
|
|
||||||
if (Object.keys(edition).length && edition.id) {
|
if (edition.id) {
|
||||||
setDocumentTitle([edition.artist_name, edition.title].join(', '));
|
setDocumentTitle([edition.artist_name, edition.title].join(', '));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -19,11 +19,12 @@ import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uplo
|
|||||||
|
|
||||||
let FurtherDetails = React.createClass({
|
let FurtherDetails = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
pieceId: React.PropTypes.number.isRequired,
|
||||||
|
|
||||||
editable: React.PropTypes.bool,
|
editable: React.PropTypes.bool,
|
||||||
pieceId: React.PropTypes.number,
|
|
||||||
extraData: React.PropTypes.object,
|
extraData: React.PropTypes.object,
|
||||||
|
handleSuccess: React.PropTypes.func,
|
||||||
otherData: React.PropTypes.arrayOf(React.PropTypes.object),
|
otherData: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||||
handleSuccess: React.PropTypes.func
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -32,13 +33,16 @@ let FurtherDetails = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification(){
|
showNotification() {
|
||||||
this.props.handleSuccess();
|
if (typeof this.props.handleSucess === 'function') {
|
||||||
let notification = new GlobalNotificationModel('Details updated', 'success');
|
this.props.handleSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
const notification = new GlobalNotificationModel('Details updated', 'success');
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
},
|
},
|
||||||
|
|
||||||
submitFile(file){
|
submitFile(file) {
|
||||||
this.setState({
|
this.setState({
|
||||||
otherDataKey: file.key
|
otherDataKey: file.key
|
||||||
});
|
});
|
||||||
@ -60,8 +64,7 @@ let FurtherDetails = React.createClass({
|
|||||||
handleSuccess={this.showNotification}
|
handleSuccess={this.showNotification}
|
||||||
editable={this.props.editable}
|
editable={this.props.editable}
|
||||||
pieceId={this.props.pieceId}
|
pieceId={this.props.pieceId}
|
||||||
extraData={this.props.extraData}
|
extraData={this.props.extraData} />
|
||||||
/>
|
|
||||||
<PieceExtraDataForm
|
<PieceExtraDataForm
|
||||||
name='display_instructions'
|
name='display_instructions'
|
||||||
title='Display Instructions'
|
title='Display Instructions'
|
||||||
|
@ -13,43 +13,46 @@ import InputTextAreaToggable from './input_textarea_toggable';
|
|||||||
|
|
||||||
let PieceExtraDataForm = React.createClass({
|
let PieceExtraDataForm = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
pieceId: React.PropTypes.number,
|
name: React.PropTypes.string.isRequired,
|
||||||
|
pieceId: React.PropTypes.number.isRequired,
|
||||||
|
|
||||||
|
editable: React.PropTypes.bool,
|
||||||
extraData: React.PropTypes.object,
|
extraData: React.PropTypes.object,
|
||||||
handleSuccess: React.PropTypes.func,
|
handleSuccess: React.PropTypes.func,
|
||||||
name: React.PropTypes.string,
|
title: React.PropTypes.string
|
||||||
title: React.PropTypes.string,
|
|
||||||
editable: React.PropTypes.bool
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getFormData() {
|
getFormData() {
|
||||||
let extradata = {};
|
|
||||||
extradata[this.props.name] = this.refs.form.refs[this.props.name].state.value;
|
|
||||||
return {
|
return {
|
||||||
extradata: extradata,
|
extradata: {
|
||||||
|
[this.props.name]: this.refs.form.refs[this.props.name].state.value
|
||||||
|
},
|
||||||
piece_id: this.props.pieceId
|
piece_id: this.props.pieceId
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let defaultValue = this.props.extraData[this.props.name] || '';
|
const { editable, extraData, handleSuccess, name, pieceId, title } = this.props;
|
||||||
if (defaultValue.length === 0 && !this.props.editable){
|
const defaultValue = (extraData && extraData[name]) || null;
|
||||||
|
|
||||||
|
if (!defaultValue && !editable) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let url = requests.prepareUrl(ApiUrls.piece_extradata, {piece_id: this.props.pieceId});
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
ref='form'
|
ref='form'
|
||||||
url={url}
|
url={requests.prepareUrl(ApiUrls.piece_extradata, { piece_id: pieceId })}
|
||||||
handleSuccess={this.props.handleSuccess}
|
handleSuccess={handleSuccess}
|
||||||
getFormData={this.getFormData}
|
getFormData={this.getFormData}
|
||||||
disabled={!this.props.editable}>
|
disabled={!editable}>
|
||||||
<Property
|
<Property
|
||||||
name={this.props.name}
|
name={name}
|
||||||
label={this.props.title}>
|
label={title}>
|
||||||
<InputTextAreaToggable
|
<InputTextAreaToggable
|
||||||
rows={1}
|
rows={1}
|
||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
placeholder={getLangText('Fill in%s', ' ') + this.props.title}
|
placeholder={getLangText('Fill in%s', ' ') + title}
|
||||||
required />
|
required />
|
||||||
</Property>
|
</Property>
|
||||||
<hr />
|
<hr />
|
||||||
|
@ -126,7 +126,7 @@ let MarketSubmitButton = React.createClass({
|
|||||||
aclName='acl_consign'>
|
aclName='acl_consign'>
|
||||||
<ModalWrapper
|
<ModalWrapper
|
||||||
trigger={triggerButton}
|
trigger={triggerButton}
|
||||||
handleSuccess={this.handleAdditionalDataSuccess.bind(this, solePieceId)}
|
handleSuccess={() => this.handleAdditionalDataSuccess(solePieceId)}
|
||||||
title={getLangText('Add additional information')}>
|
title={getLangText('Add additional information')}>
|
||||||
<MarketAdditionalDataForm
|
<MarketAdditionalDataForm
|
||||||
pieceId={solePieceId}
|
pieceId={solePieceId}
|
||||||
|
Loading…
Reference in New Issue
Block a user