diff --git a/content_editor/admin.py b/content_editor/admin.py index c33acaa0..55a0077a 100644 --- a/content_editor/admin.py +++ b/content_editor/admin.py @@ -125,11 +125,11 @@ class ContentEditor(ModelAdmin): def _content_editor_context(self, request, context): instance = context.get("original") - show_plugins = True + allow_change = True if instance is None: instance = self.model() else: - show_plugins = self.has_change_permission(request, instance) + allow_change = self.has_change_permission(request, instance) plugins = [] adding_not_allowed = ["_adding_not_allowed"] @@ -142,7 +142,7 @@ def _content_editor_context(self, request, context): if callable(iaf.opts.regions) else iaf.opts.regions ) - if show_plugins and iaf.opts.has_add_permission(request, instance) + if allow_change and iaf.opts.has_add_permission(request, instance) else adding_not_allowed ) plugins.append( @@ -167,6 +167,7 @@ def _content_editor_context(self, request, context): { "plugins": plugins, "regions": regions, + "allowChange": allow_change, "messages": { "createNew": gettext("Add new item"), "empty": gettext("No items."), diff --git a/content_editor/static/content_editor/content_editor.css b/content_editor/static/content_editor/content_editor.css index 8bcf1978..b0281fb5 100644 --- a/content_editor/static/content_editor/content_editor.css +++ b/content_editor/static/content_editor/content_editor.css @@ -57,7 +57,7 @@ html { } .order-machine-wrapper.collapsed { - --control-width: 10px; + --control-width: 20px; } @media (min-width: 1024px) { @@ -67,7 +67,7 @@ html { } .order-machine { - padding: 0 10px 20px 10px; + padding: 0 10px 10px 10px; border: 1px solid var(--hairline-color, #e8e8e8); position: relative; @@ -408,6 +408,12 @@ h3[draggable] { } } +.order-machine-readonly .plugin-buttons + p, +.order-machine-readonly + .order-machine-help, +.order-machine-readonly .inline-related > h3[draggable]::before { + display: none; +} + /* =====| OVERRIDES |===== */ /* JAZZMIN start */ diff --git a/content_editor/static/content_editor/content_editor.js b/content_editor/static/content_editor/content_editor.js index 0d8142d0..4da65f3a 100644 --- a/content_editor/static/content_editor/content_editor.js +++ b/content_editor/static/content_editor/content_editor.js @@ -740,5 +740,9 @@ django.jQuery(function ($) { ` document.head.appendChild(style) + if (!ContentEditor.allowChange) { + $(".order-machine-wrapper").addClass("order-machine-readonly") + } + $(document).trigger("content-editor:ready") })