Skip to content

Commit

Permalink
update pagecontentadmin icon
Browse files Browse the repository at this point in the history
  • Loading branch information
FreemanPancake committed Aug 16, 2024
1 parent 7f04022 commit c4f6822
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
29 changes: 20 additions & 9 deletions djangocms_pageadmin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
from django.urls import path, re_path, reverse
from django.utils.decorators import method_decorator
from django.utils.html import format_html, format_html_join
from django.utils.safestring import mark_safe
from django.utils.translation import get_language, gettext_lazy as _, override
from django.views.decorators.http import require_POST

from cms.admin.pageadmin import PageContentAdmin as DefaultPageContentAdmin
from cms.admin.utils import ChangeListActionsMixin
from cms.extensions import extension_pool
from cms.models import PageContent, PageUrl
from cms.signals.apphook import set_restart_trigger
Expand Down Expand Up @@ -51,7 +53,7 @@
require_POST = method_decorator(require_POST)


class PageContentAdmin(VersioningAdminMixin, DefaultPageContentAdmin):
class PageContentAdmin(ChangeListActionsMixin, VersioningAdminMixin, DefaultPageContentAdmin):
change_list_template = "admin/djangocms_pageadmin/pagecontent/change_list.html"
list_display_links = None
list_filter = (LanguageFilter, UnpublishedFilter, TemplateFilter, AuthorFilter)
Expand Down Expand Up @@ -215,12 +217,12 @@ def author(self, obj):
def is_locked(self, obj):
version = self.get_version(obj)
if version and version.state == DRAFT and version_is_locked(version):
return render_to_string("djangocms_version_locking/admin/locked_icon.html")
return mark_safe('<span class="cms-icon cms-icon-lock"></span>')
return ""

def is_home(self, obj):
if obj.page.is_home:
return render_to_string("djangocms_pageadmin/admin/icons/home.html")
return mark_safe('<span class="cms-icon cms-icon-home"></span>')
return ""

@admin.display(
Expand All @@ -247,9 +249,13 @@ def get_list_actions(self):
]

def _get_preview_link(self, obj, request, disabled=False):
return render_to_string(
"djangocms_pageadmin/admin/icons/preview.html",
{"url": get_object_preview_url(obj), "disabled": disabled, "keepsideframe": False},
return self.admin_action_button(
url=get_object_preview_url(obj),
disabled=disabled,
icon="view",
name="preview",
keepsideframe=False,
title=_("Preview"),
)

def _get_edit_link(self, obj, request, disabled=False):
Expand All @@ -269,9 +275,14 @@ def _get_edit_link(self, obj, request, disabled=False):
)

# close sideframe as edit will always be on page and not in sideframe
return render_to_string(
"djangocms_pageadmin/admin/icons/edit.html",
{"url": url, "disabled": disabled, "get": False, "keepsideframe": False},
return self.admin_action_button(
url=url,
icon="pencil",
title=_("Edit"),
name="edit",
disabled=disabled,
action="post",
keepsideframe=False,
)

def _get_duplicate_link(self, obj, request, disabled=False):
Expand Down
6 changes: 4 additions & 2 deletions djangocms_pageadmin/static/djangocms_pageadmin/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
/* create burger menu anchor icon */
var anchor = document.createElement('A');
var cssclass = document.createAttribute('class');
cssclass.value = 'btn cms-page-admin-action-btn closed';
cssclass.value = 'btn cms-action-btn closed';
anchor.setAttributeNode(cssclass);
var title = document.createAttribute('title');
title.value = 'Actions';
anchor.setAttributeNode(title);
var icon = document.createElement('IMG');
var new_icon = document.createElement('span');
new_icon.className = "cms-icon cms-icon-menu"
var src = document.createAttribute('src');
src.value = pageadmin_static_url_prefix + 'svg/menu.svg';
icon.setAttributeNode(src);
anchor.appendChild(icon);
anchor.appendChild(new_icon);
/* create options container */

var optionsContainer = document.createElement('DIV');
Expand Down

0 comments on commit c4f6822

Please sign in to comment.