1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00

Merge branch 'AD-1149-additional-details' of github.com:ascribe/onion into AD-1149-additional-details

This commit is contained in:
Tim Daubenschütz 2015-12-03 21:30:48 +01:00
commit 5a05a029b7
6 changed files with 79 additions and 33 deletions

View File

@ -189,14 +189,13 @@ let PieceList = React.createClass({
this.state.pieceList this.state.pieceList
.forEach((piece) => { .forEach((piece) => {
// but only if they're actually open // but only if they're actually open
const isEditionListOpenForPiece = this.state.isEditionListOpenForPieceId[piece.id]; if(this.state.isEditionListOpenForPieceId[piece.id].show) {
if (isEditionListOpenForPiece && isEditionListOpenForPiece.show) {
EditionListActions.refreshEditionList({ EditionListActions.refreshEditionList({
pieceId: piece.id, pieceId: piece.id,
filterBy filterBy
}); });
} }
}); });
}); });

View File

@ -16,6 +16,9 @@ import UserActions from '../../../../../actions/user_actions';
import PieceStore from '../../../../../stores/piece_store'; import PieceStore from '../../../../../stores/piece_store';
import PieceActions from '../../../../../actions/piece_actions'; import PieceActions from '../../../../../actions/piece_actions';
import WhitelabelActions from '../../../../../actions/whitelabel_actions';
import WhitelabelStore from '../../../../../stores/whitelabel_store';
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';
@ -47,6 +50,7 @@ let IkonotvRegisterPiece = React.createClass({
UserStore.getState(), UserStore.getState(),
PieceListStore.getState(), PieceListStore.getState(),
PieceStore.getState(), PieceStore.getState(),
WhitelabelStore.getState(),
{ {
step: 0, step: 0,
pageExitWarning: getLangText("If you leave this form now, your work will not be loaned to Ikono TV.") pageExitWarning: getLangText("If you leave this form now, your work will not be loaned to Ikono TV.")
@ -57,7 +61,9 @@ let IkonotvRegisterPiece = React.createClass({
PieceListStore.listen(this.onChange); PieceListStore.listen(this.onChange);
UserStore.listen(this.onChange); UserStore.listen(this.onChange);
PieceStore.listen(this.onChange); PieceStore.listen(this.onChange);
WhitelabelStore.listen(this.onChange);
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();
WhitelabelActions.fetchWhitelabel();
// Before we load the new piece, we reset the piece store to delete old data that we do // Before we load the new piece, we reset the piece store to delete old data that we do
// not want to display to the user. // not want to display to the user.
@ -81,6 +87,7 @@ let IkonotvRegisterPiece = React.createClass({
PieceListStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
PieceStore.unlisten(this.onChange); PieceStore.unlisten(this.onChange);
WhitelabelStore.listen(this.onChange);
}, },
onChange(state) { onChange(state) {
@ -152,7 +159,8 @@ let IkonotvRegisterPiece = React.createClass({
canSubmit() { canSubmit() {
let currentUser = this.state.currentUser; let currentUser = this.state.currentUser;
return currentUser && currentUser.acl && currentUser.acl.acl_wallet_submit; let whitelabel = this.state.whitelabel;
return currentUser && currentUser.acl && currentUser.acl.acl_wallet_submit && whitelabel && whitelabel.user;
}, },
getSlideArtistDetails() { getSlideArtistDetails() {
@ -191,20 +199,22 @@ let IkonotvRegisterPiece = React.createClass({
getSlideLoan() { getSlideLoan() {
if (this.canSubmit()) { if (this.canSubmit()) {
const {piece, whitelabel} = this.state;
let today = new Moment(); let today = new Moment();
let endDate = new Moment(); let endDate = new Moment();
endDate.add(2, 'years'); endDate.add(2, 'years');
return ( return (
<div data-slide-title={getLangText('Loan')}> <div data-slide-title={getLangText('Loan')}>
<Row className="no-margin"> <Row className="no-margin">
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}> <Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<LoanForm <LoanForm
loanHeading={getLangText('Loan to IkonoTV archive')} loanHeading={getLangText('Loan to IkonoTV archive')}
id={{piece_id: this.state.piece.id}} id={{piece_id: piece.id}}
url={ApiUrls.ownership_loans_pieces} url={ApiUrls.ownership_loans_pieces}
email="submissions@ikono.org" email={whitelabel.user}
startDate={today} startDate={today}
endDate={endDate} endDate={enddate}
showStartDate={false} showStartDate={false}
showEndDate={false} showEndDate={false}
gallery="IkonoTV archive" gallery="IkonoTV archive"

View File

@ -91,7 +91,7 @@ let MarketSubmitButton = React.createClass({
render() { render() {
const { availableAcls, currentUser, className, editions, handleSuccess } = this.props; const { availableAcls, currentUser, className, editions, handleSuccess } = this.props;
const { whitelabel } = this.state; const { whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state;
const { solePieceId, canSubmit } = this.getAggregateEditionDetails(); const { solePieceId, canSubmit } = this.getAggregateEditionDetails();
const message = getAclFormMessage({ const message = getAclFormMessage({
aclName: 'acl_consign', aclName: 'acl_consign',
@ -103,14 +103,14 @@ let MarketSubmitButton = React.createClass({
const triggerButton = ( const triggerButton = (
<button className={classNames('btn', 'btn-default', 'btn-sm', className)}> <button className={classNames('btn', 'btn-default', 'btn-sm', className)}>
{getLangText('CONSIGN TO %s', whitelabel.name.toUpperCase())} {getLangText('CONSIGN TO %s', whitelabelName.toUpperCase())}
</button> </button>
); );
const consignForm = ( const consignForm = (
<AclFormFactory <AclFormFactory
action='acl_consign' action='acl_consign'
autoFocusProperty='message' autoFocusProperty='message'
email={whitelabel.user} email={whitelabelAdminEmail}
message={message} message={message}
labels={{ labels={{
'message': getLangText('Message (also suggest a sales price if necessary)') 'message': getLangText('Message (also suggest a sales price if necessary)')
@ -149,7 +149,7 @@ let MarketSubmitButton = React.createClass({
<ModalWrapper <ModalWrapper
trigger={triggerButton} trigger={triggerButton}
handleSuccess={handleSuccess} handleSuccess={handleSuccess}
title={getLangText('Consign artwork to %s', whitelabel.name)}> title={getLangText('Consign artwork to %s', whitelabelName)}>
{consignForm} {consignForm}
</ModalWrapper> </ModalWrapper>
</AclProxy> </AclProxy>

View File

@ -49,19 +49,25 @@ let MarketPieceList = React.createClass({
}, },
render() { render() {
const { currentUser, whitelabel } = this.state; const {
currentUser: { email: userEmail },
whitelabel: {
name: whitelabelName = 'Market',
user: whitelabelAdminEmail
} } = this.state;
let filterParams = null; let filterParams = null;
let canLoadPieceList = false; let canLoadPieceList = false;
if (currentUser.email && whitelabel.user) { if (userEmail && whitelabelAdminEmail) {
canLoadPieceList = true; canLoadPieceList = true;
const isUserAdmin = currentUser.email === whitelabel.user; const isUserAdmin = userEmail === whitelabelAdminEmail;
filterParams = [{ filterParams = [{
label: getLangText('Show works I can'), label: getLangText('Show works I can'),
items: [{ items: [{
key: isUserAdmin ? 'acl_transfer' : 'acl_consign', key: isUserAdmin ? 'acl_transfer' : 'acl_consign',
label: getLangText(isUserAdmin ? 'transfer' : 'consign to %s', whitelabel.name), label: getLangText(isUserAdmin ? 'transfer' : 'consign to %s', whitelabelName),
defaultValue: true defaultValue: true
}] }]
}]; }];

View File

@ -11,11 +11,13 @@ import MarketAdditionalDataForm from './market_forms/market_additional_data_form
import Property from '../../../../ascribe_forms/property'; import Property from '../../../../ascribe_forms/property';
import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece'; import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
import PieceActions from '../../../../../actions/piece_actions'; import PieceActions from '../../../../../actions/piece_actions';
import PieceListStore from '../../../../../stores/piece_list_store'; import PieceListStore from '../../../../../stores/piece_list_store';
import PieceListActions from '../../../../../actions/piece_list_actions'; import PieceListActions from '../../../../../actions/piece_list_actions';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
import WhitelabelActions from '../../../../../actions/whitelabel_actions';
import WhitelabelStore from '../../../../../stores/whitelabel_store';
import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
@ -32,8 +34,9 @@ let MarketRegisterPiece = React.createClass({
getInitialState(){ getInitialState(){
return mergeOptions( return mergeOptions(
UserStore.getState(),
PieceListStore.getState(), PieceListStore.getState(),
UserStore.getState(),
WhitelabelStore.getState(),
{ {
step: 0 step: 0
}); });
@ -42,7 +45,10 @@ let MarketRegisterPiece = React.createClass({
componentDidMount() { componentDidMount() {
PieceListStore.listen(this.onChange); PieceListStore.listen(this.onChange);
UserStore.listen(this.onChange); UserStore.listen(this.onChange);
WhitelabelStore.listen(this.onChange);
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();
WhitelabelActions.fetchWhitelabel();
// Reset the piece store to make sure that we don't display old data // Reset the piece store to make sure that we don't display old data
// if the user repeatedly registers works // if the user repeatedly registers works
@ -52,6 +58,7 @@ let MarketRegisterPiece = React.createClass({
componentWillUnmount() { componentWillUnmount() {
PieceListStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
WhitelabelStore.unlisten(this.onChange);
}, },
onChange(state) { onChange(state) {
@ -107,6 +114,13 @@ let MarketRegisterPiece = React.createClass({
}, },
render() { render() {
const {
isFineUploaderActive,
step,
whitelabel: {
name: whitelabelName = 'Market'
} } = this.state;
setDocumentTitle(getLangText('Register a new piece')); setDocumentTitle(getLangText('Register a new piece'));
return ( return (
@ -122,9 +136,9 @@ let MarketRegisterPiece = React.createClass({
<Row className="no-margin"> <Row className="no-margin">
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}> <Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm <RegisterPieceForm
disabled={this.state.step > 0} disabled={step > 0}
enableLocalHashing={false} enableLocalHashing={false}
headerMessage={getLangText('Consign to Market')} headerMessage={getLangText('Consign to %s', whitelabelName)}
submitMessage={getLangText('Proceed to additional details')} submitMessage={getLangText('Proceed to additional details')}
isFineUploaderActive={true} isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess} handleSuccess={this.handleRegisterSuccess}

View File

@ -60,29 +60,46 @@ class EditionListStore {
* We often just have to refresh the edition list for a certain pieceId, * We often just have to refresh the edition list for a certain pieceId,
* this method provides exactly that functionality without any side effects * this method provides exactly that functionality without any side effects
*/ */
onRefreshEditionList({pieceId, filterBy = this.editionList[pieceId].filterBy}) { onRefreshEditionList({pieceId, filterBy = {}}) {
const pieceEditionList = this.editionList[pieceId];
// It may happen that the user enters the site logged in already // It may happen that the user enters the site logged in already
// through /editions // through /editions
// If he then tries to delete a piece/edition and this method is called, // If he then tries to delete a piece/edition and this method is called,
// we'll not be able to refresh his edition list since its not yet there. // we'll not be able to refresh his edition list since its not yet there.
// Therefore we can just return, since there is no data to be refreshed // Therefore we can just return, since there is no data to be refreshed
if (!pieceEditionList) { if(!this.editionList[pieceId]) {
return; return;
} }
let prevEditionListLength = this.editionList[pieceId].length;
let prevEditionListPage = this.editionList[pieceId].page;
let prevEditionListPageSize = this.editionList[pieceId].pageSize;
// we can also refresh the edition list using filterBy,
// if we decide not to do that then the old filter will just be applied.
if(filterBy && Object.keys(filterBy).length <= 0) {
filterBy = this.editionList[pieceId].filterBy;
prevEditionListLength = 10;
prevEditionListPage = 1;
prevEditionListPageSize = 10;
}
// to clear an array, david walsh recommends to just set it's length to zero // to clear an array, david walsh recommends to just set it's length to zero
// http://davidwalsh.name/empty-array // http://davidwalsh.name/empty-array
pieceEditionList.length = 0; this.editionList[pieceId].length = 0;
// refetch editions from the beginning with the previous settings // refetch editions with adjusted page size
EditionsListActions EditionsListActions.fetchEditionList(pieceId, 1, prevEditionListLength,
.fetchEditionList(pieceId, 1, pieceEditionList.pageSize, this.editionList[pieceId].orderBy,
pieceEditionList.orderBy, this.editionList[pieceId].orderAsc,
pieceEditionList.orderAsc,
filterBy) filterBy)
.catch(console.logGlobal); .then(() => {
// reset back to the normal pageSize and page
this.editionList[pieceId].page = prevEditionListPage;
this.editionList[pieceId].pageSize = prevEditionListPageSize;
})
.catch((err) => {
console.logGlobal(err);
});
} }
onSelectEdition({pieceId, editionId, toValue}) { onSelectEdition({pieceId, editionId, toValue}) {