From 509aa111ab118b52ecad38a6111d1f5655bbe57f Mon Sep 17 00:00:00 2001 From: ddejongh Date: Tue, 9 Jun 2015 16:10:38 +0200 Subject: [PATCH] Merge remote-tracking branch 'remotes/origin/master' into AD-43-in-piece_detail-add-generic-field- Conflicts: gulpfile.js added notifications cleaned up proptypes --- js/components/ascribe_buttons/acl_button.js | 22 ++++++++++--- .../ascribe_buttons/button_submit_close.js | 11 ++++--- js/components/ascribe_forms/alert.js | 5 ++- js/components/ascribe_forms/form_consign.js | 1 + js/components/ascribe_forms/input_checkbox.js | 5 +++ js/components/ascribe_forms/input_date.js | 25 +++------------ js/components/ascribe_forms/input_hidden.js | 4 +++ js/components/ascribe_forms/input_text.js | 7 +++++ js/components/ascribe_forms/input_textarea.js | 5 +++ .../ascribe_forms/input_textarea_toggable.js | 9 ++++++ js/components/ascribe_modal/modal_wrapper.js | 24 ++++++++++++-- .../piece_list_bulk_modal.js | 1 - js/components/edition.js | 31 ++++++++++++++++--- js/components/piece_list.js | 5 ++- js/mixins/form_mixin.js | 11 +++++-- 15 files changed, 123 insertions(+), 43 deletions(-) diff --git a/js/components/ascribe_buttons/acl_button.js b/js/components/ascribe_buttons/acl_button.js index 518a80d6..18fdf4da 100644 --- a/js/components/ascribe_buttons/acl_button.js +++ b/js/components/ascribe_buttons/acl_button.js @@ -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: + form: , + handleSuccess: this.showNotification }; } else if (this.props.action === 'transfer') { return { title: 'Transfer artwork', tooltip: 'Transfer the ownership of the artwork', - form: + form: , + handleSuccess: this.showNotification }; } else if (this.props.action === 'loan'){ return { title: 'Loan artwork', tooltip: 'Loan your artwork for a limited period of time', - form: + form: , + handleSuccess: this.showNotification }; } else if (this.props.action === 'share'){ return { title: 'Share artwork', tooltip: 'Share the artwork', - form: + form: , + 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 } diff --git a/js/components/ascribe_buttons/button_submit_close.js b/js/components/ascribe_buttons/button_submit_close.js index 2d70fb03..d5a94f91 100644 --- a/js/components/ascribe_buttons/button_submit_close.js +++ b/js/components/ascribe_buttons/button_submit_close.js @@ -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 ( diff --git a/js/components/ascribe_forms/alert.js b/js/components/ascribe_forms/alert.js index 4d5bae64..21f378ef 100644 --- a/js/components/ascribe_forms/alert.js +++ b/js/components/ascribe_forms/alert.js @@ -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 ( {this.props.error} diff --git a/js/components/ascribe_forms/form_consign.js b/js/components/ascribe_forms/form_consign.js index 0137e4a0..42f909a8 100644 --- a/js/components/ascribe_forms/form_consign.js +++ b/js/components/ascribe_forms/form_consign.js @@ -11,6 +11,7 @@ import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close'; let ConsignForm = React.createClass({ mixins: [FormMixin], + url() { return ApiUrls.ownership_consigns; }, diff --git a/js/components/ascribe_forms/input_checkbox.js b/js/components/ascribe_forms/input_checkbox.js index 187a1acf..28f75bc3 100644 --- a/js/components/ascribe_forms/input_checkbox.js +++ b/js/components/ascribe_forms/input_checkbox.js @@ -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], diff --git a/js/components/ascribe_forms/input_date.js b/js/components/ascribe_forms/input_date.js index 5ae1221a..56af046e 100644 --- a/js/components/ascribe_forms/input_date.js +++ b/js/components/ascribe_forms/input_date.js @@ -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 (
@@ -37,24 +40,6 @@ let InputDate = React.createClass({ placeholderText={this.props.placeholderText}/>
); - // CAN THIS BE REMOVED??? - // - // - Tim? - // - //return ( - //
- // - // - // - // - //
- //) } }); diff --git a/js/components/ascribe_forms/input_hidden.js b/js/components/ascribe_forms/input_hidden.js index c221372f..b6a8ac46 100644 --- a/js/components/ascribe_forms/input_hidden.js +++ b/js/components/ascribe_forms/input_hidden.js @@ -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], diff --git a/js/components/ascribe_forms/input_text.js b/js/components/ascribe_forms/input_text.js index b35c1ac5..7f0ee5d0 100644 --- a/js/components/ascribe_forms/input_text.js +++ b/js/components/ascribe_forms/input_text.js @@ -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], diff --git a/js/components/ascribe_forms/input_textarea.js b/js/components/ascribe_forms/input_textarea.js index 1d7af441..2c5ab40a 100644 --- a/js/components/ascribe_forms/input_textarea.js +++ b/js/components/ascribe_forms/input_textarea.js @@ -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], diff --git a/js/components/ascribe_forms/input_textarea_toggable.js b/js/components/ascribe_forms/input_textarea_toggable.js index e7faea9c..22e95fda 100644 --- a/js/components/ascribe_forms/input_textarea_toggable.js +++ b/js/components/ascribe_forms/input_textarea_toggable.js @@ -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() { diff --git a/js/components/ascribe_modal/modal_wrapper.js b/js/components/ascribe_modal/modal_wrapper.js index 0342bfb6..86246419 100644 --- a/js/components/ascribe_modal/modal_wrapper.js +++ b/js/components/ascribe_modal/modal_wrapper.js @@ -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(); }, diff --git a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js index 48c02221..5c9d691b 100644 --- a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js +++ b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js @@ -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(); }, diff --git a/js/components/edition.js b/js/components/edition.js index deb53620..31248f99 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -73,6 +73,12 @@ let Edition = React.createClass({ handleSuccess={this.props.loadEdition} edition={this.props.edition}/> + + + + + + + + ); + } +}); + + + +let EditionFurtherDetails = React.createClass({ + propTypes: { + edition: React.PropTypes.object, + handleSuccess: React.PropTypes.func }, render() { diff --git a/js/components/piece_list.js b/js/components/piece_list.js index 479b9c3f..ffe461a5 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -27,7 +27,10 @@ let PieceList = React.createClass({ componentDidMount() { let page = this.props.query.page || 1; PieceListStore.listen(this.onChange); - PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); + if (this.state.pieceList.length === 0){ + PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); + } + }, componentWillUnmount() { diff --git a/js/mixins/form_mixin.js b/js/mixins/form_mixin.js index e0cc39f1..35a95bd5 100644 --- a/js/mixins/form_mixin.js +++ b/js/mixins/form_mixin.js @@ -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); } },