1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Merge remote-tracking branch 'remotes/origin/master' into AD-43-in-piece_detail-add-generic-field-

Conflicts:
	gulpfile.js

added notifications
cleaned up proptypes
This commit is contained in:
ddejongh 2015-06-09 16:10:38 +02:00
parent 30ee436f4c
commit 509aa111ab
15 changed files with 123 additions and 43 deletions

View File

@ -9,6 +9,9 @@ import ShareForm from '../ascribe_forms/form_share_email';
import ModalWrapper from '../ascribe_modal/modal_wrapper';
import AppConstants from '../../constants/application_constants';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
let AclButton = React.createClass({
propTypes: {
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
@ -23,31 +26,40 @@ let AclButton = React.createClass({
return {
title: 'Consign artwork',
tooltip: 'Have someone else sell the artwork',
form: <ConsignForm />
form: <ConsignForm />,
handleSuccess: this.showNotification
};
}
else if (this.props.action === 'transfer') {
return {
title: 'Transfer artwork',
tooltip: 'Transfer the ownership of the artwork',
form: <TransferForm />
form: <TransferForm />,
handleSuccess: this.showNotification
};
}
else if (this.props.action === 'loan'){
return {
title: 'Loan artwork',
tooltip: 'Loan your artwork for a limited period of time',
form: <LoanForm />
form: <LoanForm />,
handleSuccess: this.showNotification
};
}
else if (this.props.action === 'share'){
return {
title: 'Share artwork',
tooltip: 'Share the artwork',
form: <ShareForm />
form: <ShareForm />,
handleSuccess: this.showNotification
};
}
},
showNotification(response){
this.props.handleSuccess();
let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
},
render() {
let shouldDisplay = this.props.availableAcls.indexOf(this.props.action) > -1;
let aclProps = this.actionProperties();
@ -60,7 +72,7 @@ let AclButton = React.createClass({
}
currentUser={ this.props.currentUser }
editions={ this.props.editions }
handleSuccess={ this.props.handleSuccess }
handleSuccess={ aclProps.handleSuccess }
title={ aclProps.title }
tooltip={ aclProps.tooltip }>
{ aclProps.form }

View File

@ -2,12 +2,13 @@
import React from 'react';
/*
Is this even used somewhere?
Deprecate? 5.6.15 - Tim
*/
let ButtonSubmitOrClose = React.createClass({
propTypes: {
submitted: React.PropTypes.bool.isRequired,
text: React.PropTypes.string.isRequired,
onClose: React.PropTypes.func.isRequired
},
render() {
if (this.props.submitted){
return (

View File

@ -4,6 +4,10 @@ import React from 'react';
import Alert from 'react-bootstrap/lib/Alert';
let AlertDismissable = React.createClass({
propTypes: {
error: React.PropTypes.array.isRequired
},
getInitialState() {
return {
alertVisible: true
@ -20,7 +24,6 @@ let AlertDismissable = React.createClass({
render() {
if (this.state.alertVisible) {
let key = this.props.error;
return (
<Alert bsStyle='danger' onDismiss={this.hide}>
{this.props.error}

View File

@ -11,6 +11,7 @@ import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
let ConsignForm = React.createClass({
mixins: [FormMixin],
url() {
return ApiUrls.ownership_consigns;
},

View File

@ -5,6 +5,11 @@ import React from 'react';
import AlertMixin from '../../mixins/alert_mixin';
let InputCheckbox = React.createClass({
propTypes: {
submitted: React.PropTypes.bool.isRequired,
required: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired
},
mixins: [AlertMixin],

View File

@ -6,6 +6,10 @@ import AlertMixin from '../../mixins/alert_mixin';
import DatePicker from 'react-datepicker/dist/react-datepicker';
let InputDate = React.createClass({
propTypes: {
submitted: React.PropTypes.bool,
placeholderText: React.PropTypes.string
},
mixins: [AlertMixin],
@ -20,11 +24,10 @@ let InputDate = React.createClass({
handleChange(date) {
this.setState({
value: date,
value_formatted: date.format("YYYY-MM-DD")});
value_formatted: date.format('YYYY-MM-DD')});
},
render: function () {
let className = 'form-control input-text-ascribe';
let alerts = (this.props.submitted) ? null : this.state.alerts;
return (
<div className="form-group">
@ -37,24 +40,6 @@ let InputDate = React.createClass({
placeholderText={this.props.placeholderText}/>
</div>
);
// CAN THIS BE REMOVED???
//
// - Tim?
//
//return (
// <div className="input-group date"
// ref={this.props.name + "_picker"}
// onChange={this.handleChange}>
// <input className={className}
// ref={this.props.name}
// placeholder={this.props.placeholder}
// required={this.props.required}
// type="text"/>
// <span className="input-group-addon input-text-ascribe">
// <span className="glyphicon glyphicon-calendar" style={{"color": "black"}}></span>
// </span>
// </div>
//)
}
});

View File

@ -5,6 +5,10 @@ import React from 'react';
import AlertMixin from '../../mixins/alert_mixin';
let InputHidden = React.createClass({
propTypes: {
submitted: React.PropTypes.bool,
value: React.PropTypes.string
},
mixins: [AlertMixin],

View File

@ -5,6 +5,13 @@ import React from 'react';
import AlertMixin from '../../mixins/alert_mixin';
let InputText = React.createClass({
propTypes: {
submitted: React.PropTypes.bool,
onBlur: React.PropTypes.func,
type: React.PropTypes.string,
required: React.PropTypes.string,
placeHolder: React.PropTypes.string
},
mixins: [AlertMixin],

View File

@ -5,6 +5,11 @@ import React from 'react';
import AlertMixin from '../../mixins/alert_mixin';
let InputTextArea = React.createClass({
propTypes: {
submitted: React.PropTypes.bool,
required: React.PropTypes.string,
defaultValue: React.PropTypes.string
},
mixins: [AlertMixin],

View File

@ -8,6 +8,15 @@ import Button from 'react-bootstrap/lib/Button';
let InputTextAreaToggable = React.createClass({
propTypes: {
editable: React.PropTypes.bool.isRequired,
submitted: React.PropTypes.bool,
rows: React.PropTypes.number.isRequired,
onSubmit: React.PropTypes.func.isRequired,
required: React.PropTypes.string,
defaultValue: React.PropTypes.string
},
mixins: [AlertMixin],
getInitialState() {

View File

@ -11,6 +11,16 @@ import Tooltip from 'react-bootstrap/lib/Tooltip';
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,
children: React.PropTypes.object,
tooltip: React.PropTypes.string.isRequired
},
render() {
return (
@ -32,13 +42,21 @@ 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,
title: React.PropTypes.string.isRequired
},
mixins: [ModalMixin],
handleSuccess(){
this.props.handleSuccess();
handleSuccess(response){
this.props.handleSuccess(response);
this.props.onRequestHide();
},

View File

@ -93,7 +93,6 @@ let PieceListBulkModal = React.createClass({
.forEach((pieceId) => {
EditionListActions.fetchEditionList(pieceId, this.state.orderBy, this.state.orderAsc);
});
GlobalNotificationActions.updateGlobalNotification({message: 'Transfer successful'});
EditionListActions.clearAllEditionSelections();
},

View File

@ -73,6 +73,12 @@ let Edition = React.createClass({
handleSuccess={this.props.loadEdition}
edition={this.props.edition}/>
</CollapsibleEditionDetails>
<CollapsibleEditionDetails
title="Further Details">
<EditionFurtherDetails
handleSuccess={this.props.loadEdition}
edition={this.props.edition}/>
</CollapsibleEditionDetails>
<CollapsibleEditionDetails
title="Provenance/Ownership History"
@ -310,12 +316,29 @@ let EditionDetailHistoryIterator = React.createClass({
let EditionPersonalNote = React.createClass({
propTypes: {
edition: React.PropTypes.object
edition: React.PropTypes.object,
handleSuccess: React.PropTypes.func
},
prepareSavePersonalNote() {
let personalNote = React.findDOMNode(this.refs.personalNote).value;
this.props.savePersonalNote(personalNote);
render() {
return (
<Row>
<Col md={12} className="ascribe-edition-personal-note">
<PersonalNoteForm
handleSuccess={this.props.handleSuccess}
editions={[this.props.edition]} />
</Col>
</Row>
);
}
});
let EditionFurtherDetails = React.createClass({
propTypes: {
edition: React.PropTypes.object,
handleSuccess: React.PropTypes.func
},
render() {

View File

@ -27,7 +27,10 @@ let PieceList = React.createClass({
componentDidMount() {
let page = this.props.query.page || 1;
PieceListStore.listen(this.onChange);
if (this.state.pieceList.length === 0){
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
}
},
componentWillUnmount() {

View File

@ -6,6 +6,11 @@ import React from 'react';
import AlertDismissable from '../components/ascribe_forms/alert';
export const FormMixin = {
propTypes: {
editions: React.PropTypes.array,
currentUser: React.PropTypes.object
},
getInitialState() {
return {
submitted: false,
@ -21,7 +26,7 @@ export const FormMixin = {
this.clearErrors();
fetch
.post(this.url(), { body: this.getFormData() })
.then(() => this.handleSuccess() )
.then(this.handleSuccess)
.catch(this.handleError);
},
@ -34,9 +39,9 @@ export const FormMixin = {
}
this.setState({errors: []});
},
handleSuccess(){
handleSuccess(response){
if ('handleSuccess' in this.props){
this.props.handleSuccess();
this.props.handleSuccess(response);
}
},