From 984761a386c12a7d602c685db2049590874305f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 13 Oct 2015 16:12:05 +0200 Subject: [PATCH 01/12] Remove stopPropagation for event in FileDragAndDrop --- .../file_drag_and_drop.js | 3 +-- js/utils/requests.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop.js b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop.js index 4c9211c5..57d87b76 100644 --- a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop.js +++ b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop.js @@ -121,13 +121,12 @@ let FileDragAndDrop = React.createClass({ // Firefox only recognizes the simulated mouse click if bubbles is set to true, // but since Google Chrome propagates the event much further than needed, we // need to stop propagation as soon as the event is created - var evt = new MouseEvent('click', { + let evt = new MouseEvent('click', { view: window, bubbles: true, cancelable: true }); - evt.stopPropagation(); this.refs.fileinput.getDOMNode().dispatchEvent(evt); }, diff --git a/js/utils/requests.js b/js/utils/requests.js index fd676896..7e9c9a58 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -57,12 +57,14 @@ class Requests { }); } - handleError(err) { - if (err instanceof TypeError) { - throw new Error('Server did not respond to the request. (Not even displayed a 500)'); - } else { - throw err; - } + handleError(url) { + return (err) => { + if (err instanceof TypeError) { + throw new Error('For: ' + url + ' - Server did not respond to the request. (Not even displayed a 500)'); + } else { + throw err; + } + }; } getUrl(url) { @@ -118,7 +120,7 @@ class Requests { merged.method = verb; return fetch(url, merged) .then(this.unpackResponse) - .catch(this.handleError); + .catch(this.handleError(url)); } get(url, params) { From 66dbf3da7168eb2c7713054cd170feb8296a2d1d Mon Sep 17 00:00:00 2001 From: vrde Date: Tue, 13 Oct 2015 16:42:40 +0200 Subject: [PATCH 02/12] Add document title management for the ascribe app --- .../ascribe_settings/account_settings.js | 2 +- .../ascribe_settings/contract_settings.js | 5 +++- .../ascribe_settings/settings_container.js | 4 +++ js/components/coa_verify_container.js | 3 ++ js/components/login_container.js | 3 ++ js/components/logout_container.js | 5 ++++ js/components/password_reset_container.js | 3 ++ js/components/piece_list.js | 3 ++ js/components/register_piece.js | 3 ++ js/components/signup_container.js | 3 ++ js/utils/dom_utils.js | 30 +++++++++++++++++++ 11 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 js/utils/dom_utils.js diff --git a/js/components/ascribe_settings/account_settings.js b/js/components/ascribe_settings/account_settings.js index 1898c599..e7bc4c2a 100644 --- a/js/components/ascribe_settings/account_settings.js +++ b/js/components/ascribe_settings/account_settings.js @@ -103,4 +103,4 @@ let AccountSettings = React.createClass({ } }); -export default AccountSettings; \ No newline at end of file +export default AccountSettings; diff --git a/js/components/ascribe_settings/contract_settings.js b/js/components/ascribe_settings/contract_settings.js index 741039ee..71d97542 100644 --- a/js/components/ascribe_settings/contract_settings.js +++ b/js/components/ascribe_settings/contract_settings.js @@ -23,6 +23,7 @@ import GlobalNotificationActions from '../../actions/global_notification_actions import AclProxy from '../acl_proxy'; import { getLangText } from '../../utils/lang_utils'; +import { setDocumentTitle } from '../../utils/dom_utils'; import { mergeOptions, truncateTextAtCharIndex } from '../../utils/general_utils'; @@ -86,6 +87,8 @@ let ContractSettings = React.createClass({ let privateContracts = this.getPrivateContracts(); let createPublicContractForm = null; + setDocumentTitle(getLangText('Contracts settings')); + if(publicContracts.length === 0) { createPublicContractForm = ( diff --git a/js/components/coa_verify_container.js b/js/components/coa_verify_container.js index a61e2d87..339b53f1 100644 --- a/js/components/coa_verify_container.js +++ b/js/components/coa_verify_container.js @@ -11,10 +11,13 @@ import InputTextAreaToggable from './ascribe_forms/input_textarea_toggable'; import ApiUrls from '../constants/api_urls'; import { getLangText } from '../utils/lang_utils'; +import { setDocumentTitle } from '../utils/dom_utils'; let CoaVerifyContainer = React.createClass({ render() { + setDocumentTitle(getLangText('Verify your Certificate of Authenticity')); + return (

diff --git a/js/components/login_container.js b/js/components/login_container.js index 33919cd6..46c14d65 100644 --- a/js/components/login_container.js +++ b/js/components/login_container.js @@ -6,6 +6,7 @@ import { Link } from 'react-router'; import LoginForm from './ascribe_forms/form_login'; import { getLangText } from '../utils/lang_utils'; +import { setDocumentTitle } from '../utils/dom_utils'; let LoginContainer = React.createClass({ @@ -26,6 +27,8 @@ let LoginContainer = React.createClass({ }, render() { + setDocumentTitle(getLangText('Log in')); + return (
); let AccordionListItemType = this.props.accordionListItemType; + setDocumentTitle(getLangText('Collection')); + return (
diff --git a/js/components/signup_container.js b/js/components/signup_container.js index 7c7b5ee7..e6c6fb73 100644 --- a/js/components/signup_container.js +++ b/js/components/signup_container.js @@ -6,6 +6,7 @@ import { Link } from 'react-router'; import SignupForm from './ascribe_forms/form_signup'; import { getLangText } from '../utils/lang_utils'; +import { setDocumentTitle } from '../utils/dom_utils'; let SignupContainer = React.createClass({ @@ -28,6 +29,8 @@ let SignupContainer = React.createClass({ }, render() { + setDocumentTitle(getLangText('Sign up')); + if (this.state.submitted){ return (
diff --git a/js/utils/dom_utils.js b/js/utils/dom_utils.js new file mode 100644 index 00000000..13f42cf2 --- /dev/null +++ b/js/utils/dom_utils.js @@ -0,0 +1,30 @@ +'use strict'; + + +/** + * Get the number of unread notifications in the title. + * + * @return {int} the number of unread notifications + */ +export function getUnreadCount() { + const match = document.title.match(/^\((\d+)\)/); + return match ? match[1] : null; +} + + +/** + * Set the title in the browser window while keeping the unread notification count (if any). + * + * @return {string} the new document title + */ +export function setDocumentTitle(title) { + const count = getUnreadCount(); + let newTitle = title; + + if (count) { + newTitle = `(${count}) ` + newTitle; + } + + document.title = newTitle; + return newTitle; +} From 84d2dd7701415569fcd3bf9b12556c98221a0543 Mon Sep 17 00:00:00 2001 From: vrde Date: Tue, 13 Oct 2015 17:02:03 +0200 Subject: [PATCH 03/12] Add document title for prize --- .../ascribe_detail/prize_piece_container.js | 13 ++++++++++++- .../prize/components/prize_login_container.js | 3 +++ .../whitelabel/prize/components/prize_piece_list.js | 3 +++ .../prize/components/prize_register_piece.js | 3 +++ .../prize/components/prize_settings_container.js | 3 +++ .../prize/components/prize_signup_container.js | 3 +++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js b/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js index 77774126..c875e576 100644 --- a/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js +++ b/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js @@ -40,6 +40,7 @@ import DetailProperty from '../../../../ascribe_detail/detail_property'; import ApiUrls from '../../../../../constants/api_urls'; import { mergeOptions } from '../../../../../utils/general_utils'; import { getLangText } from '../../../../../utils/lang_utils'; +import { setDocumentTitle } from '../../../../../utils/dom_utils'; /** @@ -112,12 +113,22 @@ let PieceContainer = React.createClass({ // Only show the artist name if you are the participant or if you are a judge and the piece is shortlisted let artistName = ((this.state.currentUser.is_jury && !this.state.currentUser.is_judge) || (this.state.currentUser.is_judge && !this.state.piece.selected )) ? -