Skip to content

Commit

Permalink
add message for retrieved content
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Sep 11, 2020
1 parent c61aa10 commit 6498360
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ $(() => {
],
});

const showMsg = (msg, error = false) => {
const time = error ? 5000 : 700;
const showMsg = (msg, error = false, default_time = 700) => {
const time = error ? 5000 : default_time;
const $div = $(`<div class="awesome_autosave-notice${error ? ' error' : ''}">${msg}</div>`)
.appendTo($form);
setTimeout(() => {
Expand All @@ -54,6 +54,10 @@ $(() => {
return;
}

if(window.localStorage.getItem(storeId)) {
showMsg(window.DecidimAwesome.texts.autosaved_retrieved, false, 5000);
}

// restore if available
store.apply();
// restore checkboxes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ window.DecidimAwesome.editor_uploader_path = "<%= decidim_decidim_awesome.editor
window.DecidimAwesome.texts = {
"drag_and_drop_image": "<%= j t(".drag_and_drop_image") %>",
"autosaved_success": "<%= j t(".autosaved_success") %>",
"autosaved_error": "<%= j t(".autosaved_error") %>"
"autosaved_error": "<%= j t(".autosaved_error") %>",
"autosaved_retrieved": "<%= j t(".autosaved_retrieved") %>"
}
<% if defined? questionnaire %>
window.DecidimAwesome.current_questionnaire = "edit_questionnaire_<%= questionnaire.id %>";
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,7 @@ en:
js:
autosaved_error: LocalStorage is not supported in your browser, form cannot
be saved automatically.
autosaved_retrieved: Data for this form has been recovered from a previous
session
autosaved_success: Data saved in local storage
drag_and_drop_image: Add images by dragging & dropping or pasting them.

0 comments on commit 6498360

Please sign in to comment.