Skip to content

Commit

Permalink
Fix order by use :lft now
Browse files Browse the repository at this point in the history
  • Loading branch information
Brice Sanchez committed Feb 2, 2016
1 parent 4c8a03b commit 24f3b7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 64 deletions.
26 changes: 12 additions & 14 deletions pages/app/views/refinery/admin/pages/_page.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<% # setup params for various action links
add_url = refinery.new_admin_page_path(parent_id: page.id)
edit_url = refinery.admin_edit_page_path(page.nested_url, switch_locale: (page.translations.first.locale unless page.translated_to_default_locale?))
delete_url = refinery.admin_delete_page_path(page.nested_url)
delete_options = {
class: "cancel confirm-delete",
data: {confirm: t('message', scope: 'refinery.admin.delete', title: page_title_with_translations(page))}
}
%>
<%= sorted_nested_li(pages, :lft) do |page| %>
<% # setup params for various action links
add_url = refinery.new_admin_page_path(parent_id: page.id)
edit_url = refinery.admin_edit_page_path(page.nested_url, switch_locale: (page.translations.first.locale unless page.translated_to_default_locale?))
delete_url = refinery.admin_delete_page_path(page.nested_url)
delete_options = {
class: "cancel confirm-delete",
data: {confirm: t('message', scope: 'refinery.admin.delete', title: page_title_with_translations(page))}
}
%>

<li class='clearfix record items' id="<%= dom_id(page) -%>">
<div class='clearfix'>
<% if page.children.present? %>
<span class="item icon toggle <%= 'expanded' if Refinery::Pages.auto_expand_admin_tree %>"
Expand Down Expand Up @@ -46,7 +47,4 @@
<%= action_icon(:delete, delete_url, t('delete', scope: 'refinery.admin.pages' ), delete_options ) if page.deletable? %>
</span>
</div>
<ul class='nested' data-ajax-content="<%= refinery.admin_children_pages_path(page.nested_url) %>">
<%= render(partial: 'page', collection: page.children) if Refinery::Pages.auto_expand_admin_tree %>
</ul>
</li>
<% end %>
51 changes: 1 addition & 50 deletions pages/app/views/refinery/admin/pages/_sortable_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,53 +1,4 @@
<ul id='sortable_list'>
<%= sorted_nested_li(@pages, :title) do |page| %>
<% # setup params for various action links
add_url = refinery.new_admin_page_path(parent_id: page.id)
edit_url = refinery.admin_edit_page_path(page.nested_url, switch_locale: (page.translations.first.locale unless page.translated_to_default_locale?))
delete_url = refinery.admin_delete_page_path(page.nested_url)
delete_options = {
class: "cancel confirm-delete",
data: {confirm: t('message', scope: 'refinery.admin.delete', title: page_title_with_translations(page))}
}
%>

<div class='clearfix'>
<% if page.children.present? %>
<span class="item icon toggle <%= 'expanded' if Refinery::Pages.auto_expand_admin_tree %>"
title="<%= t('expand_collapse', scope: 'refinery.admin.pages')%>">
</span>
<% else %>
<span class="item"></span>
<% end %>

<span class='title <%= 'toggle' if page.children.present? %>'>
<%= page_title_with_translations page %>
<%= page_meta_information page %>
</span>

<% if Refinery::I18n.frontend_locales.many? %>
<span class='locales'>
<% page.translations.sort_by{ |t| Refinery::I18n.frontend_locales.index(t.locale)}.each do |translation| %>
<% if translation.title.present? %>
<%= link_to refinery.admin_edit_page_path(page.nested_url, switch_locale: translation.locale),
class: 'locale', title: translation.locale.upcase do %>

<div class="<%=translation.locale %> locale_marker">
<%= locale_text_icon(translation.locale.upcase) %>
</div>
<% end %>
<% end %>
<% end %>
</span>
<% end %>

<span class='actions'>
<%= action_icon(:preview, page.url, t('.view_live_html')) %>
<%= action_icon(:add, add_url, t('new', scope: 'refinery.admin.pages' ) ) %>
<%= action_icon(:edit, edit_url , t('edit', scope: 'refinery.admin.pages' ) ) %>
<%= action_icon(:delete, delete_url, t('delete', scope: 'refinery.admin.pages' ), delete_options ) if page.deletable? %>
</span>
</div>
<% end %>
<%= render partial: 'page', locals: { pages: @pages} %>
</ul>
<%= render '/refinery/admin/sortable_list', :continue_reordering => !!local_assigns[:continue_reordering] %>

0 comments on commit 24f3b7d

Please sign in to comment.