lib/generators/redde/layout/templates/helpers/admin_helper.rb in redde-0.1.0 vs lib/generators/redde/layout/templates/helpers/admin_helper.rb in redde-0.1.1

- old
+ new

@@ -33,22 +33,19 @@ }.gsub(/[\n ]+/, ' ').strip.html_safe return content_for(:js,html) end def show_tree(c) - html = "" - html << "<li id=\"list_#{c.id}\"><div>#{link_to c.name, edit_admin_category_path(c)}<p>" - html << " #{link_to "Удал",[:admin, c], data: { confirm: 'Точно удалить?' }, :method => :delete, class: "del"}</p></div>" - unless c.children.empty? - html << "<ol#{" class='sortable'" if c.id == 1}>" - c.children.order('position').each do |ch| - html << show_tree(ch) + link = link_to c.name, [:edit, :admin, c] + edit = link_to "Удал",[:admin, c], data: { confirm: 'Точно удалить?' }, :method => :delete, class: "del" + html = content_tag(:div, link + content_tag(:p, edit)) + if c.children.any? + html << content_tag(:ol) do + raw c.children.map{|ch| show_tree(ch)}.join() end - html << "</ol>" end - html << "</li>" - return raw(html) + content_tag :li, raw(html), id: "list_#{c.id}" end def sort_tree(url, maxLevels = 2) %Q{ <script type="text/javascript"> @@ -62,15 +59,20 @@ items: 'li', maxLevels: #{maxLevels}, opacity: .6, placeholder: 'placeholder', revert: 250, + rootID: 'root', tabSize: 25, tolerance: 'pointer', toleranceElement: '> div', update: function(){ var serialized = $(this).nestedSortable('serialize'); - $.ajax({url: '#{url}', data: serialized}); + $.ajax({ + method: 'POST', + url: '#{url}', + data: serialized + }); } }); }); </script> }.gsub(/[\n ]+/, ' ').strip.html_safe