From 73ee0753c1431c4b9cb92155528e69253c8dcd59 Mon Sep 17 00:00:00 2001 From: diminator Date: Thu, 3 Sep 2015 17:25:22 +0200 Subject: [PATCH] refactored notifications per detail --- .../accordion_list_item_table_editions.js | 2 +- .../accordion_list_item_wallet.js | 3 +- js/components/ascribe_detail/edition.js | 30 ++----- .../ascribe_detail/piece_container.js | 12 +-- .../ascribe_forms/form_request_action.js | 34 +++----- .../list_form_request_actions.js | 11 ++- .../prizes_dashboard.js | 82 ------------------- .../ascribe_table/table_item_acl_filtered.js | 6 +- js/components/header_notification.js | 17 +++- .../ascribe_detail/prize_piece_container.js | 15 +--- .../ascribe_detail/ikonotv_piece_container.js | 15 +--- js/routes.js | 2 - sass/ascribe_notification_list.scss | 8 +- 13 files changed, 60 insertions(+), 177 deletions(-) delete mode 100644 js/components/ascribe_prizes_dashboard/prizes_dashboard.js diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js index d1ab2112..350d61a8 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js @@ -160,7 +160,7 @@ let AccordionListItemTableEditions = React.createClass({ let content = item.acl; return { 'content': content, - 'requestAction': item.request_action + 'notifications': item.notifications }; }, 'acl', getLangText('Actions'), diff --git a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js index 178a7db4..dde5c43d 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js @@ -61,8 +61,7 @@ let AccordionListItemWallet = React.createClass({ }, getGlyphicon(){ - if ((this.props.content.request_action && this.props.content.request_action.length > 0) || - (this.props.content.request_action_editions)){ + if ((this.props.content.notifications && this.props.content.notifications.length > 0)){ return ( 0){ actions = ( ); + notifications={this.props.edition.notifications}/>); } else { diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 0de25beb..a4460073 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -9,9 +9,6 @@ import PieceStore from '../../stores/piece_store'; import PieceListActions from '../../actions/piece_list_actions'; 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 UserStore from '../../stores/user_store'; @@ -65,8 +62,6 @@ let PieceContainer = React.createClass({ UserActions.fetchCurrentUser(); PieceStore.listen(this.onChange); PieceActions.fetchOne(this.props.params.pieceId); - NotificationStore.listen(this.onChange); - NotificationActions.fetchPieceNotifications(this.props.params.pieceId); }, componentWillUnmount() { @@ -78,7 +73,6 @@ let PieceContainer = React.createClass({ PieceStore.unlisten(this.onChange); UserStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange); - NotificationStore.unlisten(this.onChange); }, onChange(state) { @@ -180,14 +174,14 @@ let PieceContainer = React.createClass({ getActions() { if (this.state.piece && - this.state.pieceNotifications && - this.state.pieceNotifications.notification) { + this.state.piece.notifications && + this.state.piece.notifications.length > 0) { return ( ); + notifications={this.state.piece.notifications}/>); } else { return ( diff --git a/js/components/ascribe_forms/form_request_action.js b/js/components/ascribe_forms/form_request_action.js index c65a7394..b0f3b6c6 100644 --- a/js/components/ascribe_forms/form_request_action.js +++ b/js/components/ascribe_forms/form_request_action.js @@ -22,8 +22,7 @@ let RequestActionForm = React.createClass({ React.PropTypes.object, React.PropTypes.array ]).isRequired, - requestAction: React.PropTypes.string, - requestUser: React.PropTypes.string, + notifications: React.PropTypes.object, currentUser: React.PropTypes.object, handleSuccess: React.PropTypes.func }, @@ -35,19 +34,19 @@ let RequestActionForm = React.createClass({ getUrls() { let urls = {}; - if (this.props.requestAction === 'consign'){ + if (this.props.notifications.action === 'consign'){ urls.accept = ApiUrls.ownership_consigns_confirm; urls.deny = ApiUrls.ownership_consigns_deny; - } else if (this.props.requestAction === 'unconsign'){ + } else if (this.props.notifications.action === 'unconsign'){ urls.accept = ApiUrls.ownership_unconsigns; urls.deny = ApiUrls.ownership_unconsigns_deny; - } else if (this.props.requestAction === 'loan' && !this.isPiece()){ + } else if (this.props.notifications.action === 'loan' && !this.isPiece()){ urls.accept = ApiUrls.ownership_loans_confirm; urls.deny = ApiUrls.ownership_loans_deny; - } else if (this.props.requestAction === 'loan' && this.isPiece()){ + } else if (this.props.notifications.action === 'loan' && this.isPiece()){ urls.accept = ApiUrls.ownership_loans_pieces_confirm; urls.deny = ApiUrls.ownership_loans_pieces_deny; - } else if (this.props.requestAction === 'loan_request' && this.isPiece()){ + } else if (this.props.notifications.action === 'loan_request' && this.isPiece()){ urls.accept = ApiUrls.ownership_loans_pieces_request_confirm; urls.deny = ApiUrls.ownership_loans_pieces_request_deny; } @@ -70,8 +69,8 @@ let RequestActionForm = React.createClass({ return () => { let message = getLangText('You have successfully') + ' ' + option + ' the ' + action + ' request ' + getLangText('from') + ' ' + owner; - let notification = new GlobalNotificationModel(message, 'success'); - GlobalNotificationActions.appendGlobalNotification(notification); + let notifications = new GlobalNotificationModel(message, 'success'); + GlobalNotificationActions.appendGlobalNotification(notifications); this.handleSuccess(); @@ -81,11 +80,9 @@ let RequestActionForm = React.createClass({ handleSuccess() { 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) { this.props.handleSuccess(); @@ -93,20 +90,15 @@ let RequestActionForm = React.createClass({ }, getContent() { - let pieceOrEditionStr = this.isPiece() ? getLangText('this work%s', '.') : getLangText('this edition%s', '.'); - let message = this.props.requestUser + ' ' + getLangText('requests you') + ' ' + this.props.requestAction + ' ' + pieceOrEditionStr; - if (this.props.requestAction === 'loan_request'){ - message = this.props.requestUser + ' ' + getLangText('requests you to loan') + ' ' + pieceOrEditionStr; - } return ( - {message} + {this.props.notifications.action_str + ' by ' + this.props.notifications.by} ); }, getAcceptButtonForm(urls) { - if(this.props.requestAction === 'unconsign') { + if(this.props.notifications.action === 'unconsign') { return ( ); - } else if(this.props.requestAction === 'loan_request') { + } else if(this.props.notifications.action === 'loan_request') { return ( @@ -158,7 +150,7 @@ let RequestActionForm = React.createClass({ isInline={true} getFormData={this.getFormData} handleSuccess={ - this.showNotification(getLangText('denied'), this.props.requestAction, this.props.requestUser) + this.showNotification(getLangText('denied'), this.props.notifications.action, this.props.notifications.by) } className='inline pull-right'>