Skip to content

Commit

Permalink
show formats selector only when export action is selected
Browse files Browse the repository at this point in the history
manelclos committed Feb 19, 2016
1 parent 82d2829 commit 85b1c6d
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions import_export/admin.py
Original file line number Diff line number Diff line change
@@ -437,6 +437,9 @@ def export_admin_action(self, request, queryset):

actions = [export_admin_action]

class Media:
js = ['import_export/action_formats.js']


class ImportExportActionModelAdmin(ImportMixin, ExportActionModelAdmin):
"""
12 changes: 12 additions & 0 deletions import_export/static/import_export/action_formats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function($) {
$(document).on('ready', function() {
$('select[name="action"]', '#changelist-form').on('change', function() {
if ($(this).val() == 'export_admin_action') {
$('select[name="file_format"]', '#changelist-form').parent().show();
} else {
$('select[name="file_format"]', '#changelist-form').parent().hide();
}
});
$('select[name="action"]', '#changelist-form').change();
});
})(django.jQuery);

0 comments on commit 85b1c6d

Please sign in to comment.