1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-14 21:10:27 +01:00

Merge pull request #43 from ascribe/AD-1149-fix-comments-in-pr

Ad 1149 fix comments in pr
This commit is contained in:
Brett Sun 2015-12-02 14:22:25 +01:00
commit 8f14b27eac
15 changed files with 56 additions and 143 deletions

View File

@ -10,6 +10,8 @@ import ApiUrls from '../../constants/api_urls';
import AppConstants from '../../constants/application_constants'; import AppConstants from '../../constants/application_constants';
import { getCookie } from '../../utils/fetch_api_utils'; import { getCookie } from '../../utils/fetch_api_utils';
import { getLangText } from '../../utils/lang_utils';
let FurtherDetailsFileuploader = React.createClass({ let FurtherDetailsFileuploader = React.createClass({
propTypes: { propTypes: {
@ -26,7 +28,7 @@ let FurtherDetailsFileuploader = React.createClass({
getDefaultProps() { getDefaultProps() {
return { return {
label: 'Additional files', label: getLangText('Additional files'),
multiple: false multiple: false
}; };
}, },

View File

@ -26,7 +26,6 @@ let RegisterPieceForm = React.createClass({
isFineUploaderActive: React.PropTypes.bool, isFineUploaderActive: React.PropTypes.bool,
isFineUploaderEditable: React.PropTypes.bool, isFineUploaderEditable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool, enableLocalHashing: React.PropTypes.bool,
onLoggedOut: React.PropTypes.func,
// For this form to work with SlideContainer, we sometimes have to disable it // For this form to work with SlideContainer, we sometimes have to disable it
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
@ -116,7 +115,6 @@ let RegisterPieceForm = React.createClass({
setIsUploadReady={this.setIsUploadReady} setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile} isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile}
isFineUploaderActive={this.props.isFineUploaderActive} isFineUploaderActive={this.props.isFineUploaderActive}
onLoggedOut={this.props.onLoggedOut}
disabled={!this.props.isFineUploaderEditable} disabled={!this.props.isFineUploaderEditable}
enableLocalHashing={enableLocalHashing} enableLocalHashing={enableLocalHashing}
uploadMethod={this.props.location.query.method} /> uploadMethod={this.props.location.query.method} />

View File

@ -38,7 +38,6 @@ const InputFineUploader = React.createClass({
// a user is actually not logged in already to prevent him from droping files // a user is actually not logged in already to prevent him from droping files
// before login in // before login in
isFineUploaderActive: bool, isFineUploaderActive: bool,
onLoggedOut: func,
enableLocalHashing: bool, enableLocalHashing: bool,
uploadMethod: string, uploadMethod: string,
@ -51,7 +50,10 @@ const InputFineUploader = React.createClass({
fileClassToUpload: shape({ fileClassToUpload: shape({
singular: string, singular: string,
plural: string plural: string
}) }),
// Provided by `Property`
onChange: React.PropTypes.func
}, },
getDefaultProps() { getDefaultProps() {
@ -101,16 +103,16 @@ const InputFineUploader = React.createClass({
setIsUploadReady, setIsUploadReady,
isReadyForFormSubmission, isReadyForFormSubmission,
areAssetsDownloadable, areAssetsDownloadable,
onLoggedOut,
enableLocalHashing, enableLocalHashing,
uploadMethod,
fileClassToUpload, fileClassToUpload,
location } = this.props; disabled } = this.props;
let editable = this.props.isFineUploaderActive; let editable = this.props.isFineUploaderActive;
// if disabled is actually set by property, we want to override // if disabled is actually set by property, we want to override
// isFineUploaderActive // isFineUploaderActive
if(typeof this.props.disabled !== 'undefined') { if(typeof disabled !== 'undefined') {
editable = !this.props.disabled; editable = !disabled;
} }
return ( return (
@ -139,10 +141,9 @@ const InputFineUploader = React.createClass({
'X-CSRFToken': getCookie(AppConstants.csrftoken) 'X-CSRFToken': getCookie(AppConstants.csrftoken)
} }
}} }}
onInactive={this.props.onLoggedOut} enableLocalHashing={enableLocalHashing}
enableLocalHashing={this.props.enableLocalHashing} uploadMethod={uploadMethod}
uploadMethod={this.props.uploadMethod} fileClassToUpload={fileClassToUpload} />
fileClassToUpload={this.props.fileClassToUpload} />
); );
} }
}); });

View File

@ -15,7 +15,6 @@ let FileDragAndDrop = React.createClass({
className: React.PropTypes.string, className: React.PropTypes.string,
onDrop: React.PropTypes.func.isRequired, onDrop: React.PropTypes.func.isRequired,
onDragOver: React.PropTypes.func, onDragOver: React.PropTypes.func,
onInactive: React.PropTypes.func,
filesToUpload: React.PropTypes.array, filesToUpload: React.PropTypes.array,
handleDeleteFile: React.PropTypes.func, handleDeleteFile: React.PropTypes.func,
handleCancelFile: React.PropTypes.func, handleCancelFile: React.PropTypes.func,
@ -60,28 +59,21 @@ let FileDragAndDrop = React.createClass({
handleDrop(event) { handleDrop(event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
let files;
if(this.props.dropzoneInactive) { if (!this.props.dropzoneInactive) {
// if there is a handle function for doing stuff let files;
// when the dropzone is inactive, then call it
if(this.props.onInactive) { // handle Drag and Drop
this.props.onInactive(); if(event.dataTransfer && event.dataTransfer.files.length > 0) {
files = event.dataTransfer.files;
} else if(event.target.files) { // handle input type file
files = event.target.files;
} }
return;
}
// handle Drag and Drop if(typeof this.props.onDrop === 'function' && files) {
if(event.dataTransfer && event.dataTransfer.files.length > 0) { this.props.onDrop(files);
files = event.dataTransfer.files; }
} else if(event.target.files) { // handle input type file
files = event.target.files;
} }
if(typeof this.props.onDrop === 'function' && files) {
this.props.onDrop(files);
}
}, },
handleDeleteFile(fileId) { handleDeleteFile(fileId) {
@ -113,31 +105,25 @@ let FileDragAndDrop = React.createClass({
}, },
handleOnClick() { handleOnClick() {
let evt; // do not propagate event if the drop zone's inactive,
// when multiple is set to false and the user already uploaded a piece, // for example when multiple is set to false and the user already uploaded a piece
// do not propagate event if (!this.props.dropzoneInactive) {
if(this.props.dropzoneInactive) { let evt;
// if there is a handle function for doing stuff
// when the dropzone is inactive, then call it try {
if(this.props.onInactive) { evt = new MouseEvent('click', {
this.props.onInactive(); view: window,
bubbles: true,
cancelable: true
});
} catch(e) {
// For browsers that do not support the new MouseEvent syntax
evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
} }
return;
}
try { this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
evt = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true
});
} catch(e) {
// For browsers that do not support the new MouseEvent syntax
evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
} }
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
}, },
render: function () { render: function () {

View File

@ -99,7 +99,6 @@ let ReactS3FineUploader = React.createClass({
areAssetsDownloadable: React.PropTypes.bool, areAssetsDownloadable: React.PropTypes.bool,
areAssetsEditable: React.PropTypes.bool, areAssetsEditable: React.PropTypes.bool,
defaultErrorMessage: React.PropTypes.string, defaultErrorMessage: React.PropTypes.string,
onInactive: React.PropTypes.func,
// We encountered some cases where people had difficulties to upload their // We encountered some cases where people had difficulties to upload their
// works to ascribe due to a slow internet connection. // works to ascribe due to a slow internet connection.
@ -891,7 +890,6 @@ let ReactS3FineUploader = React.createClass({
multiple, multiple,
areAssetsDownloadable, areAssetsDownloadable,
areAssetsEditable, areAssetsEditable,
onInactive,
enableLocalHashing, enableLocalHashing,
fileClassToUpload, fileClassToUpload,
fileInputElement: FileInputElement, fileInputElement: FileInputElement,
@ -901,7 +899,6 @@ let ReactS3FineUploader = React.createClass({
multiple, multiple,
areAssetsDownloadable, areAssetsDownloadable,
areAssetsEditable, areAssetsEditable,
onInactive,
enableLocalHashing, enableLocalHashing,
uploadMethod, uploadMethod,
fileClassToUpload, fileClassToUpload,

View File

@ -133,7 +133,7 @@ let PieceList = React.createClass({
const defaultFilterBy = {}; const defaultFilterBy = {};
if (filterParams && typeof filterParams.forEach === 'function') { if (filterParams && typeof filterParams.forEach === 'function') {
filterParams.forEach(({ label, items }) => { filterParams.forEach(({ items }) => {
items.forEach((item) => { items.forEach((item) => {
if (typeof item === 'object' && item.defaultValue) { if (typeof item === 'object' && item.defaultValue) {
defaultFilterBy[item.key] = true; defaultFilterBy[item.key] = true;
@ -211,7 +211,7 @@ let PieceList = React.createClass({
}, },
loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) { loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) {
let orderBy = this.state.orderBy ? this.state.orderBy : this.props.orderBy; const orderBy = this.state.orderBy || this.props.orderBy;
return PieceListActions.fetchPieceList(page, this.state.pageSize, search, return PieceListActions.fetchPieceList(page, this.state.pageSize, search,
orderBy, this.state.orderAsc, filterBy); orderBy, this.state.orderAsc, filterBy);
@ -259,7 +259,6 @@ let PieceList = React.createClass({
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view'); const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
setDocumentTitle(getLangText('Collection')); setDocumentTitle(getLangText('Collection'));
return ( return (
<div> <div>
<PieceListToolbar <PieceListToolbar

View File

@ -97,12 +97,12 @@ let PieceListFilterDisplay = React.createClass({
render() { render() {
let { filterBy } = this.props; let { filterBy } = this.props;
let filtersWithLabel = this.transformFilterParamsItemsToBools();
// do not show the FilterDisplay if there are no filters applied // do not show the FilterDisplay if there are no filters applied
if(filterBy && Object.keys(filterBy).length === 0) { if(filterBy && Object.keys(filterBy).length === 0) {
return null; return null;
} else { } else {
const filtersWithLabel = this.transformFilterParamsItemsToBools();
return ( return (
<div className="row"> <div className="row">
<div className="ascribe-piece-list-filter-display col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2"> <div className="ascribe-piece-list-filter-display col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2">

View File

@ -45,10 +45,7 @@ let RegisterPiece = React.createClass( {
UserStore.getState(), UserStore.getState(),
WhitelabelStore.getState(), WhitelabelStore.getState(),
PieceListStore.getState(), PieceListStore.getState(),
{ );
selectedLicense: 0,
isFineUploaderActive: false
});
}, },
componentDidMount() { componentDidMount() {
@ -66,13 +63,6 @@ let RegisterPiece = React.createClass( {
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
}, },
handleSuccess(response){ handleSuccess(response){
@ -117,7 +107,7 @@ let RegisterPiece = React.createClass( {
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}> <Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm <RegisterPieceForm
{...this.props} {...this.props}
isFineUploaderActive={this.state.isFineUploaderActive} isFineUploaderActive={true}
handleSuccess={this.handleSuccess} handleSuccess={this.handleSuccess}
location={this.props.location}> location={this.props.location}>
{this.props.children} {this.props.children}

View File

@ -53,8 +53,6 @@ let CylandRegisterPiece = React.createClass({
PieceStore.getState(), PieceStore.getState(),
WhitelabelStore.getState(), WhitelabelStore.getState(),
{ {
selectedLicense: 0,
isFineUploaderActive: false,
step: 0 step: 0
}); });
}, },
@ -90,13 +88,6 @@ let CylandRegisterPiece = React.createClass({
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
}, },
handleRegisterSuccess(response){ handleRegisterSuccess(response){
@ -167,11 +158,6 @@ let CylandRegisterPiece = React.createClass({
} }
}, },
// basically redirects to the second slide (index: 1), when the user is not logged in
onLoggedOut() {
this.history.pushState(null, '/login');
},
render() { render() {
let today = new Moment(); let today = new Moment();
@ -197,9 +183,8 @@ let CylandRegisterPiece = React.createClass({
enableLocalHashing={false} enableLocalHashing={false}
headerMessage={getLangText('Submit to Cyland Archive')} headerMessage={getLangText('Submit to Cyland Archive')}
submitMessage={getLangText('Submit')} submitMessage={getLangText('Submit')}
isFineUploaderActive={this.state.isFineUploaderActive} isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess} handleSuccess={this.handleRegisterSuccess}
onLoggedOut={this.onLoggedOut}
location={this.props.location}/> location={this.props.location}/>
</Col> </Col>
</Row> </Row>

View File

@ -85,13 +85,6 @@ let IkonotvRegisterPiece = React.createClass({
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
}, },
@ -157,19 +150,6 @@ let IkonotvRegisterPiece = React.createClass({
); );
}, },
changeSlide() {
// only transition to the login store, if user is not logged in
// ergo the currentUser object is not properly defined
if(this.state.currentUser && !this.state.currentUser.email) {
this.onLoggedOut();
}
},
// basically redirects to the second slide (index: 1), when the user is not logged in
onLoggedOut() {
this.history.pushState(null, '/login');
},
canSubmit() { canSubmit() {
let currentUser = this.state.currentUser; let currentUser = this.state.currentUser;
return currentUser && currentUser.acl && currentUser.acl.acl_wallet_submit; return currentUser && currentUser.acl && currentUser.acl.acl_wallet_submit;
@ -260,9 +240,8 @@ let IkonotvRegisterPiece = React.createClass({
enableLocalHashing={false} enableLocalHashing={false}
headerMessage={getLangText('Register work')} headerMessage={getLangText('Register work')}
submitMessage={getLangText('Register')} submitMessage={getLangText('Register')}
isFineUploaderActive={this.state.isFineUploaderActive} isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess} handleSuccess={this.handleRegisterSuccess}
onLoggedOut={this.onLoggedOut}
location={this.props.location}/> location={this.props.location}/>
</Col> </Col>
</Row> </Row>

View File

@ -53,8 +53,8 @@ let MarketSubmitButton = React.createClass({
const { extra_data, other_data } = edition; const { extra_data, other_data } = edition;
if (extra_data.artist_bio && extra_data.work_description && if (extra_data.artist_bio && extra_data.work_description &&
extra_data.technology_details && extra_data.display_instructions && extra_data.technology_details && extra_data.display_instructions &&
other_data.length > 0) { other_data.length > 0) {
return true; return true;
} }
} }

View File

@ -8,6 +8,7 @@ import Property from '../../../../../ascribe_forms/property';
import InputTextAreaToggable from '../../../../../ascribe_forms/input_textarea_toggable'; import InputTextAreaToggable from '../../../../../ascribe_forms/input_textarea_toggable';
import FurtherDetailsFileuploader from '../../../../../ascribe_detail/further_details_fileuploader'; import FurtherDetailsFileuploader from '../../../../../ascribe_detail/further_details_fileuploader';
import AscribeSpinner from '../../../../../ascribe_spinner';
import GlobalNotificationModel from '../../../../../../models/global_notification_model'; import GlobalNotificationModel from '../../../../../../models/global_notification_model';
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions'; import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
@ -24,6 +25,7 @@ import requests from '../../../../../../utils/requests';
import { mergeOptions } from '../../../../../../utils/general_utils'; import { mergeOptions } from '../../../../../../utils/general_utils';
import { getLangText } from '../../../../../../utils/lang_utils'; import { getLangText } from '../../../../../../utils/lang_utils';
let MarketAdditionalDataForm = React.createClass({ let MarketAdditionalDataForm = React.createClass({
propTypes: { propTypes: {
pieceId: React.PropTypes.oneOfType([ pieceId: React.PropTypes.oneOfType([
@ -96,7 +98,7 @@ let MarketAdditionalDataForm = React.createClass({
}, },
isUploadReadyOnChange(piece) { isUploadReadyOnChange(piece) {
return piece && piece.other_data && piece.other_data.length > 0 ? true : false; return piece && piece.other_data && piece.other_data.length > 0;
}, },
handleSuccessWithNotification() { handleSuccessWithNotification() {
@ -211,7 +213,7 @@ let MarketAdditionalDataForm = React.createClass({
} else { } else {
return ( return (
<div className="ascribe-loading-position"> <div className="ascribe-loading-position">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} /> <AscribeSpinner color='dark-blue' size='lg' />
</div> </div>
); );
} }

View File

@ -50,7 +50,7 @@ let MarketPieceList = React.createClass({
render() { render() {
const { currentUser, whitelabel } = this.state; const { currentUser, whitelabel } = this.state;
let filterParams = undefined; let filterParams = null;
let canLoadPieceList = false; let canLoadPieceList = false;
if (currentUser.email && whitelabel.user) { if (currentUser.email && whitelabel.user) {

View File

@ -35,8 +35,6 @@ let MarketRegisterPiece = React.createClass({
UserStore.getState(), UserStore.getState(),
PieceListStore.getState(), PieceListStore.getState(),
{ {
selectedLicense: 0,
isFineUploaderActive: false,
step: 0 step: 0
}); });
}, },
@ -58,13 +56,6 @@ let MarketRegisterPiece = React.createClass({
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
if (this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
}, },
handleRegisterSuccess(response) { handleRegisterSuccess(response) {
@ -115,11 +106,6 @@ let MarketRegisterPiece = React.createClass({
); );
}, },
// basically redirects to the second slide (index: 1), when the user is not logged in
onLoggedOut() {
this.history.pushState(null, '/login');
},
render() { render() {
setDocumentTitle(getLangText('Register a new piece')); setDocumentTitle(getLangText('Register a new piece'));
@ -140,9 +126,8 @@ let MarketRegisterPiece = React.createClass({
enableLocalHashing={false} enableLocalHashing={false}
headerMessage={getLangText('Consign to Market')} headerMessage={getLangText('Consign to Market')}
submitMessage={getLangText('Proceed to additional details')} submitMessage={getLangText('Proceed to additional details')}
isFineUploaderActive={this.state.isFineUploaderActive} isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess} handleSuccess={this.handleRegisterSuccess}
onLoggedOut={this.onLoggedOut}
location={this.props.location}> location={this.props.location}>
<Property <Property
name="num_editions" name="num_editions"

View File

@ -228,16 +228,6 @@ let ROUTES = {
) )
}; };
function getRoutes(commonRoutes, subdomain) {
if(subdomain in ROUTES) {
return ROUTES[subdomain];
} else {
throw new Error('Subdomain wasn\'t specified in the wallet app.');
}
};
function getRoutes(commonRoutes, subdomain) { function getRoutes(commonRoutes, subdomain) {
if(subdomain in ROUTES) { if(subdomain in ROUTES) {
return ROUTES[subdomain]; return ROUTES[subdomain];
@ -246,5 +236,4 @@ function getRoutes(commonRoutes, subdomain) {
} }
} }
export default getRoutes; export default getRoutes;