app/views/pages_cms/admin/pages/edit.html.haml in pages_cms-0.1.1 vs app/views/pages_cms/admin/pages/edit.html.haml in pages_cms-0.2.0

- old
+ new

@@ -1,45 +1,59 @@ -= form_for @page, url: admin_page_path(@page), class: 'inline-form form-horizontal' do |f| - %div.row - %div.col-md-8 - %span - %h2 - Edit - = @page.title - = link_to 'Preview', slugged_path(@page), class: 'btn btn-default btn-xs' - = f.label 'Show in top navbar ' - = f.check_box :navbar_show - = f.label 'Show in sidebar ' - = f.check_box :sidebar_show - = f.text_field :title, placeholder: 'page title', class: 'form-control big' - = f.text_field :meta_tags, placeholder: 'meta tags', class: 'form-control inline-form' - = f.text_field :meta_description, placeholder: 'meta description', class: 'form-control inline-form' - = f.select(:parent_id, PagesCms::Page.where(parent_id: nil).collect {|p| [p.title, p.id] }, {include_blank: 'Is a sub-page of'}, class: 'form-control inline-form') - = f.submit 'Save', class: 'btn btn-primary inline-form' - %div.sortable - = f.fields_for :page_blocks, f.object.page_blocks.order(:order) do |page_block| - = render 'page_block_fields', f: page_block - %hr - = link_to_add_association 'Add Block', f, :page_blocks +- if params[:sortable] == 'on' + %h1 Sort Your Page Blocks + %p + tip: give your page blocks a name to more easily sort them. + = form_for @page, url: admin_page_path(@page) do |f| + %ul.sortable.list-unstyled + = f.fields_for :page_blocks, f.object.page_blocks.order(:order) do |ff| + %li + %h4 + %span.glyphicon.glyphicon-menu-hamburger + = ff.object.div_id + = ff.hidden_field :order, class: 'block-order' - %div.col-md-3 - %h4 Sidebar - = f.fields_for :sidebar, @sidebar do |ss| - = ss.text_area :content, placeholder: 'content', class: 'form-control', rows: '20' - = ss.label 'Show sidebar on this page ' - = ss.check_box :show - = ss.select(:use_instead, PagesCms::Page.all.includes(:sidebar).collect {|p| [p.title, p.sidebar.id] unless p.sidebar.nil? }, {include_blank: 'Use this sidebar instead'}, class: 'form-control inline-form') + = f.submit 'Save', class: 'btn btn-primary center-block' - %div.row +- else + = form_for @page, url: admin_page_path(@page) do |f| + %div.row + %div.col-md-8 + %span + %h2 + Edit + = @page.title + = link_to 'Preview', slugged_path(@page), class: 'btn btn-default btn-xs' + = link_to 'Sort', edit_admin_page_path(@page, sortable: 'on'), class: 'btn btn-default btn-xs' + = f.label 'Show in top navbar ' + = f.check_box :navbar_show + = f.label 'Show in sidebar ' + = f.check_box :sidebar_show + = f.text_field :title, placeholder: 'page title', class: 'form-control big' + = f.text_field :meta_tags, placeholder: 'meta tags', class: 'form-control inline-form' + = f.text_field :meta_description, placeholder: 'meta description', class: 'form-control inline-form' + = f.select(:parent_id, PagesCms::Page.where(parent_id: nil).collect {|p| [p.title, p.id] }, {include_blank: 'Is a sub-page of'}, class: 'form-control inline-form') + = f.submit 'Save', class: 'btn btn-primary inline-form' + %div + = f.fields_for :page_blocks, f.object.page_blocks.order(:order) do |page_block| + = render 'page_block_fields', f: page_block + %hr + = link_to_add_association 'Add Block', f, :page_blocks + + %div.col-md-3 + %h4 Sidebar + = f.fields_for :sidebar, @sidebar do |ss| + = render 'editor', f: ss + = ss.label 'Show sidebar on this page' + = ss.check_box :show + = ss.select(:use_instead, PagesCms::Page.all.includes(:sidebar).collect {|p| [p.title, p.sidebar.id] unless p.sidebar.nil? }, {include_blank: 'Use this sidebar instead'}, class: 'form-control inline-form') + = f.submit 'Save', class: 'btn btn-primary center-block' :javascript $( document ).ready(function() { - $('.sortable').sortable({items: '.nested-fields', handle: 'span'}); - }); - window.setInterval(function(){ - $('.block-order').each(function(i){ - $(this).val(i+1); - }) - }, 500); + $('.sortable').sortable(); + $('.sortable').sortable().bind('sortupdate', function() { + $('.block-order').each(function(i){ $(this).val(i+1) }) + }); + }) = javascript_include_tag 'pages_cms/sortable.js' \ No newline at end of file