Skip to content

Commit

Permalink
monkeypatch ChangeListActionsMixin in cms.admin.utils to support acti…
Browse files Browse the repository at this point in the history
…on list burger menu.
  • Loading branch information
FreemanPancake committed Nov 19, 2024
1 parent 17260f6 commit 6367dd8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions djangocms_version_locking/monkeypatch/admin.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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",)

Check failure on line 72 in djangocms_version_locking/monkeypatch/admin.py

View workflow job for this annotation

GitHub Actions / flake8

missing whitespace around operator

Check failure on line 72 in djangocms_version_locking/monkeypatch/admin.py

View workflow job for this annotation

GitHub Actions / flake8

line too long (136 > 120 characters)
ChangeListActionsMixin.Media.js+=("admin/js/jquery.init.js", "djangocms_version_locking/js/actions.js",)

Check failure on line 73 in djangocms_version_locking/monkeypatch/admin.py

View workflow job for this annotation

GitHub Actions / flake8

missing whitespace around operator

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)
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 */

Expand Down
14 changes: 0 additions & 14 deletions djangocms_version_locking/utils.py

This file was deleted.

0 comments on commit 6367dd8

Please sign in to comment.