Skip to content

Commit

Permalink
Make confirm on exit optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jul 23, 2013
1 parent b04f664 commit 23c5f98
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 3 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->children()
->scalarNode('html5_validate')->defaultValue(true)->end()
->scalarNode('confirm_exit')->defaultValue(true)->end()
->end()
->end()
->arrayNode('dashboard')
Expand Down
1 change: 1 addition & 0 deletions Resources/doc/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Full Configuration Options
title_logo: bundles/sonataadmin/logo_title.png
options:
html5_validate: false # does not use html5 validation
confirm_exit: false # disable confirmation when quitting with unsaved changes
templates:
# default global templates
Expand Down
4 changes: 3 additions & 1 deletion Resources/public/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
jQuery(document).ready(function() {
jQuery('html').removeClass('no-js');
jQuery('.sonata-ba-form form').confirmExit(window.TRANSLATIONS.CONFIRM_EXIT);
if (window.SONATA_CONFIG.CONFIRM_EXIT) {
jQuery('.sonata-ba-form form').confirmExit(window.SONATA_TRANSLATIONS.CONFIRM_EXIT);
}
Admin.add_pretty_errors(document);
Admin.add_filters(document);
Admin.set_object_field_value(document);
Expand Down
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.bg.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ca.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.cs.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.de.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>You have unsaved changes.</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.es.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.eu.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.fa.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.hr.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.hu.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.it.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>Seleziona</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ja.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.lb.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.nl.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.pl.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.pt.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>Selecionar</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.pt_BR.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ro.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>Selectați</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ru.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.sk.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.sl.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.uk.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.zh_CN.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
<source>list_select</source>
<target>list_select</target>
</trans-unit>
<trans-unit id="confirm_exit">
<source>confirm_exit</source>
<target>confirm_exit</target>
</trans-unit>
</body>
</file>
</xliff>
7 changes: 5 additions & 2 deletions Resources/views/standard_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ file that was distributed with this source code.

{% block javascripts %}
<script type="text/javascript">
window.TRANSLATIONS = {
window.SONATA_CONFIG = {
CONFIRM_EXIT: {% if admin_pool.getOption('confirm_exit') %}true{% else %}false{% endif %}
};
window.SONATA_TRANSLATIONS = {
CONFIRM_EXIT: '{{ 'confirm_exit'|trans({}, 'SonataAdminBundle')|escape('js') }}'
};
</script>
Expand All @@ -49,7 +52,7 @@ file that was distributed with this source code.
<script src="{{ asset('bundles/sonataadmin/bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>

<script src="{{ asset('bundles/sonataadmin/jquery/jquery.form.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataadmin/jquery/jquery.confirmExit.js') }}" type="text/javascript"></script>
{% if admin_pool.getOption('confirm_exit') %}<script src="{{ asset('bundles/sonataadmin/jquery/jquery.confirmExit.js') }}" type="text/javascript"></script>{% endif %}
<script src="{{ asset('bundles/sonataadmin/base.js') }}" type="text/javascript"></script>
{% endblock %}

Expand Down

0 comments on commit 23c5f98

Please sign in to comment.