1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

notifications on piece details (www, ikono, cyland) and edition details

This commit is contained in:
diminator 2015-09-03 15:17:12 +02:00
parent edcd8e57a4
commit 9334251fd3
10 changed files with 119 additions and 23 deletions

View File

@ -8,7 +8,9 @@ class NotificationActions {
constructor() { constructor() {
this.generateActions( this.generateActions(
'updatePieceListNotifications', 'updatePieceListNotifications',
'updateEditionListNotifications' 'updateEditionListNotifications',
'updateEditionNotifications',
'updatePieceNotifications'
); );
} }
@ -21,6 +23,15 @@ class NotificationActions {
.catch((err) => console.logGlobal(err)); .catch((err) => console.logGlobal(err));
} }
fetchPieceNotifications(pieceId) {
NotificationFetcher
.fetchPieceNotifications(pieceId)
.then((res) => {
this.actions.updatePieceNotifications(res);
})
.catch((err) => console.logGlobal(err));
}
fetchEditionListNotifications() { fetchEditionListNotifications() {
NotificationFetcher NotificationFetcher
.fetchEditionListNotifications() .fetchEditionListNotifications()
@ -29,6 +40,15 @@ class NotificationActions {
}) })
.catch((err) => console.logGlobal(err)); .catch((err) => console.logGlobal(err));
} }
fetchEditionNotifications(editionId) {
NotificationFetcher
.fetchEditionNotifications(editionId)
.then((res) => {
this.actions.updateEditionNotifications(res);
})
.catch((err) => console.logGlobal(err));
}
} }
export default alt.createActions(NotificationActions); export default alt.createActions(NotificationActions);

View File

