Skip to content

Commit 9d88e3f

Browse files
committed
add back manual ordering of categories
1 parent 8e2d70a commit 9d88e3f

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

admin/views/categories/_form.haml

+11-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
.controls
1717
=f.select :parent_id, :options=>(Category.all - [@category]).map{|c| [c.name,c.id]},:include_blank=>true,:class => 'form-control input-large input-with-feedback'
1818
%span.help-inline=error ? f.error_message_on(:parent_id, :class => 'text-error') : pat(:example)
19+
- error = @category.errors.include?(:item_order)
20+
%fieldset.control-group{:class => error ? 'has-error' : ''}
21+
=f.label :item_order, :class => 'control-label'
22+
.controls
23+
=f.text_field :item_order, :type => :number, :class => 'form-control input-large input-with-feedback'
24+
%span.help-inline=error ? f.error_message_on(:item_order, :class => 'text-error') : pat(:example)
1925
%fieldset.control-group{:class => error ? 'has-error' : ''}
2026
=f.label :link, :class => 'control-label'
2127
.controls
@@ -28,23 +34,22 @@
2834
=f.submit pat(:save_and_continue), :class => 'btn btn-info', :name => 'save_and_continue'
2935
 
3036
=link_to pat(:cancel), url(:categories, :index), :class => 'btn btn-default'
31-
37+
3238
%h2 Child Order
3339
%p Drag each child to reorder. To add children, drag them from the list below.
3440

3541
- if [email protected]_record?
3642
.sortable-list-section
3743
%h3
38-
Children of Category
44+
Children of Category
3945
%span.italic= @category.name
4046
%ul.category-child-order.reorderable{ data: { url: url_for(:categories, :update, id: @category.id) }, style: "border: 3px solid #ccc" }
4147
- @category.children.each do |child|
42-
-#%li{ data: {id: child.id} }= link_to child.name, url(:categories, :edit, id: child.id)
43-
%li.btn.btn-default.btn-lg.btn-block{ data: {id: child.id} }= link_to child.name, url(:categories, :edit, id: child.id)
48+
-#%li{ data: {id: child.id} }= link_to child.name, url(:categories, :edit, id: child.id)
49+
%li.btn.btn-default.btn-lg.btn-block{ data: {id: child.id} }= link_to child.name, url(:categories, :edit, id: child.id)
4450

4551
.sortable-list-section
4652
%h3 All Categories
4753
%ul.category-all-order.reorderable{data: { url: url_for(:categories,:update, id: @category.id)}, style: "border: 3px solid #ccc"}
4854
- (Category.all - @category.children).each do |category|
49-
%li.btn.btn-default.btn-lg.btn-block{ data: {id: category.id} }= link_to category.name, url(:categories, :edit, id: category.id)
50-
55+
%li.btn.btn-default.btn-lg.btn-block{ data: {id: category.id} }= link_to category.name, url(:categories, :edit, id: category.id)

admin/views/posts/_form.haml

-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@
3333
=body
3434
- show=false
3535

36-
-# error = @post.errors.include?(:body)
37-
%fieldset.control-group{:class => error ? 'has-error' : ''}
38-
=f.label :body, :class => 'control-label'
39-
.controls
40-
~f.text_area :body, :class => 'form-control input-large input-with-feedback'
41-
%span.help-inline=error ? f.error_message_on(:body, :class => 'text-error') : pat(:example)
42-
43-
44-
4536
- error = @post.errors.include?(:account_id)
4637
%fieldset.control-group{:class => error ? 'has-error' : ''}
4738
=f.label :account_id, caption: "Author",:class => 'control-label'

models/category.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Category < ActiveRecord::Base
1818
has_many :children, :class_name=>Category, :foreign_key=>:parent_id
1919
has_many :posts
2020

21-
default_scope { order('item_order DESC') }
21+
default_scope { order('item_order ASC') }
2222

2323
def all_posts
2424
return self.posts + self.children.map(&:all_posts)

0 commit comments

Comments
 (0)