mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
delete function for multi editions
This commit is contained in:
parent
9241d3e38f
commit
af71196dfd
@ -26,7 +26,7 @@ let AclButton = React.createClass({
|
||||
return {
|
||||
title: 'Consign artwork',
|
||||
tooltip: 'Have someone else sell the artwork',
|
||||
form: <ConsignForm />,
|
||||
form: <ConsignForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||
handleSuccess: this.showNotification
|
||||
};
|
||||
}
|
||||
@ -34,7 +34,7 @@ let AclButton = React.createClass({
|
||||
return {
|
||||
title: 'Transfer artwork',
|
||||
tooltip: 'Transfer the ownership of the artwork',
|
||||
form: <TransferForm />,
|
||||
form: <TransferForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||
handleSuccess: this.showNotification
|
||||
};
|
||||
}
|
||||
@ -42,7 +42,7 @@ let AclButton = React.createClass({
|
||||
return {
|
||||
title: 'Loan artwork',
|
||||
tooltip: 'Loan your artwork for a limited period of time',
|
||||
form: <LoanForm />,
|
||||
form: <LoanForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||
handleSuccess: this.showNotification
|
||||
};
|
||||
}
|
||||
@ -50,7 +50,7 @@ let AclButton = React.createClass({
|
||||
return {
|
||||
title: 'Share artwork',
|
||||
tooltip: 'Share the artwork',
|
||||
form: <ShareForm />,
|
||||
form: <ShareForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||
handleSuccess: this.showNotification
|
||||
};
|
||||
}
|
||||
@ -70,8 +70,6 @@ let AclButton = React.createClass({
|
||||
{this.props.action.toUpperCase()}
|
||||
</div>
|
||||
}
|
||||
currentUser={ this.props.currentUser }
|
||||
editions={ this.props.editions }
|
||||
handleSuccess={ aclProps.handleSuccess }
|
||||
title={ aclProps.title }
|
||||
tooltip={ aclProps.tooltip }>
|
||||
|
51
js/components/ascribe_buttons/delete_button.js
Normal file
51
js/components/ascribe_buttons/delete_button.js
Normal file
@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import Router from 'react-router';
|
||||
|
||||
import Button from 'react-bootstrap/lib/Button';
|
||||
|
||||
import EditionDeleteForm from '../ascribe_forms/form_delete_edition';
|
||||
import ModalWrapper from '../ascribe_modal/modal_wrapper';
|
||||
|
||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||
|
||||
let DeleteButton = React.createClass({
|
||||
propTypes: {
|
||||
editions: React.PropTypes.array.isRequired,
|
||||
},
|
||||
|
||||
mixins: [Router.Navigation],
|
||||
|
||||
showNotification(response){
|
||||
this.transitionTo('pieces');
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
},
|
||||
render: function () {
|
||||
let btnDelete = null;
|
||||
let content = <EditionDeleteForm />;
|
||||
if (this.props.edition.acl.indexOf('delete') > -1) {
|
||||
btnDelete = <Button bsStyle="danger">Delete this edition</Button>;
|
||||
}
|
||||
else if (this.props.edition.acl.indexOf('del_from_collection') > -1){
|
||||
btnDelete = <Button bsStyle="danger">Remove this artwork from your list</Button>;
|
||||
}
|
||||
else{
|
||||
return <div></div>;
|
||||
}
|
||||
return (
|
||||
<ModalWrapper
|
||||
button={ btnDelete }
|
||||
currentUser={ this.props.currentUser }
|
||||
editions={ [this.props.edition] }
|
||||
handleSuccess={ this.showNotification }
|
||||
title='Remove Edition'
|
||||
tooltip='Click to remove edition'>
|
||||
{ content }
|
||||
</ModalWrapper>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default DeleteButton;
|
||||
|
35
js/components/ascribe_forms/form_delete_edition.js
Normal file
35
js/components/ascribe_forms/form_delete_edition.js
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import fetch from '../../utils/fetch';
|
||||
import ApiUrls from '../../constants/api_urls';
|
||||
import FormMixin from '../../mixins/form_mixin';
|
||||
|
||||
let EditionDeleteForm = React.createClass({
|
||||
|
||||
mixins: [FormMixin],
|
||||
|
||||
url() {
|
||||
return fetch.prepareUrl(ApiUrls.edition_delete, {edition_id: this.props.editions[0].bitcoin_id});
|
||||
},
|
||||
httpVerb(){
|
||||
return 'delete';
|
||||
},
|
||||
|
||||
renderForm () {
|
||||
return (
|
||||
<div className="modal-body">
|
||||
<p>Are you sure you would like to permanently delete this edition?</p>
|
||||
<p>This is an irrevocable action.</p>
|
||||
<div className="modal-footer">
|
||||
<button type="submit" className="btn btn-ascribe-inv" onClick={this.submit}>YES, DELETE</button>
|
||||
<button className="btn btn-ascribe" onClick={this.props.onRequestHide}>CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export default EditionDeleteForm;
|
@ -13,8 +13,6 @@ import ModalMixin from '../../mixins/modal_mixin';
|
||||
let ModalWrapper = React.createClass({
|
||||
propTypes: {
|
||||
title: React.PropTypes.string.isRequired,
|
||||
editions: React.PropTypes.array.isRequired,
|
||||
currentUser: React.PropTypes.object.isRequired,
|
||||
onRequestHide: React.PropTypes.func,
|
||||
handleSuccess: React.PropTypes.func.isRequired,
|
||||
button: React.PropTypes.object.isRequired,
|
||||
@ -29,8 +27,6 @@ let ModalWrapper = React.createClass({
|
||||
<ModalTrigger modal={
|
||||
<ModalBody
|
||||
title={this.props.title}
|
||||
editions={this.props.editions}
|
||||
currentUser={this.props.currentUser}
|
||||
handleSuccess={this.props.handleSuccess}>
|
||||
{this.props.children}
|
||||
</ModalBody>
|
||||
@ -45,8 +41,6 @@ let ModalWrapper = React.createClass({
|
||||
|
||||
let ModalBody = React.createClass({
|
||||
propTypes: {
|
||||
editions: React.PropTypes.array,
|
||||
currentUser: React.PropTypes.object,
|
||||
onRequestHide: React.PropTypes.func,
|
||||
handleSuccess: React.PropTypes.func,
|
||||
children: React.PropTypes.object,
|
||||
@ -63,9 +57,7 @@ let ModalBody = React.createClass({
|
||||
renderChildren() {
|
||||
return ReactAddons.Children.map(this.props.children, (child) => {
|
||||
return ReactAddons.addons.cloneWithProps(child, {
|
||||
editions: this.props.editions,
|
||||
currentUser: this.props.currentUser,
|
||||
onRequestHide: this.onRequestHide,
|
||||
onRequestHide: this.props.onRequestHide,
|
||||
handleSuccess: this.handleSuccess
|
||||
});
|
||||
});
|
||||
|
@ -13,7 +13,6 @@ import UserActions from '../../actions/user_actions';
|
||||
import PieceListBulkModalSelectedEditionsWidget from './piece_list_bulk_modal_selected_editions_widget';
|
||||
import AclButtonList from '../ascribe_buttons/acl_button_list';
|
||||
|
||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||
|
||||
let PieceListBulkModal = React.createClass({
|
||||
propTypes: {
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import MediaPlayer from './ascribe_media/media_player';
|
||||
|
||||
import CollapsibleMixin from 'react-bootstrap/lib/CollapsibleMixin';
|
||||
@ -14,6 +15,7 @@ import PieceExtraDataForm from './ascribe_forms/form_piece_extradata';
|
||||
|
||||
import EditionActions from '../actions/edition_actions';
|
||||
import AclButtonList from './ascribe_buttons/acl_button_list';
|
||||
import DeleteButton from './ascribe_buttons/delete_button';
|
||||
|
||||
import GlobalNotificationModel from '../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../actions/global_notification_actions';
|
||||
@ -113,11 +115,9 @@ let Edition = React.createClass({
|
||||
|
||||
<CollapsibleEditionDetails
|
||||
title="Delete Actions">
|
||||
<Button
|
||||
bsStyle="danger"
|
||||
onClick={this.props.deleteEdition}>
|
||||
Remove this artwork from your list
|
||||
</Button>
|
||||
<DeleteButton
|
||||
edition={this.props.edition}
|
||||
currentUser={ this.props.currentUser } />
|
||||
</CollapsibleEditionDetails>
|
||||
</Col>
|
||||
</Row>
|
||||
@ -348,6 +348,11 @@ let EditionFurtherDetails = React.createClass({
|
||||
edition: React.PropTypes.object,
|
||||
handleSuccess: React.PropTypes.func
|
||||
},
|
||||
showNotification(){
|
||||
this.props.handleSuccess();
|
||||
let notification = new GlobalNotificationModel('Details updated', 'success');
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
@ -356,17 +361,17 @@ let EditionFurtherDetails = React.createClass({
|
||||
<PieceExtraDataForm
|
||||
name='artist_contact_info'
|
||||
title='Artist Contact Info'
|
||||
handleSuccess={this.props.handleSuccess}
|
||||
handleSuccess={this.showNotification}
|
||||
editions={[this.props.edition]} />
|
||||
<PieceExtraDataForm
|
||||
name='display_instructions'
|
||||
title='Display Instructions'
|
||||
handleSuccess={this.props.handleSuccess}
|
||||
handleSuccess={this.showNotification}
|
||||
editions={[this.props.edition]} />
|
||||
<PieceExtraDataForm
|
||||
name='technology_details'
|
||||
title='Technology Details'
|
||||
handleSuccess={this.props.handleSuccess}
|
||||
handleSuccess={this.showNotification}
|
||||
editions={[this.props.edition]} />
|
||||
</Col>
|
||||
</Row>
|
||||
@ -374,5 +379,4 @@ let EditionFurtherDetails = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export default Edition;
|
||||
|
@ -6,16 +6,18 @@ let apiUrls = {
|
||||
'ownership_shares_mail': AppConstants.baseUrl + 'ownership/shares/mail/',
|
||||
'ownership_transfers': AppConstants.baseUrl + 'ownership/transfers/',
|
||||
'user': AppConstants.baseUrl + 'users/',
|
||||
'pieces_list': AppConstants.baseUrl + 'pieces/',
|
||||
'piece': AppConstants.baseUrl + 'pieces/${piece_id}',
|
||||
'pieces_list': AppConstants.baseUrl + 'pieces/',
|
||||
'piece_extradata': AppConstants.baseUrl + 'pieces/${piece_id}/extradata/',
|
||||
'edition': AppConstants.baseUrl + 'editions/${bitcoin_id}/',
|
||||
'editions_list': AppConstants.baseUrl + 'pieces/${piece_id}/editions/',
|
||||
'edition_delete': AppConstants.baseUrl + 'editions/${edition_id}/',
|
||||
'ownership_loans': AppConstants.baseUrl + 'ownership/loans/',
|
||||
'ownership_consigns': AppConstants.baseUrl + 'ownership/consigns/',
|
||||
'ownership_unconsigns': AppConstants.baseUrl + 'ownership/unconsigns/',
|
||||
'ownership_unconsigns_request': AppConstants.baseUrl + 'ownership/unconsigns/request/',
|
||||
'note_notes': AppConstants.baseUrl + 'note/notes/',
|
||||
'piece_extradata': AppConstants.baseUrl + 'pieces/${piece_id}/extradata/'
|
||||
'note_notes': AppConstants.baseUrl + 'note/notes/'
|
||||
|
||||
};
|
||||
|
||||
export default apiUrls;
|
||||
|
@ -24,11 +24,23 @@ export const FormMixin = {
|
||||
}
|
||||
this.setState({submitted: true});
|
||||
this.clearErrors();
|
||||
let action = (this.httpVerb && this.httpVerb()) || 'post';
|
||||
this[action]();
|
||||
},
|
||||
|
||||
post(){
|
||||
fetch
|
||||
.post(this.url(), { body: this.getFormData() })
|
||||
.then(this.handleSuccess)
|
||||
.catch(this.handleError);
|
||||
},
|
||||
|
||||
delete(){
|
||||
fetch
|
||||
.delete(this.url())
|
||||
.then(this.handleSuccess)
|
||||
.catch(this.handleError);
|
||||
},
|
||||
|
||||
clearErrors(){
|
||||
for (var ref in this.refs){
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
export default class GlobalNotificationModel {
|
||||
constructor(message, type = 'info', dismissAfter = 3500) {
|
||||
constructor(message, type = 'info', dismissAfter = 5000) {
|
||||
if(message) {
|
||||
this.message = message;
|
||||
} else {
|
||||
|
@ -92,6 +92,12 @@ class Fetch {
|
||||
return this.request('get', newUrl);
|
||||
}
|
||||
|
||||
delete(url, params) {
|
||||
let paramsCopy = this._merge(params);
|
||||
let newUrl = this.prepareUrl(url, paramsCopy, true);
|
||||
return this.request('delete', newUrl);
|
||||
}
|
||||
|
||||
post(url, params) {
|
||||
let paramsCopy = this._merge(params);
|
||||
let newUrl = this.prepareUrl(url, paramsCopy);
|
||||
|
Loading…
Reference in New Issue
Block a user