mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +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 {
|
return {
|
||||||
title: 'Consign artwork',
|
title: 'Consign artwork',
|
||||||
tooltip: 'Have someone else sell the artwork',
|
tooltip: 'Have someone else sell the artwork',
|
||||||
form: <ConsignForm />,
|
form: <ConsignForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ let AclButton = React.createClass({
|
|||||||
return {
|
return {
|
||||||
title: 'Transfer artwork',
|
title: 'Transfer artwork',
|
||||||
tooltip: 'Transfer the ownership of the artwork',
|
tooltip: 'Transfer the ownership of the artwork',
|
||||||
form: <TransferForm />,
|
form: <TransferForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ let AclButton = React.createClass({
|
|||||||
return {
|
return {
|
||||||
title: 'Loan artwork',
|
title: 'Loan artwork',
|
||||||
tooltip: 'Loan your artwork for a limited period of time',
|
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
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ let AclButton = React.createClass({
|
|||||||
return {
|
return {
|
||||||
title: 'Share artwork',
|
title: 'Share artwork',
|
||||||
tooltip: 'Share the artwork',
|
tooltip: 'Share the artwork',
|
||||||
form: <ShareForm />,
|
form: <ShareForm currentUser={ this.props.currentUser } editions={ this.props.editions }/>,
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -70,8 +70,6 @@ let AclButton = React.createClass({
|
|||||||
{this.props.action.toUpperCase()}
|
{this.props.action.toUpperCase()}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
currentUser={ this.props.currentUser }
|
|
||||||
editions={ this.props.editions }
|
|
||||||
handleSuccess={ aclProps.handleSuccess }
|
handleSuccess={ aclProps.handleSuccess }
|
||||||
title={ aclProps.title }
|
title={ aclProps.title }
|
||||||
tooltip={ aclProps.tooltip }>
|
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({
|
let ModalWrapper = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
title: React.PropTypes.string.isRequired,
|
title: React.PropTypes.string.isRequired,
|
||||||
editions: React.PropTypes.array.isRequired,
|
|
||||||
currentUser: React.PropTypes.object.isRequired,
|
|
||||||
onRequestHide: React.PropTypes.func,
|
onRequestHide: React.PropTypes.func,
|
||||||
handleSuccess: React.PropTypes.func.isRequired,
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
button: React.PropTypes.object.isRequired,
|
button: React.PropTypes.object.isRequired,
|
||||||
@ -29,8 +27,6 @@ let ModalWrapper = React.createClass({
|
|||||||
<ModalTrigger modal={
|
<ModalTrigger modal={
|
||||||
<ModalBody
|
<ModalBody
|
||||||
title={this.props.title}
|
title={this.props.title}
|
||||||
editions={this.props.editions}
|
|
||||||
currentUser={this.props.currentUser}
|
|
||||||
handleSuccess={this.props.handleSuccess}>
|
handleSuccess={this.props.handleSuccess}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
@ -45,8 +41,6 @@ let ModalWrapper = React.createClass({
|
|||||||
|
|
||||||
let ModalBody = React.createClass({
|
let ModalBody = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
editions: React.PropTypes.array,
|
|
||||||
currentUser: React.PropTypes.object,
|
|
||||||
onRequestHide: React.PropTypes.func,
|
onRequestHide: React.PropTypes.func,
|
||||||
handleSuccess: React.PropTypes.func,
|
handleSuccess: React.PropTypes.func,
|
||||||
children: React.PropTypes.object,
|
children: React.PropTypes.object,
|
||||||
@ -63,9 +57,7 @@ let ModalBody = React.createClass({
|
|||||||
renderChildren() {
|
renderChildren() {
|
||||||
return ReactAddons.Children.map(this.props.children, (child) => {
|
return ReactAddons.Children.map(this.props.children, (child) => {
|
||||||
return ReactAddons.addons.cloneWithProps(child, {
|
return ReactAddons.addons.cloneWithProps(child, {
|
||||||
editions: this.props.editions,
|
onRequestHide: this.props.onRequestHide,
|
||||||
currentUser: this.props.currentUser,
|
|
||||||
onRequestHide: this.onRequestHide,
|
|
||||||
handleSuccess: this.handleSuccess
|
handleSuccess: this.handleSuccess
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,6 @@ import UserActions from '../../actions/user_actions';
|
|||||||
import PieceListBulkModalSelectedEditionsWidget from './piece_list_bulk_modal_selected_editions_widget';
|
import PieceListBulkModalSelectedEditionsWidget from './piece_list_bulk_modal_selected_editions_widget';
|
||||||
import AclButtonList from '../ascribe_buttons/acl_button_list';
|
import AclButtonList from '../ascribe_buttons/acl_button_list';
|
||||||
|
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
||||||
|
|
||||||
let PieceListBulkModal = React.createClass({
|
let PieceListBulkModal = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import MediaPlayer from './ascribe_media/media_player';
|
import MediaPlayer from './ascribe_media/media_player';
|
||||||
|
|
||||||
import CollapsibleMixin from 'react-bootstrap/lib/CollapsibleMixin';
|
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 EditionActions from '../actions/edition_actions';
|
||||||
import AclButtonList from './ascribe_buttons/acl_button_list';
|
import AclButtonList from './ascribe_buttons/acl_button_list';
|
||||||
|
import DeleteButton from './ascribe_buttons/delete_button';
|
||||||
|
|
||||||
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';
|
||||||
@ -113,11 +115,9 @@ let Edition = React.createClass({
|
|||||||
|
|
||||||
<CollapsibleEditionDetails
|
<CollapsibleEditionDetails
|
||||||
title="Delete Actions">
|
title="Delete Actions">
|
||||||
<Button
|
<DeleteButton
|
||||||
bsStyle="danger"
|
edition={this.props.edition}
|
||||||
onClick={this.props.deleteEdition}>
|
currentUser={ this.props.currentUser } />
|
||||||
Remove this artwork from your list
|
|
||||||
</Button>
|
|
||||||
</CollapsibleEditionDetails>
|
</CollapsibleEditionDetails>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@ -348,6 +348,11 @@ let EditionFurtherDetails = React.createClass({
|
|||||||
edition: React.PropTypes.object,
|
edition: React.PropTypes.object,
|
||||||
handleSuccess: React.PropTypes.func
|
handleSuccess: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
showNotification(){
|
||||||
|
this.props.handleSuccess();
|
||||||
|
let notification = new GlobalNotificationModel('Details updated', 'success');
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
@ -356,17 +361,17 @@ let EditionFurtherDetails = React.createClass({
|
|||||||
<PieceExtraDataForm
|
<PieceExtraDataForm
|
||||||
name='artist_contact_info'
|
name='artist_contact_info'
|
||||||
title='Artist Contact Info'
|
title='Artist Contact Info'
|
||||||
handleSuccess={this.props.handleSuccess}
|
handleSuccess={this.showNotification}
|
||||||
editions={[this.props.edition]} />
|
editions={[this.props.edition]} />
|
||||||
<PieceExtraDataForm
|
<PieceExtraDataForm
|
||||||
name='display_instructions'
|
name='display_instructions'
|
||||||
title='Display Instructions'
|
title='Display Instructions'
|
||||||
handleSuccess={this.props.handleSuccess}
|
handleSuccess={this.showNotification}
|
||||||
editions={[this.props.edition]} />
|
editions={[this.props.edition]} />
|
||||||
<PieceExtraDataForm
|
<PieceExtraDataForm
|
||||||
name='technology_details'
|
name='technology_details'
|
||||||
title='Technology Details'
|
title='Technology Details'
|
||||||
handleSuccess={this.props.handleSuccess}
|
handleSuccess={this.showNotification}
|
||||||
editions={[this.props.edition]} />
|
editions={[this.props.edition]} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@ -374,5 +379,4 @@ let EditionFurtherDetails = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default Edition;
|
export default Edition;
|
||||||
|
@ -6,16 +6,18 @@ let apiUrls = {
|
|||||||
'ownership_shares_mail': AppConstants.baseUrl + 'ownership/shares/mail/',
|
'ownership_shares_mail': AppConstants.baseUrl + 'ownership/shares/mail/',
|
||||||
'ownership_transfers': AppConstants.baseUrl + 'ownership/transfers/',
|
'ownership_transfers': AppConstants.baseUrl + 'ownership/transfers/',
|
||||||
'user': AppConstants.baseUrl + 'users/',
|
'user': AppConstants.baseUrl + 'users/',
|
||||||
'pieces_list': AppConstants.baseUrl + 'pieces/',
|
|
||||||
'piece': AppConstants.baseUrl + 'pieces/${piece_id}',
|
'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}/',
|
'edition': AppConstants.baseUrl + 'editions/${bitcoin_id}/',
|
||||||
'editions_list': AppConstants.baseUrl + 'pieces/${piece_id}/editions/',
|
'editions_list': AppConstants.baseUrl + 'pieces/${piece_id}/editions/',
|
||||||
|
'edition_delete': AppConstants.baseUrl + 'editions/${edition_id}/',
|
||||||
'ownership_loans': AppConstants.baseUrl + 'ownership/loans/',
|
'ownership_loans': AppConstants.baseUrl + 'ownership/loans/',
|
||||||
'ownership_consigns': AppConstants.baseUrl + 'ownership/consigns/',
|
'ownership_consigns': AppConstants.baseUrl + 'ownership/consigns/',
|
||||||
'ownership_unconsigns': AppConstants.baseUrl + 'ownership/unconsigns/',
|
'ownership_unconsigns': AppConstants.baseUrl + 'ownership/unconsigns/',
|
||||||
'ownership_unconsigns_request': AppConstants.baseUrl + 'ownership/unconsigns/request/',
|
'ownership_unconsigns_request': AppConstants.baseUrl + 'ownership/unconsigns/request/',
|
||||||
'note_notes': AppConstants.baseUrl + 'note/notes/',
|
'note_notes': AppConstants.baseUrl + 'note/notes/'
|
||||||
'piece_extradata': AppConstants.baseUrl + 'pieces/${piece_id}/extradata/'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default apiUrls;
|
export default apiUrls;
|
||||||
|
@ -24,12 +24,24 @@ export const FormMixin = {
|
|||||||
}
|
}
|
||||||
this.setState({submitted: true});
|
this.setState({submitted: true});
|
||||||
this.clearErrors();
|
this.clearErrors();
|
||||||
|
let action = (this.httpVerb && this.httpVerb()) || 'post';
|
||||||
|
this[action]();
|
||||||
|
},
|
||||||
|
|
||||||
|
post(){
|
||||||
fetch
|
fetch
|
||||||
.post(this.url(), { body: this.getFormData() })
|
.post(this.url(), { body: this.getFormData() })
|
||||||
.then(this.handleSuccess)
|
.then(this.handleSuccess)
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
delete(){
|
||||||
|
fetch
|
||||||
|
.delete(this.url())
|
||||||
|
.then(this.handleSuccess)
|
||||||
|
.catch(this.handleError);
|
||||||
|
},
|
||||||
|
|
||||||
clearErrors(){
|
clearErrors(){
|
||||||
for (var ref in this.refs){
|
for (var ref in this.refs){
|
||||||
if ('clearAlerts' in this.refs[ref]){
|
if ('clearAlerts' in this.refs[ref]){
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export default class GlobalNotificationModel {
|
export default class GlobalNotificationModel {
|
||||||
constructor(message, type = 'info', dismissAfter = 3500) {
|
constructor(message, type = 'info', dismissAfter = 5000) {
|
||||||
if(message) {
|
if(message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,6 +92,12 @@ class Fetch {
|
|||||||
return this.request('get', newUrl);
|
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) {
|
post(url, params) {
|
||||||
let paramsCopy = this._merge(params);
|
let paramsCopy = this._merge(params);
|
||||||
let newUrl = this.prepareUrl(url, paramsCopy);
|
let newUrl = this.prepareUrl(url, paramsCopy);
|
||||||
|
Loading…
Reference in New Issue
Block a user