mirror of
https://github.com/ascribe/onion.git
synced 2024-06-30 05:31:58 +02:00
loan request with moment
shortlist on accordeonlist OK
This commit is contained in:
parent
bcd6400a78
commit
ab97fa420c
|
@ -8,7 +8,8 @@ class OwnershipActions {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.generateActions(
|
this.generateActions(
|
||||||
'updateLoanPieceRequestList',
|
'updateLoanPieceRequestList',
|
||||||
'updateLoanPieceRequest'
|
'updateLoanPieceRequest',
|
||||||
|
'flushLoanPieceRequest'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +27,10 @@ class OwnershipActions {
|
||||||
fetchLoanRequest(pieceId) {
|
fetchLoanRequest(pieceId) {
|
||||||
OwnershipFetcher.fetchLoanPieceRequestList()
|
OwnershipFetcher.fetchLoanPieceRequestList()
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
let loanRequests = data.loan_requests;
|
this.actions.updateLoanPieceRequest({loanRequests: data.loan_requests, pieceId: pieceId});
|
||||||
this.actions.updateLoanPieceRequest({loanRequests, pieceId});
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.logGlobal(err);
|
console.logGlobal(err);
|
||||||
this.actions.flushLoanPieceRequest();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import Moment from 'moment';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
|
@ -66,8 +66,10 @@ let LoanRequestAnswerForm = React.createClass({
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.state.loanRequest)
|
|
||||||
if (this.state.loanRequest) {
|
if (this.state.loanRequest) {
|
||||||
|
let startDate = new Moment(this.state.loanRequest.datetime_from, Moment.ISO_8601),
|
||||||
|
endDate = new Moment(this.state.loanRequest.datetime_to, Moment.ISO_8601);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoanForm
|
<LoanForm
|
||||||
loanHeading={null}
|
loanHeading={null}
|
||||||
|
@ -76,6 +78,8 @@ let LoanRequestAnswerForm = React.createClass({
|
||||||
url={this.props.url}
|
url={this.props.url}
|
||||||
email={this.state.loanRequest.new_owner}
|
email={this.state.loanRequest.new_owner}
|
||||||
gallery={this.state.loanRequest.gallery}
|
gallery={this.state.loanRequest.gallery}
|
||||||
|
startdate={startDate}
|
||||||
|
enddate={endDate}
|
||||||
showPassword={true}
|
showPassword={true}
|
||||||
showPersonalMessage={false}
|
showPersonalMessage={false}
|
||||||
handleSuccess={this.handleLoanSuccess}/>
|
handleSuccess={this.handleLoanSuccess}/>
|
||||||
|
|
|
@ -28,7 +28,8 @@ let PieceList = React.createClass({
|
||||||
redirectTo: React.PropTypes.string,
|
redirectTo: React.PropTypes.string,
|
||||||
customSubmitButton: React.PropTypes.element,
|
customSubmitButton: React.PropTypes.element,
|
||||||
filterParams: React.PropTypes.array,
|
filterParams: React.PropTypes.array,
|
||||||
orderParams: React.PropTypes.array
|
orderParams: React.PropTypes.array,
|
||||||
|
orderBy: React.PropTypes.string
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -59,10 +60,10 @@ let PieceList = React.createClass({
|
||||||
|
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
EditionListStore.listen(this.onChange);
|
EditionListStore.listen(this.onChange);
|
||||||
|
let orderBy = this.props.orderBy ? this.props.orderBy : this.state.orderBy;
|
||||||
if (this.state.pieceList.length === 0 || this.state.page !== page){
|
if (this.state.pieceList.length === 0 || this.state.page !== page){
|
||||||
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search,
|
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search,
|
||||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy)
|
orderBy, this.state.orderAsc, this.state.filterBy)
|
||||||
.then(() => PieceListActions.fetchPieceRequestActions());
|
.then(() => PieceListActions.fetchPieceRequestActions());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -115,7 +115,11 @@ let AccordionListItemPrize = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// participant
|
return this.getPrizeButtonsParticipant();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getPrizeButtonsParticipant() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AclProxy
|
<AclProxy
|
||||||
|
@ -130,6 +134,16 @@ let AccordionListItemPrize = React.createClass({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleShortlistSuccess(message){
|
||||||
|
let notification = new GlobalNotificationModel(message, 'success', 2000);
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshPieceData() {
|
||||||
|
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||||
|
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||||
|
},
|
||||||
|
|
||||||
getPrizeBadge(){
|
getPrizeBadge(){
|
||||||
if (this.state.currentUser && this.state.currentUser.is_judge) {
|
if (this.state.currentUser && this.state.currentUser.is_judge) {
|
||||||
return (
|
return (
|
||||||
|
@ -137,10 +151,18 @@ let AccordionListItemPrize = React.createClass({
|
||||||
<InputCheckbox
|
<InputCheckbox
|
||||||
defaultChecked={this.props.content.selected}
|
defaultChecked={this.props.content.selected}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
PrizeRatingActions.toggleShortlist(this.props.content.id).then(
|
PrizeRatingActions.toggleShortlist(this.props.content.id)
|
||||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
.then(
|
||||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy)
|
(res) => {
|
||||||
); }}/>
|
this.refreshPieceData();
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
(res) => {
|
||||||
|
this.handleShortlistSuccess(res.notification);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}}/>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,6 +264,7 @@ let PrizePieceRatings = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
handleLoanRequestSuccess(){},
|
handleLoanRequestSuccess(){},
|
||||||
|
|
||||||
handleShortlistSuccess(message){
|
handleShortlistSuccess(message){
|
||||||
let notification = new GlobalNotificationModel(message, 'success', 2000);
|
let notification = new GlobalNotificationModel(message, 'success', 2000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
|
|
@ -40,13 +40,16 @@ let PrizePieceList = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getButtonSubmit() {
|
getButtonSubmit() {
|
||||||
if (this.state.prize && this.state.prize.active){
|
if (this.state.prize && this.state.prize.active && !this.state.currentUser.is_jury){
|
||||||
return (
|
return (
|
||||||
<ButtonLink to="register_piece">
|
<ButtonLink to="register_piece">
|
||||||
{getLangText('Submit to prize')}
|
{getLangText('Submit to prize')}
|
||||||
</ButtonLink>
|
</ButtonLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else if (this.state.prize && this.state.currentUser.is_judge){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -54,9 +57,11 @@ let PrizePieceList = React.createClass({
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PieceList
|
<PieceList
|
||||||
|
ref="list"
|
||||||
redirectTo="register_piece"
|
redirectTo="register_piece"
|
||||||
accordionListItemType={AccordionListItemPrize}
|
accordionListItemType={AccordionListItemPrize}
|
||||||
orderParams={this.state.currentUser.is_jury ? ['rating', 'title'] : ['artist_name', 'title']}
|
orderParams={this.state.currentUser.is_jury ? ['rating', 'title'] : ['artist_name', 'title']}
|
||||||
|
orderBy={this.state.currentUser.is_jury ? 'rating' : null}
|
||||||
filterParams={null}
|
filterParams={null}
|
||||||
customSubmitButton={this.getButtonSubmit()}/>
|
customSubmitButton={this.getButtonSubmit()}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@ class OwnershipStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flushLoanPieceRequest(){
|
onFlushLoanPieceRequest(){
|
||||||
this.loanRequestList = [];
|
this.loanRequestList = [];
|
||||||
this.loanRequest = null;
|
this.loanRequest = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user