Skip to content

Commit

Permalink
Fix unlock state in page table list view
Browse files Browse the repository at this point in the history
and for global pages
  • Loading branch information
tvdeyen committed Dec 14, 2023
1 parent c9e05a1 commit 972f0f9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
10 changes: 9 additions & 1 deletion app/views/alchemy/admin/layoutpages/_layoutpage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= page_layout_missing_warning %>
<% elsif layoutpage.locked? %>
<sl-tooltip class="like-hint-tooltip" content="<%= Alchemy.t("This page is locked", name: layoutpage.locker_name) %>">
<i class="icon ri-file-edit-fill ri-fw ri-xl"></i>
<i class="icon ri-file-edit-line ri-fw ri-xl"></i>
</sl-tooltip>
<% else %>
<i class="icon ri-file-line ri-xl"></i>
Expand Down Expand Up @@ -54,6 +54,14 @@
</sl-tooltip>
<%- end -%>
</div>
<div class="page_infos">
<% if layoutpage.locked? %>
<span class="page_status locked">
<i class="icon ri-fw ri-1x ri-edit-line"></i>
<%= layoutpage.status_title(:locked) %>
</span>
<% end %>
</div>
<div class="sitemap_sitename without-status">
<%= link_to(
layoutpage.name,
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pages/_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
</div>
<div class="page_infos">
{{#if locked}}
<span class="page_status">
<span class="page_status locked">
<i class="icon ri-fw ri-1x ri-edit-line"></i>
{{status_titles.locked}}
</span>
Expand Down
4 changes: 2 additions & 2 deletions app/views/alchemy/admin/pages/_table_row.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tr class="<%= cycle(:even, :odd) %>" data-page-id="<%= page.id %>">
<tr class="<%= cycle(:even, :odd) %>" data-page-id="<%= page.id %>" id="page_<%= page.id %>">
<td class="icon">
<% if can?(:edit_content, page) %>
<% if page.locked? %>
Expand Down Expand Up @@ -38,7 +38,7 @@
</td>
<td class="status right">
<% if page.locked? %>
<span class="page_status">
<span class="page_status locked">
<%= render_icon(:edit, size: "1x") %>
<%= page.status_title(:locked) %>
</span>
Expand Down
11 changes: 9 additions & 2 deletions app/views/alchemy/admin/pages/unlock.js.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
(function() {
var locked_page_icon_content
var locked_page_tab = document.querySelector('#locked_page_<%= @page.id -%>')
var locked_page_icon = document.querySelector(
'#page_<%= @page.id -%> > .sitemap_page > .sitemap_left_images .like-hint-tooltip'
) || document.querySelector('[data-page-id="<%= @page.id -%>"] > .icon')
) || document.querySelector('[data-page-id="<%= @page.id -%>"] i.icon')
if (locked_page_tab) {
locked_page_tab.remove()
}
if (locked_page_icon) {
locked_page_icon.outerHTML = '<span class="handle"><i class="icon ri-file-line ri-fw ri-xl"></i></span>'
if (locked_page_icon.parentElement.classList.contains("handle")) {
locked_page_icon_content = '<span class="handle"><i class="icon ri-file-line ri-fw ri-xl"></i></span>'
} else {
locked_page_icon_content = '<i class="icon ri-file-line ri-fw ri-xl"></i>'
}
locked_page_icon.outerHTML = locked_page_icon_content
}
document.querySelector("#page_<%= @page.id -%> .page_status.locked").remove()
Alchemy.growl('<%= flash[:notice] -%>')
})()

0 comments on commit 972f0f9

Please sign in to comment.