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