From 649836022b3955eb4f25b486741dbfde82877d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Fri, 11 Sep 2020 18:19:51 +0200 Subject: [PATCH] add message for retrieved content --- .../decidim/decidim_awesome/forms/autosave.js.es6 | 8 ++++++-- .../decidim/decidim_awesome/_awesome_config.js.erb | 3 ++- config/locales/en.yml | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 b/app/assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 index 9ac2cdfd7..20e22611d 100644 --- a/app/assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 +++ b/app/assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 @@ -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 = $(`
${msg}
`) .appendTo($form); setTimeout(() => { @@ -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 diff --git a/app/views/layouts/decidim/decidim_awesome/_awesome_config.js.erb b/app/views/layouts/decidim/decidim_awesome/_awesome_config.js.erb index ab3a34542..f78ccb636 100644 --- a/app/views/layouts/decidim/decidim_awesome/_awesome_config.js.erb +++ b/app/views/layouts/decidim/decidim_awesome/_awesome_config.js.erb @@ -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 %>"; diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ba2e5e28..b676d830b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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.