Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit ab064dd

Browse files
committed
Close the quick-add UI as soon as the user posts a new event, show an error message if it fails.
Fixes #208
1 parent d054729 commit ab064dd

File tree

8 files changed

+43
-1
lines changed

8 files changed

+43
-1
lines changed

src/_locales/de/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
"message": "Probleme?",
5656
"description": "A link that provides troubleshooting information related to authorization."
5757
},
58+
"error_saving_new_event": {
59+
"message": "Fehler beim Speichern der neuen Veranstaltung; Bitte versuchen Sie es erneut.",
60+
"description": "An error message shown when a user-added quick-add event could not be saved."
61+
},
5862
"add_to_google_calendar": {
5963
"message": "Zu Google Kalender hinzufügen",
6064
"description": "Alt text and/or link text for the link that users click to add event to their calendar."

src/_locales/en/messages.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
"description": "A link that provides troubleshooting information related to authorization."
7070
},
7171

72+
"error_saving_new_event": {
73+
"message": "Error saving new event; please retry.",
74+
"description": "An error message shown when a user-added quick-add event could not be saved."
75+
},
76+
7277
"add_to_google_calendar": {
7378
"message": "Add to Google Calendar",
7479
"description": "Alt text and/or link text for the link that users click to add event to their calendar."

src/_locales/es/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
"message": "¿Problemas?",
5656
"description": "A link that provides troubleshooting information related to authorization."
5757
},
58+
"error_saving_new_event": {
59+
"message": "Error al guardar nuevo evento; por favor vuelva a intentar.",
60+
"description": "An error message shown when a user-added quick-add event could not be saved."
61+
},
5862
"add_to_google_calendar": {
5963
"message": "Añadir a Google Calendar",
6064
"description": "Alt text and/or link text for the link that users click to add event to their calendar."

src/_locales/nl/messages.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
"description": "A link that provides troubleshooting information related to authorization."
7070
},
7171

72+
"error_saving_new_event": {
73+
"message": "Fout bij het opslaan van nieuwe gebeurtenis; Probeer het opnieuw.",
74+
"description": "An error message shown when a user-added quick-add event could not be saved."
75+
},
76+
7277
"add_to_google_calendar": {
7378
"message": "Toevoegen aan Google Agenda",
7479
"description": "Alt text and/or link text for the link that users click to add event to their calendar."

src/browser_action.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ header {
8383
margin-bottom: 8px;
8484
}
8585

86+
#info_bar {
87+
background: #ffdbdd;
88+
color: #000;
89+
display: none;
90+
padding: 8px;
91+
width: 100%;
92+
margin-bottom: 8px;
93+
}
94+
8695
section {
8796
padding: 0 8px;
8897
}

src/browser_action.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<div class="header-placeholder"></div>
3131
<section>
3232
<a id="announcement_new_features" class="i18n" href="https://github.com/manastungare/google-calendar-crx/wiki/Changes" target="_blank"></a>
33+
<div id="info_bar"></div>
3334
<div id="error">
3435
<p class="i18n" id="authorization_explanation"></p>
3536
<p><button class="button i18n" id="authorization_required"></button></p>

src/browser_action.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ browseraction.installButtonClickHandlers_ = function() {
137137
_gaq.push(['_trackEvent', 'Quick Add', 'Event Created']);
138138
browseraction.createQuickAddEvent_($('#quick-add-event-title').val().toString(),
139139
$('#quick-add-calendar-list').val());
140+
$('#quick-add-event-title').val(''); // Remove the existing text from the field.
140141
});
141142
};
142143

@@ -218,23 +219,30 @@ browseraction.createQuickAddEvent_ = function(text, calendarId) {
218219
_gaq.push(['_trackEvent', 'getAuthToken', 'OK']);
219220
_gaq.push(['_trackEvent', 'QuickAdd', 'Add']);
220221

222+
browseraction.startSpinner();
221223
$.ajax(quickAddUrl, {
222224
type: 'POST',
223225
headers: {
224226
'Authorization': 'Bearer ' + authToken
225227
},
226228
success: function(response) {
229+
browseraction.stopSpinner();
227230
chrome.extension.sendMessage({method: 'events.feed.fetch'});
228-
$('#quick-add').slideUp(200);
229231
},
230232
error: function(response) {
233+
browseraction.stopSpinner();
234+
$('#info_bar').text(chrome.i18n.getMessage('error_saving_new_event')).slideDown();
235+
window.setTimeout(function() {
236+
$('#info_bar').slideUp();
237+
}, constants.INFO_BAR_DISMISS_TIMEOUT_MS);
231238
_gaq.push(['_trackEvent', 'QuickAdd', 'Error', response.statusText]);
232239
chrome.extension.getBackgroundPage().background.log('Error adding Quick Add event', response.statusText);
233240
if (response.status === 401) {
234241
chrome.identity.removeCachedAuthToken({ 'token': authToken }, function() {});
235242
}
236243
}
237244
});
245+
$('#quick-add').slideUp(200);
238246
});
239247
};
240248

src/constants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ constants.MENU_ITEM_VIEW_CALENDAR_WEB = 'view_web_calendar';
2323
* @const
2424
*/
2525
constants.EVENT_STATUS_DECLINED = 'declined';
26+
27+
/**
28+
* @type {number}
29+
* @const
30+
*/
31+
constants.INFO_BAR_DISMISS_TIMEOUT_MS = 5000;

0 commit comments

Comments
 (0)