Permalink
Browse files

position of subcategory and creation of pictures_collection attached …

…to a category
  • Loading branch information...
1 parent 7baeb85 commit 06ce5a53ded711d871e9df0498ce1c09f117a4e3 @moktin committed Mar 17, 2012
@@ -3,9 +3,10 @@
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$(document).ready ->
- $("#categories_list").sortable(
+ $("#categories_list, .sub_categories").sortable(
opacity: 0.6,
cursor: 'move',
update: ->
$.put("/admin/categories/update_positions", $(this).sortable("serialize"))
).disableSelection();
+
@@ -7,5 +7,8 @@
margin-bottom: 20px !important;
font-size: 14px !important;
color: black!important;
+ small {
+ font-size: 12px;
+ }
}
}
@@ -1,7 +1,7 @@
class Admin::PicturesCollectionsController < AdminController
def new
- @pictures_collection = PicturesCollection.new
+ @pictures_collection = PicturesCollection.new(:category_ids => [params[:category_id].to_i])
end
def create
@@ -9,7 +9,7 @@ class Category < ActiveRecord::Base
before_create :set_position
after_destroy :clean_positions
- default_scope order(:position)
+ default_scope order("categories.position")
scope :roots, where(:category_id => nil)
scope :children, where("category_id IS NOT NULL")
@@ -1,9 +1,16 @@
class PicturesCollection
include ActiveModel::Conversion
extend ActiveModel::Naming
+ extend ActiveModel::Translation
attr_accessor :description, :dimensions, :technic, :materials, :year, :pictures, :categories, :category_ids, :year
+ def initialize(attributes = {})
+ attributes.each do |name, value|
+ send("#{name}=", value)
+ end
+ end
+
def persisted?
false
end
@@ -4,9 +4,9 @@
= link_to(t('categories.new.child'), new_admin_category_path(:category_id => category.id))
|
= link_to(t('destroy'), admin_category_path(category), :method => :delete)
- %ul.sub_category
+ %ul.sub_categories
- category.categories.each do |child_category|
- %li
+ %li.sub_category{:id => "category_#{child_category.id}"}
= child_category.name
= link_to("(#{child_category.pictures.count} #{t('pictures.label')})", admin_category_pictures_path(child_category)) unless child_category.has_children?
= link_to(t('destroy'), admin_category_path(child_category), :method => :delete)
@@ -4,7 +4,7 @@
= t('pictures.for_category', :category => @category.name)
- else
= t('pictures.label')
- %small.pull-right= link_to(t('create'), new_admin_pictures_collection_path, :class => 'btn btn-primary')
+ %small.pull-right= link_to(t('create'), new_admin_pictures_collection_path(:category_id => @category ? @category.id : nil), :class => 'btn btn-primary')
#pictures_list
@@ -2,6 +2,13 @@
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
+ activemodel:
+ models:
+ pictures_collection: Picture Collection
+ attributes:
+ pictures_collection:
+ category_ids: Category
+
hello: "Hello world"
edit: 'edit'
destroy: 'delete'

0 comments on commit 06ce5a5

Please sign in to comment.