@ -16,6 +16,9 @@ import PieceListActions from '../../actions/piece_list_actions';
import PieceListStore from '../../stores/piece_list_store'; import PieceListStore from '../../stores/piece_list_store';
import EditionListActions from '../../actions/edition_list_actions'; import EditionListActions from '../../actions/edition_list_actions';
import NotificationActions from '../../actions/notification_actions';
import NotificationStore from '../../stores/notification_store';
import HistoryIterator from './history_iterator'; import HistoryIterator from './history_iterator';
import MediaContainer from './media_container'; import MediaContainer from './media_container';
@ -208,6 +211,25 @@ let EditionSummary = React.createClass({
handleDeleteSuccess: React.PropTypes.func handleDeleteSuccess: React.PropTypes.func
}, },
getInitialState() {
return mergeOptions(
NotificationStore.getState()
);
},
componentDidMount() {
NotificationStore.listen(this.onChange);
NotificationActions.fetchEditionNotifications(this.props.edition.bitcoin_id);
},
componentWillUnmount() {
NotificationStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
getTransferWithdrawData(){ getTransferWithdrawData(){
return {'bitcoin_id': this.props.edition.bitcoin_id}; return {'bitcoin_id': this.props.edition.bitcoin_id};
}, },
@ -234,13 +256,13 @@ let EditionSummary = React.createClass({
getActions(){ getActions(){
let actions = null; let actions = null;
if (this.props.edition.request_action && this.props.edition.request_action.length > 0){ if (this.state.editionNotifications && this.state.editionNotifications.notification){
actions = ( actions = (
<ListRequestActions <ListRequestActions
pieceOrEditions={[this.props.edition]} pieceOrEditions={[this.props.edition]}
currentUser={this.props.currentUser} currentUser={this.props.currentUser}
handleSuccess={this.showNotification} handleSuccess={this.showNotification}
requestActions={this.props.edition.request_action}/>); requestActions={this.state.editionNotifications.notification}/>);
} }
else { else {

View File

@ -9,6 +9,9 @@ import PieceStore from '../../stores/piece_store';
import PieceListActions from '../../actions/piece_list_actions'; import PieceListActions from '../../actions/piece_list_actions';
import PieceListStore from '../../stores/piece_list_store'; import PieceListStore from '../../stores/piece_list_store';
import NotificationActions from '../../actions/notification_actions';
import NotificationStore from '../../stores/notification_store';
import UserActions from '../../actions/user_actions'; import UserActions from '../../actions/user_actions';
import UserStore from '../../stores/user_store'; import UserStore from '../../stores/user_store';
@ -62,6 +65,8 @@ let PieceContainer = React.createClass({
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();
PieceStore.listen(this.onChange); PieceStore.listen(this.onChange);
PieceActions.fetchOne(this.props.params.pieceId); PieceActions.fetchOne(this.props.params.pieceId);
NotificationStore.listen(this.onChange);
NotificationActions.fetchPieceNotifications(this.props.params.pieceId);
}, },
componentWillUnmount() { componentWillUnmount() {
@ -73,6 +78,7 @@ let PieceContainer = React.createClass({
PieceStore.unlisten(this.onChange); PieceStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
PieceListStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange);
NotificationStore.unlisten(this.onChange);
}, },
onChange(state) { onChange(state) {
@ -172,17 +178,16 @@ let PieceContainer = React.createClass({
return {'id': this.state.piece.id}; return {'id': this.state.piece.id};
}, },
getActions(){ getActions() {
if (this.state.piece && if (this.state.piece &&
this.state.piece.request_action && this.state.pieceNotifications &&
this.state.piece.request_action.length > 0) { this.state.pieceNotifications.notification) {
return ( return (
<ListRequestActions <ListRequestActions
pieceOrEditions={this.state.piece} pieceOrEditions={this.state.piece}
currentUser={this.state.currentUser} currentUser={this.state.currentUser}
handleSuccess={this.loadPiece} handleSuccess={this.loadPiece}
requestActions={this.state.piece.request_action}/> requestActions={this.state.pieceNotifications.notification}/>);
);
} }
else { else {
return ( return (

View File

@ -6,7 +6,7 @@ import AclButton from './../ascribe_buttons/acl_button';
import ActionPanel from '../ascribe_panel/action_panel'; import ActionPanel from '../ascribe_panel/action_panel';
import Form from './form'; import Form from './form';
import PieceListActions from '../../actions/piece_list_actions'; import NotificationActions from '../../actions/notification_actions';
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';
@ -79,7 +79,14 @@ let RequestActionForm = React.createClass({
}, },
handleSuccess() { handleSuccess() {
PieceListActions.fetchPieceRequestActions(); if (this.isPiece()){
NotificationActions.fetchPieceListNotifications();
//NotificationActions.fetchPieceNotifications(this.props.pieceOrEditions.id);
}
else {
NotificationActions.fetchEditionListNotifications();
NotificationActions.fetchEditionNotifications(this.props.pieceOrEditions[0].bitcoin_id);
}
if(this.props.handleSuccess) { if(this.props.handleSuccess) {
this.props.handleSuccess(); this.props.handleSuccess();
} }

View File

@ -15,6 +15,9 @@ import PieceListActions from '../../../../../actions/piece_list_actions';
import PrizeRatingActions from '../../actions/prize_rating_actions'; import PrizeRatingActions from '../../actions/prize_rating_actions';
import PrizeRatingStore from '../../stores/prize_rating_store'; import PrizeRatingStore from '../../stores/prize_rating_store';
import NotificationStore from '../../../../../stores/notification_store';
import NotificationActions from '../../../../../actions/notification_actions.js';
import UserStore from '../../../../../stores/user_store'; import UserStore from '../../../../../stores/user_store';
import Piece from '../../../../../components/ascribe_detail/piece'; import Piece from '../../../../../components/ascribe_detail/piece';
@ -50,7 +53,8 @@ let PieceContainer = React.createClass({
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
PieceStore.getState(), PieceStore.getState(),
UserStore.getState() UserStore.getState(),
NotificationStore.getState()
); );
}, },
@ -58,6 +62,8 @@ let PieceContainer = React.createClass({
PieceStore.listen(this.onChange); PieceStore.listen(this.onChange);
PieceActions.fetchOne(this.props.params.pieceId); PieceActions.fetchOne(this.props.params.pieceId);
UserStore.listen(this.onChange); UserStore.listen(this.onChange);
NotificationStore.listen(this.onChange);
NotificationActions.fetchPieceNotifications(this.props.params.pieceId);
}, },
// This is done to update the container when the user clicks on the prev or next // This is done to update the container when the user clicks on the prev or next
@ -77,6 +83,7 @@ let PieceContainer = React.createClass({
PieceActions.updatePiece({}); PieceActions.updatePiece({});
PieceStore.unlisten(this.onChange); PieceStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
NotificationStore.unlisten(this.onChange);
}, },
@ -88,6 +95,19 @@ let PieceContainer = React.createClass({
PieceActions.fetchOne(this.props.params.pieceId); PieceActions.fetchOne(this.props.params.pieceId);
}, },
getActions() {
if (this.state.piece &&
this.state.pieceNotifications &&
this.state.pieceNotifications.notification) {
return (
<ListRequestActions
pieceOrEditions={this.state.piece}
currentUser={this.state.currentUser}
handleSuccess={this.loadPiece}
requestActions={this.state.pieceNotifications.notification}/>);
}
},
render() { render() {
if('title' in this.state.piece) { if('title' in this.state.piece) {
// Only show the artist name if you are the participant or if you are a judge and the piece is shortlisted // Only show the artist name if you are the participant or if you are a judge and the piece is shortlisted
@ -111,11 +131,7 @@ let PieceContainer = React.createClass({
<DetailProperty label={getLangText('BY')} value={artistName} /> <DetailProperty label={getLangText('BY')} value={artistName} />
<DetailProperty label={getLangText('DATE')} value={ this.state.piece.date_created.slice(0, 4) } /> <DetailProperty label={getLangText('DATE')} value={ this.state.piece.date_created.slice(0, 4) } />
{artistEmail} {artistEmail}
<ListRequestActions {this.getActions()}
pieceOrEditions={this.state.piece}
currentUser={this.state.currentUser}
handleSuccess={this.loadPiece}
requestActions={this.state.piece.request_action}/>
<hr/> <hr/>
</div> </div>
} }

View File

@ -10,6 +10,9 @@ import PieceListStore from '../../../../../../stores/piece_list_store';
import UserStore from '../../../../../../stores/user_store'; import UserStore from '../../../../../../stores/user_store';
import NotificationStore from '../../../../../../stores/notification_store';
import NotificationActions from '../../../../../../actions/notification_actions.js';
import Piece from '../../../../../../components/ascribe_detail/piece'; import Piece from '../../../../../../components/ascribe_detail/piece';
import ListRequestActions from '../../../../../ascribe_forms/list_form_request_actions'; import ListRequestActions from '../../../../../ascribe_forms/list_form_request_actions';
@ -41,7 +44,8 @@ let IkonotvPieceContainer = React.createClass({
return mergeOptions( return mergeOptions(
PieceStore.getState(), PieceStore.getState(),
UserStore.getState(), UserStore.getState(),
PieceListStore.getState() PieceListStore.getState(),
NotificationStore.getState()
); );
}, },
@ -50,6 +54,8 @@ let IkonotvPieceContainer = React.createClass({
PieceActions.fetchOne(this.props.params.pieceId); PieceActions.fetchOne(this.props.params.pieceId);
UserStore.listen(this.onChange); UserStore.listen(this.onChange);
PieceListStore.listen(this.onChange); PieceListStore.listen(this.onChange);
NotificationStore.listen(this.onChange);
NotificationActions.fetchPieceNotifications(this.props.params.pieceId);
}, },
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -68,6 +74,7 @@ let IkonotvPieceContainer = React.createClass({
PieceStore.unlisten(this.onChange); PieceStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
PieceListStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange);
NotificationStore.unlisten(this.onChange);
}, },
onChange(state) { onChange(state) {
@ -89,15 +96,14 @@ let IkonotvPieceContainer = React.createClass({
getActions(){ getActions(){
if (this.state.piece && if (this.state.piece &&
this.state.piece.request_action && this.state.pieceNotifications &&
this.state.piece.request_action.length > 0) { this.state.pieceNotifications.notification) {
return ( return (
<ListRequestActions <ListRequestActions
pieceOrEditions={this.state.piece} pieceOrEditions={this.state.piece}
currentUser={this.state.currentUser} currentUser={this.state.currentUser}
handleSuccess={this.loadPiece} handleSuccess={this.loadPiece}
requestActions={this.state.piece.request_action}/> requestActions={this.state.pieceNotifications.notification}/>);
);
} }
else { else {

View File

@ -28,7 +28,9 @@ let ApiUrls = {
'note_public_edition': AppConstants.apiEndpoint + 'note/public/editions/', 'note_public_edition': AppConstants.apiEndpoint + 'note/public/editions/',
'note_public_piece': AppConstants.apiEndpoint + 'note/public/pieces/', 'note_public_piece': AppConstants.apiEndpoint + 'note/public/pieces/',
'notification_piecelist': AppConstants.apiEndpoint + 'notifications/pieces/', 'notification_piecelist': AppConstants.apiEndpoint + 'notifications/pieces/',
'notification_piece': AppConstants.apiEndpoint + 'notifications/pieces/${piece_id}/',
'notification_editionlist': AppConstants.apiEndpoint + 'notifications/editions/', 'notification_editionlist': AppConstants.apiEndpoint + 'notifications/editions/',
'notification_edition': AppConstants.apiEndpoint + 'notifications/editions/${edition_id}/',
'ownership_contract_agreements': AppConstants.apiEndpoint + 'ownership/contract_agreements/', 'ownership_contract_agreements': AppConstants.apiEndpoint + 'ownership/contract_agreements/',
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/', 'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/', 'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',

View File

@ -9,8 +9,16 @@ let NotificationFetcher = {
return requests.get('notification_piecelist'); return requests.get('notification_piecelist');
}, },
fetchPieceNotifications(pieceId) {
return requests.get('notification_piece', {'piece_id': pieceId});
},
fetchEditionListNotifications() { fetchEditionListNotifications() {
return requests.get('notification_editionlist'); return requests.get('notification_editionlist');
},
fetchEditionNotifications(editionId) {
return requests.get('notification_edition', {'edition_id': editionId});
} }
}; };

View File

@ -10,6 +10,8 @@ class NotificationStore {
constructor() { constructor() {
this.pieceListNotifications = {}; this.pieceListNotifications = {};
this.editionListNotifications = {}; this.editionListNotifications = {};
this.editionNotifications = null;
this.pieceNotifications = null;
this.bindActions(NotificationActions); this.bindActions(NotificationActions);
} }
@ -17,10 +19,18 @@ class NotificationStore {
this.pieceListNotifications = res.notifications; this.pieceListNotifications = res.notifications;
} }
onUpdatePieceNotifications(res) {
this.pieceNotifications = res.notification;
}
onUpdateEditionListNotifications(res) { onUpdateEditionListNotifications(res) {
this.editionListNotifications = res.notifications; this.editionListNotifications = res.notifications;
} }
onUpdateEditionNotifications(res) {
this.editionNotifications = res.notification;
}
} }
export default alt.createStore(NotificationStore, 'NotificationStore'); export default alt.createStore(NotificationStore, 'NotificationStore');

View File

@ -61,8 +61,8 @@ $break-medium: 1200px;
padding-top: 0; padding-top: 0;
} }
border-top: 0; border-top: 0;
overflow-y:auto; overflow-y: auto;
overflow-x:hidden; overflow-x: hidden;
max-height: 70vh; max-height: 70vh;
} }
} }