diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3a0143d..a87630e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Unreleased * Dropped Support for Python 3.8 * Introduced Django CMS 4.1 support. * delete `VersionLock` as It's moved to Version.locked_by field. -* added `AdminActionListMixin` in utils.py file to support action list burger menu. +* monkeypatch `ChangeListActionsMixin` in cms.admin.utils to support action list burger menu. 1.3.0 (2024-05-16) diff --git a/djangocms_version_locking/monkeypatch/admin.py b/djangocms_version_locking/monkeypatch/admin.py index f549df8..743ee8a 100644 --- a/djangocms_version_locking/monkeypatch/admin.py +++ b/djangocms_version_locking/monkeypatch/admin.py @@ -1,6 +1,9 @@ from django.template.loader import render_to_string from django.utils.translation import gettext_lazy as _ +from cms.admin.utils import ChangeListActionsMixin +from cms.utils.urlutils import static_with_version + from djangocms_versioning.admin import ( ExtendedVersionAdminMixin, StateIndicatorMixin, @@ -62,6 +65,13 @@ def _get_manage_versions_link(self, obj, request, disabled=False): ) +""" Monkeypatch ChangeListActionsMixin, add action burger menu for action list +This will enable burger menu feature for ModelAdmin inherits from +VersionAdmin, ExtendedVersionAdminMixin, GrouperModelAdmin. +""" +ChangeListActionsMixin.Media.css["all"]+=(static_with_version("cms/css/cms.pagetree.css"), "djangocms_version_locking/css/actions.css",) +ChangeListActionsMixin.Media.js+=("admin/js/jquery.init.js", "djangocms_version_locking/js/actions.js",) + ExtendedVersionAdminMixin._get_manage_versions_link = _get_manage_versions_link ExtendedVersionAdminMixin.get_actions_list = _get_actions_list(ExtendedVersionAdminMixin.get_actions_list) StateIndicatorMixin.get_indicator_column = _get_indicator_column(StateIndicatorMixin.get_indicator_column) diff --git a/djangocms_version_locking/monkeypatch/djangocms_alias/admin.py b/djangocms_version_locking/monkeypatch/djangocms_alias/admin.py index 4b27541..6d5ead2 100644 --- a/djangocms_version_locking/monkeypatch/djangocms_alias/admin.py +++ b/djangocms_version_locking/monkeypatch/djangocms_alias/admin.py @@ -13,10 +13,9 @@ proxy_model, version_list_url, ) -from djangocms_version_locking.utils import AdminActionListMixin -class AliasAdmin(AdminActionListMixin, OriginalAliasAdmin): +class AliasAdmin(OriginalAliasAdmin): change_list_template = "monkeypatch/cms/admin/cms/grouper/change_list.html" diff --git a/djangocms_version_locking/static/djangocms_version_locking/css/actions.css b/djangocms_version_locking/static/djangocms_version_locking/css/actions.css index 52e58fe..cb11ec2 100644 --- a/djangocms_version_locking/static/djangocms_version_locking/css/actions.css +++ b/djangocms_version_locking/static/djangocms_version_locking/css/actions.css @@ -102,3 +102,7 @@ ul.cms-pagetree-dropdown-menu-inner li a.inactive { .cms-pagetree-dropdown-menu:before { margin-top: 13px; } + +.btn.cms-action-btn.cms-action-burger { + margin-left: 4px !important; +} diff --git a/djangocms_version_locking/static/djangocms_version_locking/js/actions.js b/djangocms_version_locking/static/djangocms_version_locking/js/actions.js index 9c5dad4..0001b19 100644 --- a/djangocms_version_locking/static/djangocms_version_locking/js/actions.js +++ b/djangocms_version_locking/static/djangocms_version_locking/js/actions.js @@ -10,7 +10,7 @@ /* create burger menu anchor section */ var anchor = document.createElement('A'); var cssclass = document.createAttribute('class'); - cssclass.value = 'btn cms-action-btn closed'; + cssclass.value = 'btn cms-action-btn closed cms-action-burger'; anchor.setAttributeNode(cssclass); // create burger menu title var title = document.createAttribute('title'); @@ -92,7 +92,7 @@ /* add the options to the drop-down */ optionsContainer.appendChild(ul); - actions[0].appendChild(anchor); + $(actions[0]).children('.cms-action-btn:last').after(anchor); document.body.appendChild(optionsContainer); /* listen for burger menu clicks */ diff --git a/djangocms_version_locking/utils.py b/djangocms_version_locking/utils.py deleted file mode 100644 index ff81046..0000000 --- a/djangocms_version_locking/utils.py +++ /dev/null @@ -1,14 +0,0 @@ -from django import forms - - -class AdminActionListMixin(metaclass=forms.MediaDefiningClass): - """AdminActionListMixin is a mixin for the Versioned Model class. It adds the ability to have - action buttons and a burger menu in the admin's change list view. - """ - - class Media: - js = ( - "admin/js/jquery.init.js", - "djangocms_version_locking/js/actions.js", - ) - css = {"all": ("djangocms_version_locking/css/actions.css",)}