Skip to content
Snippets Groups Projects
Commit 8ef77771 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Prevent clearing of form when changing language in between

Ask user if they really want to change the language as it will clear the form as soon as the main form on the page was edited at least once.
Fixes #80
parent 0a62d76a
No related branches found
No related tags found
1 merge request!42Prevent clearing of form when changing language in between
Pipeline #4045 passed
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 06:38+0000\n"
"POT-Creation-Date: 2020-05-19 21:50+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -46,10 +46,15 @@ msgstr "Anzahl"
msgid "Event Status"
msgstr "Event-Status"
#: templates/base.html:78
#: templates/base.html:28
msgid ""
"Are you sure you want to change the language now? This will clear the form!"
msgstr "Wirklich jetzt die Sprache ändern? Das wird das Formular zurücksetzen!"
#: templates/base.html:97
msgid "Impress"
msgstr "Impressum"
#: templates/base.html:81
#: templates/base.html:100
msgid "This software is open source"
msgstr "Diese Software ist Open Source"
......@@ -19,6 +19,26 @@
<link rel="stylesheet" href="{% static 'common/css/custom.css' %}">
<script type='text/javascript'>
var changed_form = false;
$(document).ready(function() {
// Ask before changing language if user changed main form on page
$("#language-switcher").submit(function(e){
if(changed_form) {
if(!confirm("{% trans 'Are you sure you want to change the language now? This will clear the form!' %}"))
e.preventDefault(e);
}
});
// Remember any main form edits/changes
$("form.post-form :input").change(function(){
if($(this).val() != '')
changed_form = true;
});
});
</script>
{% block imports %}{% endblock %}
</head>
<body>
......@@ -29,6 +49,7 @@
method="post"
class="form-inline"
name="language-form"
id="language-switcher"
style="flex-direction: column;">
{% csrf_token %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment