1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-23 01:36:28 +02:00

Handle deletion method for WalletPieceContainer

This commit is contained in:
Tim Daubenschütz 2015-10-21 23:45:53 +02:00
parent 846e891d84
commit 7f97ce9828
5 changed files with 68 additions and 6 deletions

View File

@ -9,7 +9,6 @@ import Form from './../ascribe_forms/form';
import PieceExtraDataForm from './../ascribe_forms/form_piece_extradata';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
@ -17,6 +16,7 @@ import FurtherDetailsFileuploader from './further_details_fileuploader';
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
let FurtherDetails = React.createClass({
propTypes: {
editable: React.PropTypes.bool,

View File

@ -2,14 +2,12 @@
import React from 'react';
import ListRequestActions from '../../../../ascribe_forms/list_form_request_actions';
import AclButtonList from '../../../../ascribe_buttons/acl_button_list';
import DeleteButton from '../../../../ascribe_buttons/delete_button';
import AclProxy from '../../../../acl_proxy';
import { mergeOptions } from '../../../../../utils/general_utils';
@ -18,6 +16,7 @@ let WalletActionPanel = React.createClass({
piece: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object.isRequired,
loadPiece: React.PropTypes.func.isRequired,
handleDeleteSuccess: React.PropTypes.func.isRequired,
submitButtonType: React.PropTypes.func.isRequired
},
@ -62,7 +61,7 @@ let WalletActionPanel = React.createClass({
</AclProxy>
</AclProxy>
<DeleteButton
handleSuccess={this.handleDeleteSuccess}
handleSuccess={this.props.handleDeleteSuccess}
piece={this.props.piece}/>
</AclButtonList>
);

View File

@ -23,6 +23,7 @@ let WalletPieceContainer = React.createClass({
piece: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object.isRequired,
loadPiece: React.PropTypes.func.isRequired,
handleDeleteSuccess: React.PropTypes.func.isRequired,
submitButtonType: React.PropTypes.func.isRequired
},
@ -53,6 +54,7 @@ let WalletPieceContainer = React.createClass({
piece={this.props.piece}
currentUser={this.props.currentUser}
loadPiece={this.props.loadPiece}
handleDeleteSuccess={this.props.handleDeleteSuccess}
submitButtonType={this.props.submitButtonType}/>
<CollapsibleParagraph
title={getLangText('Loan History')}

View File

@ -1,12 +1,18 @@
'use strict';
import React from 'react';
import { History } from 'react-router';
import PieceActions from '../../../../../../actions/piece_actions';
import PieceStore from '../../../../../../stores/piece_store';
import UserStore from '../../../../../../stores/user_store';
import PieceListStore from '../../../../../../stores/piece_list_store';
import PieceListActions from '../../../../../../actions/piece_list_actions';
import EditionListActions from '../../../../../../actions/edition_list_actions';
import CylandSubmitButton from '../cyland_buttons/cyland_submit_button';
import CollapsibleParagraph from '../../../../../../components/ascribe_collapsible/collapsible_paragraph';
@ -17,26 +23,34 @@ import WalletPieceContainer from '../../ascribe_detail/wallet_piece_container';
import AscribeSpinner from '../../../../../ascribe_spinner';
import GlobalNotificationModel from '../../../../../../models/global_notification_model';
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
import { getLangText } from '../../../../../../utils/lang_utils';
import { setDocumentTitle } from '../../../../../../utils/dom_utils';
import { mergeOptions } from '../../../../../../utils/general_utils';
let CylandPieceContainer = React.createClass({
propTypes: {
location: React.PropTypes.object,
params: React.PropTypes.object
},
mixins: [History],
getInitialState() {
return mergeOptions(
PieceStore.getState(),
UserStore.getState()
UserStore.getState(),
PieceListStore.getState()
);
},
componentDidMount() {
PieceStore.listen(this.onChange);
UserStore.listen(this.onChange);
PieceListStore.listen(this.onChange);
// Every time we're leaving the piece detail page,
// just reset the piece that is saved in the piece store
@ -50,6 +64,7 @@ let CylandPieceContainer = React.createClass({
componentWillUnmount() {
PieceStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange);
PieceListStore.listen(this.onChange);
},
onChange(state) {
@ -60,6 +75,21 @@ let CylandPieceContainer = React.createClass({
PieceActions.fetchOne(this.props.params.pieceId);
},
handleDeleteSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
// since we're deleting a piece, we just need to close
// all editions dialogs and not reload them
EditionListActions.closeAllEditionLists();
EditionListActions.clearAllEditionSelections();
let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection');
},
render() {
if(this.state.piece && this.state.piece.title) {
setDocumentTitle([this.state.piece.artist_name, this.state.piece.title].join(', '));
@ -69,6 +99,7 @@ let CylandPieceContainer = React.createClass({
piece={this.state.piece}
currentUser={this.state.currentUser}
loadPiece={this.loadPiece}
handleDeleteSuccess={this.handleDeleteSuccess}
submitButtonType={CylandSubmitButton}>
<CollapsibleParagraph
title={getLangText('Further Details')}

View File

@ -1,12 +1,18 @@
'use strict';
import React from 'react';
import { History } from 'react-router';
import PieceActions from '../../../../../../actions/piece_actions';
import PieceStore from '../../../../../../stores/piece_store';
import UserStore from '../../../../../../stores/user_store';
import PieceListStore from '../../../../../../stores/piece_list_store';
import PieceListActions from '../../../../../../actions/piece_list_actions';
import EditionListActions from '../../../../../../actions/edition_list_actions';
import IkonotvSubmitButton from '../ikonotv_buttons/ikonotv_submit_button';
import CollapsibleParagraph from '../../../../../../components/ascribe_collapsible/collapsible_paragraph';
@ -18,6 +24,9 @@ import WalletPieceContainer from '../../ascribe_detail/wallet_piece_container';
import AscribeSpinner from '../../../../../ascribe_spinner';
import GlobalNotificationModel from '../../../../../../models/global_notification_model';
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
import { getLangText } from '../../../../../../utils/lang_utils';
import { setDocumentTitle } from '../../../../../../utils/dom_utils';
import { mergeOptions } from '../../../../../../utils/general_utils';
@ -28,16 +37,20 @@ let IkonotvPieceContainer = React.createClass({
params: React.PropTypes.object
},
mixins: [History],
getInitialState() {
return mergeOptions(
PieceStore.getState(),
UserStore.getState()
UserStore.getState(),
PieceListStore.getState()
);
},
componentDidMount() {
PieceStore.listen(this.onChange);
UserStore.listen(this.onChange);
PieceListStore.listen(this.onChange);
// Every time we're leaving the piece detail page,
// just reset the piece that is saved in the piece store
@ -59,6 +72,7 @@ let IkonotvPieceContainer = React.createClass({
componentWillUnmount() {
PieceStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange);
PieceListStore.listen(this.onChange);
},
onChange(state) {
@ -69,6 +83,21 @@ let IkonotvPieceContainer = React.createClass({
PieceActions.fetchOne(this.props.params.pieceId);
},
handleDeleteSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
// since we're deleting a piece, we just need to close
// all editions dialogs and not reload them
EditionListActions.closeAllEditionLists();
EditionListActions.clearAllEditionSelections();
let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection');
},
render() {
let furtherDetails = (
<CollapsibleParagraph
@ -102,6 +131,7 @@ let IkonotvPieceContainer = React.createClass({
piece={this.state.piece}
currentUser={this.state.currentUser}
loadPiece={this.loadPiece}
handleDeleteSuccess={this.handleDeleteSuccess}
submitButtonType={IkonotvSubmitButton}>
{furtherDetails}
</WalletPieceContainer>