Skip to content

Commit

Permalink
custom js for action form also handles grappelli
Browse files Browse the repository at this point in the history
  • Loading branch information
frnhr committed Dec 29, 2017
1 parent d0157e2 commit 70f236f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions import_export/static/import_export/action_formats.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
(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();
var $actionsSelect, $formatsElement;
if ($('body').hasClass('grp-change-list')) {
// using grappelli
$actionsSelect = $('#grp-changelist-form select[name="action"]');
$formatsElement = $('#grp-changelist-form select[name="file_format"]');
} else {
// using default admin
$actionsSelect = $('#changelist-form select[name="action"]');
$formatsElement = $('#changelist-form select[name="file_format"]').parent();
}
$actionsSelect.on('change', function() {
if ($(this).val() === 'export_admin_action') {
$formatsElement.show();
} else {
$('select[name="file_format"]', '#changelist-form').parent().hide();
$formatsElement.hide();
}
});
$('select[name="action"]', '#changelist-form').change();
$actionsSelect.change();
});
})(django.jQuery);

0 comments on commit 70f236f

Please sign in to comment.