mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
add functionality for submit to prize button and fix delete button
This commit is contained in:
parent
aec1ff2173
commit
07dce25fe7
@ -11,6 +11,8 @@ import AccordionListItemEditionWidget from './accordion_list_item_edition_widget
|
|||||||
import CreateEditionsForm from '../ascribe_forms/create_editions_form';
|
import CreateEditionsForm from '../ascribe_forms/create_editions_form';
|
||||||
|
|
||||||
import PieceListActions from '../../actions/piece_list_actions';
|
import PieceListActions from '../../actions/piece_list_actions';
|
||||||
|
import PieceListStore from '../../stores/piece_list_store';
|
||||||
|
|
||||||
import EditionListActions from '../../actions/edition_list_actions';
|
import EditionListActions from '../../actions/edition_list_actions';
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
@ -20,6 +22,7 @@ import AclProxy from '../acl_proxy';
|
|||||||
import SubmitToPrizeButton from '../ascribe_buttons/submit_to_prize_button';
|
import SubmitToPrizeButton from '../ascribe_buttons/submit_to_prize_button';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
import { mergeOptions } from '../../utils/general_utils';
|
||||||
|
|
||||||
let Link = Router.Link;
|
let Link = Router.Link;
|
||||||
|
|
||||||
@ -33,9 +36,24 @@ let AccordionListItem = React.createClass({
|
|||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return mergeOptions(
|
||||||
showCreateEditionsDialog: false
|
{
|
||||||
};
|
showCreateEditionsDialog: false
|
||||||
|
},
|
||||||
|
PieceListStore.getState()
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
PieceListStore.listen(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
PieceListStore.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
getGlyphicon(){
|
getGlyphicon(){
|
||||||
@ -61,6 +79,13 @@ let AccordionListItem = React.createClass({
|
|||||||
this.toggleCreateEditionsDialog();
|
this.toggleCreateEditionsDialog();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleSubmitPrizeSuccess(response) {
|
||||||
|
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
|
||||||
|
|
||||||
|
let notification = new GlobalNotificationModel(response.message, 'success', 10000);
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
|
||||||
onPollingSuccess(pieceId, numEditions) {
|
onPollingSuccess(pieceId, numEditions) {
|
||||||
PieceListActions.updatePropertyForPiece({
|
PieceListActions.updatePropertyForPiece({
|
||||||
pieceId,
|
pieceId,
|
||||||
@ -132,7 +157,8 @@ let AccordionListItem = React.createClass({
|
|||||||
show={this.props.content.prize_name === null}>
|
show={this.props.content.prize_name === null}>
|
||||||
<SubmitToPrizeButton
|
<SubmitToPrizeButton
|
||||||
className="pull-right"
|
className="pull-right"
|
||||||
piece={this.props.content} />
|
piece={this.props.content}
|
||||||
|
handleSuccess={this.handleSubmitPrizeSuccess}/>
|
||||||
</AclProxy>
|
</AclProxy>
|
||||||
<AclProxy
|
<AclProxy
|
||||||
show={this.props.content.prize_name}>
|
show={this.props.content.prize_name}>
|
||||||
|
@ -55,7 +55,7 @@ let DeleteButton = React.createClass({
|
|||||||
if(this.props.editions && this.props.editions.constructor !== Array && this.props.editions.acl.acl_unshare) {
|
if(this.props.editions && this.props.editions.constructor !== Array && this.props.editions.acl.acl_unshare) {
|
||||||
content = <EditionRemoveFromCollectionForm editions={this.props.editions}/>;
|
content = <EditionRemoveFromCollectionForm editions={this.props.editions}/>;
|
||||||
title = getLangText('Remove Edition from Collection');
|
title = getLangText('Remove Edition from Collection');
|
||||||
} else {
|
} else if(this.props.piece && this.props.piece.acl.acl_unshare) {
|
||||||
content = <PieceRemoveFromCollectionForm pieceId={this.props.piece.id}/>;
|
content = <PieceRemoveFromCollectionForm pieceId={this.props.piece.id}/>;
|
||||||
title = getLangText('Remove Piece from Collection');
|
title = getLangText('Remove Piece from Collection');
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,38 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import ModalWrapper from '../ascribe_modal/modal_wrapper';
|
||||||
|
import PieceSubmitToPrizeForm from '../ascribe_forms/form_submit_to_prize';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let SubmitToPrizeButton = React.createClass({
|
let SubmitToPrizeButton = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string
|
className: React.PropTypes.string,
|
||||||
|
handleSuccess: React.PropTypes.func,
|
||||||
|
piece: React.PropTypes.object.isRequired
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
getSubmitButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className={classNames('btn', 'btn-default', 'btn-xs', this.props.className)}>
|
className={classNames('btn', 'btn-default', 'btn-xs', this.props.className)}>
|
||||||
{getLangText('Submit to prize')}
|
{getLangText('Submit to prize')}
|
||||||
</button>
|
</button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<ModalWrapper
|
||||||
|
button={this.getSubmitButton()}
|
||||||
|
handleSuccess={this.props.handleSuccess}
|
||||||
|
title={getLangText('Submit to prize')}>
|
||||||
|
<PieceSubmitToPrizeForm
|
||||||
|
piece={this.props.piece}
|
||||||
|
handleSuccess={this.props.handleSuccess}/>
|
||||||
|
</ModalWrapper>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
57
js/components/ascribe_forms/form_submit_to_prize.js
Normal file
57
js/components/ascribe_forms/form_submit_to_prize.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import Form from '../ascribe_forms/form';
|
||||||
|
|
||||||
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
import { getLangText } from '../../utils/lang_utils.js';
|
||||||
|
|
||||||
|
let PieceSubmitToPrizeForm = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
piece: React.PropTypes.object,
|
||||||
|
handleSuccess: React.PropTypes.func,
|
||||||
|
|
||||||
|
// this is set by ModalWrapper automatically
|
||||||
|
onRequestHide: React.PropTypes.func
|
||||||
|
},
|
||||||
|
|
||||||
|
getFormData() {
|
||||||
|
return this.props.piece;
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
console.log(this.props);
|
||||||
|
return (
|
||||||
|
<Form
|
||||||
|
ref='form'
|
||||||
|
url={ApiUrls.pieces_list}
|
||||||
|
getFormData={this.getFormData}
|
||||||
|
handleSuccess={this.props.handleSuccess}
|
||||||
|
buttons={
|
||||||
|
<div className="modal-footer">
|
||||||
|
<p className="pull-right">
|
||||||
|
<button
|
||||||
|
className="btn btn-default btn-sm ascribe-margin-1px"
|
||||||
|
type="submit">{getLangText('SUBMIT TO PRIZE')}</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
|
||||||
|
style={{marginLeft: '0'}}
|
||||||
|
onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</button>
|
||||||
|
</p>
|
||||||
|
</div>}
|
||||||
|
spinner={
|
||||||
|
<div className="modal-footer">
|
||||||
|
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_small.gif'} />
|
||||||
|
</div>}>
|
||||||
|
<p>{getLangText('Are you sure you want to submit to the art prize?')}</p>
|
||||||
|
<p>{getLangText('This is an irrevocable action%s', '.')}</p>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export default PieceSubmitToPrizeForm;
|
@ -4,7 +4,7 @@ import requests from '../utils/requests';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import AlertDismissable from '../components/ascribe_forms/alert';
|
import AlertDismissable from '../components/ascribe_forms/alert';
|
||||||
import { getLangText } from '../utils/lang_utils.js'
|
import { getLangText } from '../utils/lang_utils.js';
|
||||||
|
|
||||||
export const FormMixin = {
|
export const FormMixin = {
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
Loading…
Reference in New Issue
Block a user