From 17cb2223c2358a28782d8277e57117748eea514d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 16 Sep 2015 09:47:22 +0200 Subject: [PATCH] finalize contract update button --- js/actions/contract_list_actions.js | 2 +- .../ascribe_settings/contract_settings.js | 26 ++------------ .../contract_settings_update_button.js | 36 ++++++++++++++++--- .../ascribe_upload_button/upload_button.js | 5 +-- js/fetchers/ownership_fetcher.js | 2 +- 5 files changed, 38 insertions(+), 33 deletions(-) diff --git a/js/actions/contract_list_actions.js b/js/actions/contract_list_actions.js index a856fb2b..5b874caf 100644 --- a/js/actions/contract_list_actions.js +++ b/js/actions/contract_list_actions.js @@ -30,7 +30,7 @@ class ContractListActions { changeContract(contract){ return Q.Promise((resolve, reject) => { - OwnershipFetcher.makeContractPublic(contract) + OwnershipFetcher.changeContract(contract) .then((res) => { resolve(res); }) diff --git a/js/components/ascribe_settings/contract_settings.js b/js/components/ascribe_settings/contract_settings.js index 00b37b78..278c0f52 100644 --- a/js/components/ascribe_settings/contract_settings.js +++ b/js/components/ascribe_settings/contract_settings.js @@ -39,23 +39,6 @@ let ContractSettings = React.createClass({ this.setState(state); }, - makeContractPublic(contract) { - return () => { - contract.is_public = true; - ContractListActions.changeContract(contract) - .then(() => { - ContractListActions.fetchContractList(true); - let notification = getLangText('Contract %s is now public', contract.name); - notification = new GlobalNotificationModel(notification, 'success', 4000); - GlobalNotificationActions.appendGlobalNotification(notification); - }) - .catch((err) => { - let notification = new GlobalNotificationModel(err, 'danger', 10000); - GlobalNotificationActions.appendGlobalNotification(notification); - }); - }; - }, - removeContract(contract) { return () => { ContractListActions.removeContract(contract.id) @@ -113,7 +96,7 @@ let ContractSettings = React.createClass({ content={contract.name} buttons={
- + - - + { + let notification = new GlobalNotificationModel(getLangText('Contract %s successfully updated', res.name), 'success', 5000); + GlobalNotificationActions.appendGlobalNotification(notification); + + return ContractListActions.fetchContractList(true); + }) + .then(() => { + this.refs.fineuploader.reset(); + }) + .catch((err) => { + console.logGlobal(err); + let notification = new GlobalNotificationModel(getLangText('Contract could not be updated'), 'success', 5000); + GlobalNotificationActions.appendGlobalNotification(notification); + }); }, render() { return ( {/* So that ReactS3FineUploader is not complaining */}} signature={{ endpoint: AppConstants.serverUrl + 's3/signature/', customHeaders: { diff --git a/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js b/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js index a3fa985c..47347d46 100644 --- a/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js +++ b/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js @@ -3,6 +3,8 @@ import React from 'react'; import { displayValidProgressFilesFilter } from '../react_s3_fine_uploader_utils'; +import { getLangText } from '../../../utils/lang_utils'; + let UploadButton = React.createClass({ propTypes: { @@ -22,7 +24,6 @@ let UploadButton = React.createClass({ handleResumeFile: React.PropTypes.func, multiple: React.PropTypes.bool, - // For simplification purposes we're just going to use this prop as a // label for the upload button fileClassToUpload: React.PropTypes.shape({ @@ -76,7 +77,7 @@ let UploadButton = React.createClass({ // Depending on wether there is an upload going on or not we // display the progress if(filesToUpload.length > 0) { - return 'Upload progress: ' + Math.ceil(filesToUpload[0].progress) + '%'; + return getLangText('Upload progress') + ': ' + Math.ceil(filesToUpload[0].progress) + '%'; } else { return fileClassToUpload.singular; } diff --git a/js/fetchers/ownership_fetcher.js b/js/fetchers/ownership_fetcher.js index fde66c7d..f9ce5f86 100644 --- a/js/fetchers/ownership_fetcher.js +++ b/js/fetchers/ownership_fetcher.js @@ -48,7 +48,7 @@ let OwnershipFetcher = { return requests.get(ApiUrls.ownership_loans_pieces_request); }, - makeContractPublic(contractObj){ + changeContract(contractObj){ return requests.put(ApiUrls.ownership_contract, { body: contractObj, contract_id: contractObj.id }); },