From 480a5430a92900d68f75d5c5683b642635593a7b Mon Sep 17 00:00:00 2001 From: fherreazcue Date: Thu, 7 Sep 2023 14:59:56 +0100 Subject: [PATCH] Reduces number permission checks, most importantly of "can_publish?" --- app/assets/stylesheets/publishing.scss | 5 ----- app/views/assets/_asset_checkbox_row.html.erb | 21 +++++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/publishing.scss b/app/assets/stylesheets/publishing.scss index 082a1ebb7b..9af8d7a905 100644 --- a/app/assets/stylesheets/publishing.scss +++ b/app/assets/stylesheets/publishing.scss @@ -64,11 +64,6 @@ ul.item_for_decision { .publishing_options { padding: 0.5em 1em; - &.publishable { - background-color: #fafaff; - border-left-color: $btn-success-bg; - } - &.not-manageable { border-left-color: $btn-warning-bg; } diff --git a/app/views/assets/_asset_checkbox_row.html.erb b/app/views/assets/_asset_checkbox_row.html.erb index 7411d8e3b3..1edfb7021a 100644 --- a/app/views/assets/_asset_checkbox_row.html.erb +++ b/app/views/assets/_asset_checkbox_row.html.erb @@ -3,10 +3,19 @@ checked ||= false block_published ||= false + can_manage=item.can_manage? + can_view=item.can_view? + published=false tree_class = 'not-manageable' - tree_class = 'publishable' if item.can_publish? && item.can_manage? - tree_class = 'already-published' if item.is_published? - tree_class = 'not-visible' unless item.can_view? + tree_class = 'manageable' if can_manage + tree_class = 'not-visible' unless can_view + if block_published + if item.is_published? + published=true + tree_class = 'already-published' + end + end + toggle ||=false cb_parent_selector ||="div\##{item.class.name}_#{item.id}.split_button_parent" @@ -20,15 +29,15 @@ <% if toggle %> <%= render :partial => 'assets/isa-tree-toggle', locals: { cb_parent_selector: cb_parent_selector } -%> <% end %> - <% if item.can_view? %> + <% if can_view %>
<%= render :partial => 'general/split_button_checkbox', locals: { checkbox_id: publishing_item_param(item), checkbox_class: "#{item.class.name}_#{item.id}", checked: checked, checkbox_text: "", - published: (item.is_published? && block_published), - cant_manage: !(item.can_manage?), + published: published, + cant_manage: !(can_manage), toggle: toggle, cb_parent_selector: cb_parent_selector} -%>