diff --git a/doc/changelog.rst b/doc/changelog.rst index 576bfd525..05f979f2f 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,6 +1,13 @@ Changelog ========= +2.0.0a1 +------- + +Fixes: + +* The `Apply` button for filters will show/hide correctly again + 2.0.0a0 ------- diff --git a/flask_admin/static/admin/js/bs4_filters.js b/flask_admin/static/admin/js/bs4_filters.js index 24e342ddc..248b7b65d 100644 --- a/flask_admin/static/admin/js/bs4_filters.js +++ b/flask_admin/static/admin/js/bs4_filters.js @@ -22,11 +22,10 @@ var AdminFilters = function(element, filtersElement, filterGroups, activeFilters function removeFilter() { $(this).closest('tr').remove(); if($('.filters tr').length == 0) { - $('button', $root).hide(); - $('a[class=btn]', $root).hide(); + $('button', $root).addClass('d-none'); $('.filters tbody').remove(); } else { - $('button', $root).show(); + $('button', $root).removeClass('d-none'); } return false; @@ -42,7 +41,7 @@ var AdminFilters = function(element, filtersElement, filterGroups, activeFilters var $field = createFilterInput($inputContainer, null, selectedFilter); styleFilterInput(selectedFilter, $field); - $('button', $root).show(); + $('button', $root).removeClass('d-none'); } // generate HTML for filter input - allows changing filter input type to one with options or tags @@ -69,6 +68,11 @@ var AdminFilters = function(element, filtersElement, filterGroups, activeFilters } inputContainer.replaceWith($('').append($field)); + // show "Apply Filter" button when filter input is changed + $field.on('input change', function() { + $('button', $root).removeClass('d-none'); + }); + return $field; } @@ -153,7 +157,7 @@ var AdminFilters = function(element, filtersElement, filterGroups, activeFilters addFilter(name, filterGroups[name], false, null); - $('button', $root).show(); + $('button', $root).removeClass('d-none'); }); // on page load - add active filters @@ -166,7 +170,7 @@ var AdminFilters = function(element, filtersElement, filterGroups, activeFilters // show "Apply Filter" button when filter input is changed $('.filter-val', $root).on('input change', function() { - $('button', $root).show(); + $('button', $root).removeClass('d-none'); }); $('.remove-filter', $root).click(removeFilter); diff --git a/flask_admin/templates/bootstrap4/admin/model/layout.html b/flask_admin/templates/bootstrap4/admin/model/layout.html index 6bd192f65..936bfd1d4 100644 --- a/flask_admin/templates/bootstrap4/admin/model/layout.html +++ b/flask_admin/templates/bootstrap4/admin/model/layout.html @@ -46,7 +46,7 @@ {% endif %}
- + {% if active_filters %} {{ _gettext('Reset Filters') }} {% endif %} diff --git a/flask_admin/translations/en/LC_MESSAGES/admin.mo b/flask_admin/translations/en/LC_MESSAGES/admin.mo index 94b61f16b..91e2551ed 100644 Binary files a/flask_admin/translations/en/LC_MESSAGES/admin.mo and b/flask_admin/translations/en/LC_MESSAGES/admin.mo differ