From d6bd4b4ac1914ced446795695f9efd85acd9f20d Mon Sep 17 00:00:00 2001 From: diminator Date: Wed, 16 Sep 2015 14:07:13 +0200 Subject: [PATCH] bug fix acl button form copyright association + account settings bug fix dispatch in form loan ikonotv slides --- js/actions/contract_agreement_list_actions.js | 11 +++ js/components/ascribe_buttons/acl_button.js | 33 +++---- .../ascribe_forms/form_contract_agreement.js | 89 +++++++++++-------- .../form_copyright_association.js | 75 ++++++++++++++++ js/components/ascribe_forms/form_loan.js | 23 ++--- .../ascribe_settings/account_settings.js | 3 + .../ikonotv_additional_data_form.js | 13 +-- .../ikonotv/ikonotv_contract_notifications.js | 83 +++++++++-------- js/constants/application_constants.js | 6 +- 9 files changed, 221 insertions(+), 115 deletions(-) create mode 100644 js/components/ascribe_forms/form_copyright_association.js diff --git a/js/actions/contract_agreement_list_actions.js b/js/actions/contract_agreement_list_actions.js index 86988f47..f2959901 100644 --- a/js/actions/contract_agreement_list_actions.js +++ b/js/actions/contract_agreement_list_actions.js @@ -89,6 +89,17 @@ class ContractAgreementListActions { }); } + flushContractAgreementList(){ + return Q.Promise((resolve, reject) => { + this.actions.updateContractAgreementList(null).then( + resolve() + ).catch((err) => { + console.logGlobal(err); + reject(err); + }); + }); + } + } export default alt.createActions(ContractAgreementListActions); diff --git a/js/components/ascribe_buttons/acl_button.js b/js/components/ascribe_buttons/acl_button.js index 084de194..e3c7fa1c 100644 --- a/js/components/ascribe_buttons/acl_button.js +++ b/js/components/ascribe_buttons/acl_button.js @@ -162,21 +162,24 @@ let AclButton = React.createClass({ }, render() { - let shouldDisplay = this.props.availableAcls[this.props.action]; - let aclProps = this.actionProperties(); - let buttonClassName = this.props.buttonAcceptClassName ? this.props.buttonAcceptClassName : ''; - return ( - - {this.sanitizeAction()} - - } - handleSuccess={aclProps.handleSuccess} - title={aclProps.title}> - {aclProps.form} - - ); + if (this.props.availableAcls){ + let shouldDisplay = this.props.availableAcls[this.props.action]; + let aclProps = this.actionProperties(); + let buttonClassName = this.props.buttonAcceptClassName ? this.props.buttonAcceptClassName : ''; + return ( + + {this.sanitizeAction()} + + } + handleSuccess={aclProps.handleSuccess} + title={aclProps.title}> + {aclProps.form} + + ); + } + return null; } }); diff --git a/js/components/ascribe_forms/form_contract_agreement.js b/js/components/ascribe_forms/form_contract_agreement.js index fb6793e6..94ab26d0 100644 --- a/js/components/ascribe_forms/form_contract_agreement.js +++ b/js/components/ascribe_forms/form_contract_agreement.js @@ -35,7 +35,7 @@ let ContractAgreementForm = React.createClass({ componentDidMount() { ContractListStore.listen(this.onChange); - ContractListActions.fetchContractList(true); + ContractListActions.fetchContractList(true, false); }, componentWillUnmount() { @@ -95,45 +95,56 @@ let ContractAgreementForm = React.createClass({ }, render() { + if (this.state.contractList && this.state.contractList.length > 0) { + return ( +
+ {getLangText('Send loan request')} + } + spinner={ + + + + }> +
+

{getLangText('Contract form')}

+
+ + + + {this.getContracts()} + + {getLangText('Appendix')} + + +
+ ); + } return ( -
- {getLangText('Send loan request')} - } - spinner={ - - - - }> -
-

{getLangText('Contract form')}

-
- - - - {this.getContracts()} - - {getLangText('Appendix')} - - -
+
+

+ {getLangText('No private contracts found, please go to the ')} + {getLangText('settings page')} + {getLangText(' and create them.')} +

+
); } }); diff --git a/js/components/ascribe_forms/form_copyright_association.js b/js/components/ascribe_forms/form_copyright_association.js new file mode 100644 index 00000000..451afb97 --- /dev/null +++ b/js/components/ascribe_forms/form_copyright_association.js @@ -0,0 +1,75 @@ +'use strict'; + +import React from 'react'; + +import GlobalNotificationModel from '../../models/global_notification_model'; +import GlobalNotificationActions from '../../actions/global_notification_actions'; + +import Form from './form'; +import Property from './property'; + +import apiUrls from '../../constants/api_urls'; +import appConstants from '../../constants/application_constants'; + +import { getLangText } from '../../utils/lang_utils'; + +let CopyrightAssociationForm = React.createClass({ + propTypes: { + currentUser: React.PropTypes.object + }, + + handleSubmitSuccess(){ + let notification = getLangText('Copyright association updated'); + notification = new GlobalNotificationModel(notification, 'success', 10000); + GlobalNotificationActions.appendGlobalNotification(notification); + }, + + getProfileFormData(){ + if (this.props.currentUser && this.props.currentUser.email){ + return {email: this.props.currentUser.email}; + } + return null; + }, + + render() { + let selectedState = -1; + if (this.props.currentUser + && this.props.currentUser.profile + && this.props.currentUser.profile.copyright_association) { + selectedState = appConstants.copyrightAssociations.indexOf(this.props.currentUser.profile.copyright_association); + } + return ( +
+ + + +
+
+ ); + } +}); + +export default CopyrightAssociationForm; \ No newline at end of file diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index dacbae77..a1c31330 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -61,7 +61,7 @@ let LoanForm = React.createClass({ // however, it can also be that at the time the component is mounting, // the email is not defined (because it's asynchronously fetched from the server). // Then we need to update it as soon as it is included into LoanForm's props. - if(nextProps && nextProps.email) { + if(nextProps && nextProps.email && this.props.email !== nextProps.email) { this.getContractAgreementsOrCreatePublic(nextProps.email); } }, @@ -75,16 +75,19 @@ let LoanForm = React.createClass({ }, getContractAgreementsOrCreatePublic(email){ - ContractAgreementListActions.flushContractAgreementList(); - if (email) { - ContractAgreementListActions.fetchAvailableContractAgreementList(email).then( - (contractAgreementList) => { - if (!contractAgreementList) { - ContractAgreementListActions.createContractAgreementFromPublicContract(email); + /* a more complex defer (with promises) otherwise we dispatch while an action is being dispatched) */ + window.setTimeout(() => { + ContractAgreementListActions.flushContractAgreementList(); + + if (email) { + ContractAgreementListActions.fetchAvailableContractAgreementList(email).then( + (contractAgreementList) => { + if (!contractAgreementList) { + ContractAgreementListActions.createContractAgreementFromPublicContract(email); + } } - } - ); - } + ); + }}, 0); }, getFormData(){ diff --git a/js/components/ascribe_settings/account_settings.js b/js/components/ascribe_settings/account_settings.js index b4d46b2d..93a419c2 100644 --- a/js/components/ascribe_settings/account_settings.js +++ b/js/components/ascribe_settings/account_settings.js @@ -13,6 +13,8 @@ import Property from '../ascribe_forms/property'; import InputCheckbox from '../ascribe_forms/input_checkbox'; import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph'; +import CopyrightAssociationForm from '../ascribe_forms/form_copyright_association'; + import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; @@ -117,6 +119,7 @@ let AccountSettings = React.createClass({ show={true} defaultExpanded={true}> {content} + {profile} {/*
diff --git a/js/components/whitelabel/wallet/components/ikonotv/ascribe_forms/ikonotv_additional_data_form.js b/js/components/whitelabel/wallet/components/ikonotv/ascribe_forms/ikonotv_additional_data_form.js index 6a2f8cc5..6f249c7b 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ascribe_forms/ikonotv_additional_data_form.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ascribe_forms/ikonotv_additional_data_form.js @@ -7,7 +7,7 @@ import Property from '../../../../../ascribe_forms/property'; import InputTextAreaToggable from '../../../../../ascribe_forms/input_textarea_toggable'; -import FurtherDetailsFileuploader from '../../../../../ascribe_detail/further_details_fileuploader'; +//import FurtherDetailsFileuploader from '../../../../../ascribe_detail/further_details_fileuploader'; import ApiUrls from '../../../../../../constants/api_urls'; import AppConstants from '../../../../../../constants/application_constants'; @@ -15,7 +15,7 @@ import AppConstants from '../../../../../../constants/application_constants'; import requests from '../../../../../../utils/requests'; import { getLangText } from '../../../../../../utils/lang_utils'; -import { formSubmissionValidation } from '../../../../../ascribe_uploader/react_s3_fine_uploader_utils'; +//import { formSubmissionValidation } from '../../../../../ascribe_uploader/react_s3_fine_uploader_utils'; let IkonotvAdditionalDataForm = React.createClass({ @@ -110,15 +110,6 @@ let IkonotvAdditionalDataForm = React.createClass({ placeholder={getLangText('Enter a conceptual overview...')} required="required"/> - ); } else { diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js index 6a63657c..beffe23a 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js @@ -6,17 +6,18 @@ import Router from 'react-router'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Button from 'react-bootstrap/lib/Button'; -import Form from '../../../../ascribe_forms/form'; -import Property from '../../../../ascribe_forms/property'; -import InputCheckbox from '../../../../ascribe_forms/input_checkbox'; - import NotificationActions from '../../../../../actions/notification_actions'; import NotificationStore from '../../../../../stores/notification_store'; + +import UserStore from '../../../../../stores/user_store'; + import WhitelabelStore from '../../../../../stores/whitelabel_store'; import GlobalNotificationModel from '../../../../../models/global_notification_model'; import GlobalNotificationActions from '../../../../../actions/global_notification_actions'; +import CopyrightAssociationForm from '../../../../ascribe_forms/form_copyright_association'; + import apiUrls from '../../../../../constants/api_urls'; import requests from '../../../../../utils/requests'; @@ -32,12 +33,14 @@ let IkonotvContractNotifications = React.createClass({ getInitialState() { return mergeOptions( NotificationStore.getState(), + UserStore.getState(), WhitelabelStore.getState() ); }, componentDidMount() { NotificationStore.listen(this.onChange); + UserStore.listen(this.onChange); WhitelabelStore.listen(this.onChange); if (this.state.contractAgreementListNotifications === null){ NotificationActions.fetchContractAgreementListNotifications(); @@ -88,7 +91,8 @@ let IkonotvContractNotifications = React.createClass({ let notifications = this.state.contractAgreementListNotifications[0]; let appendix = notifications.contract_agreement.appendix; if (appendix) { - return (
+ return ( +

{getLangText('Appendix')}

                         {appendix.default}
@@ -99,6 +103,13 @@ let IkonotvContractNotifications = React.createClass({
         return null;
     },
 
+    handleConfirm() {
+        let contractAgreement = this.state.contractAgreementListNotifications[0].contract_agreement;
+        requests.put(apiUrls.ownership_contract_agreements_confirm, {contract_agreement_id: contractAgreement.id}).then(
+            () => this.handleConfirmSuccess()
+        );
+    },
+
     handleConfirmSuccess() {
         let notification = new GlobalNotificationModel(getLangText('You have accepted the conditions'), 'success', 10000);
         GlobalNotificationActions.appendGlobalNotification(notification);
@@ -118,11 +129,29 @@ let IkonotvContractNotifications = React.createClass({
         this.transitionTo('pieces');
     },
 
+    getCopyrightAssociationForm(){
+        if (this.state.currentUser && this.state.currentUser.profile
+            && this.state.currentUser.profile.copyright_association){
+            return null;
+        }
+        return (
+            
+

{getLangText('Are you a member of any copyright societies?')}

+

+ ARS, DACS, Bildkunst, Pictoright, SODRAC, Copyright Agency/Viscopy, SAVA, Bildrecht GmbH, + SABAM, AUTVIS, CREAIMAGEN, SONECA, Copydan, EAU, Kuvasto, GCA, HUNGART, IVARO, SIAE, JASPAR-SPDA, + AKKA/LAA, LATGA-A, SOMAAP, ARTEGESTION, CARIER, BONO, APSAV, SPA, GESTOR, VISaRTA, RAO, LITA, + DALRO, VeGaP, BUS, ProLitteris, AGADU, AUTORARTE, BUBEDRA, BBDA, BCDA, BURIDA, ADAVIS, BSDA +

+ +
+ ); + }, + render() { if (this.state.contractAgreementListNotifications && this.state.contractAgreementListNotifications.length > 0) { - let contractAgreement = this.state.contractAgreementListNotifications[0].contract_agreement; return (
@@ -133,41 +162,17 @@ let IkonotvContractNotifications = React.createClass({
{this.getContract()} -
- {this.getAppendix} -

{getLangText('Are you a member of any copyright societies?')}

-

- ARS, DACS, Bildkunst, Pictoright, SODRAC, Copyright Agency/Viscopy, SAVA, Bildrecht GmbH, - SABAM, AUTVIS, CREAIMAGEN, SONECA, Copydan, EAU, Kuvasto, GCA, HUNGART, IVARO, SIAE, JASPAR-SPDA, - AKKA/LAA, LATGA-A, SOMAAP, ARTEGESTION, CARIER, BONO, APSAV, SPA, GESTOR, VISaRTA, RAO, LITA, - DALRO, VeGaP, BUS, ProLitteris, AGADU, AUTORARTE, BUBEDRA, BBDA, BCDA, BURIDA, ADAVIS, BSDA + {this.getAppendix()} + {this.getCopyrightAssociationForm()} +

+ +

-
- - -

- }> - - - - {' ' + getLangText('Yes') } - - - - -
diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index f1455029..3b3c4a9f 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -61,7 +61,11 @@ let constants = { 'whitelabel': {}, 'raven': { 'url': 'https://0955da3388c64ab29bd32c2a429f9ef4@app.getsentry.com/48351' - } + }, + 'copyrightAssociations': ['ARS', 'DACS', 'Bildkunst', 'Pictoright', 'SODRAC', 'Copyright Agency/Viscopy', 'SAVA', + 'Bildrecht GmbH', 'SABAM', 'AUTVIS', 'CREAIMAGEN', 'SONECA', 'Copydan', 'EAU', 'Kuvasto', 'GCA', 'HUNGART', + 'IVARO', 'SIAE', 'JASPAR-SPDA', 'AKKA/LAA', 'LATGA-A', 'SOMAAP', 'ARTEGESTION', 'CARIER', 'BONO', 'APSAV', + 'SPA', 'GESTOR', 'VISaRTA', 'RAO', 'LITA', 'DALRO', 'VeGaP', 'BUS', 'ProLitteris', 'AGADU', 'AUTORARTE', 'BUBEDRA', 'BBDA', 'BCDA', 'BURIDA', 'ADAVIS', 'BSDA'] }; export default constants;