category selection controls for pages, snipets and files
Oleg
committed Aug 23, 2011
commit 4d2fdcbdc566254884525d8ea7db7e212ceba4d2
Showing 6
changed files with
28 additions
and 0 deletions
app/assets/stylesheets/comfortable_mexican_sofa/form.css
+9
-0
| @@ | @@ -119,4 +119,13 @@ |
| padding: 5px; | |
| border-radius: 3px; | |
| -moz-border-radius: 3px; | |
| + | } |
| + | #cms_body .form_element.categories .value label { |
| + | display: inline-block; |
| + | padding: 3px 5px; |
| + | background-color: #9f9f9f; |
| + | border-radius: 3px; |
| + | font: 9px/14px 'Lucida Grande', 'Tahoma', serif; |
| + | text-transform: uppercase; |
| + | color: #fff; |
| } | |
| \ No newline at end of file | |
app/models/cms/category.rb
+1
-0
| @@ | @@ -14,6 +14,7 @@ class Cms::Category < ActiveRecord::Base |
| :presence => true | |
| # -- Scopes --------------------------------------------------------------- | |
| + | default_scope order(:label) |
| scope :of_type, lambda { |type| | |
| where(:categorized_type => type) | |
| } | |
app/views/cms_admin/categories/_form.html.erb
+12
-0
| @@ | @@ -0,0 +1,12 @@ |
| + | <% object = form.object %> |
| + | <% if (categories = Cms::Category.of_type(object.class.to_s)).present? %> |
| + | <%= form.simple_field t('.categories'), nil, :class => 'categories' do %> |
| + | <% categories.each do |category| %> |
| + | <%= hidden_field_tag "#{object.class.to_s.demodulize.downcase}[category_ids][#{category.id}]", 0, :id => nil %> |
| + | <label> |
| + | <%= check_box_tag "#{object.class.to_s.demodulize.downcase}[category_ids][#{category.id}]", 1, object.categories.member?(category), :id => nil %> |
| + | <%= category.label %> |
| + | </label> |
| + | <% end %> |
| + | <% end %> |
| + | <% end %> |
| \ No newline at end of file | |
app/views/cms_admin/files/_form.html.erb
+2
-0
| @@ | @@ -8,6 +8,8 @@ |
| <% end %> | |
| <%= form.text_area :description %> | |
| + | <%= render :partial => 'cms_admin/categories/form', :object => form %> |
| + | |
| <%= form.simple_field nil, nil, :class => 'submit_element' do %> | |
| <%= form.submit t(@file.new_record?? '.create' : '.update'), :disable_builder => true %> | |
| <% end %> | |
app/views/cms_admin/pages/_form.html.erb
+2
-0
| @@ | @@ -29,6 +29,8 @@ |
| <%= render :partial => 'form_blocks' %> | |
| + | <%= render :partial => 'cms_admin/categories/form', :object => form %> |
| + | |
| <%= form.simple_field nil, nil, :class => 'submit_element' do %> | |
| <%= form.check_box :is_published, :disable_builder => true %> | |
| <%= form.label_for :is_published %> | |
app/views/cms_admin/snippets/_form.html.erb
+2
-0
| @@ | @@ -6,6 +6,8 @@ |
| <%= form.text_field :slug, :id => 'slug', :class => 'delimiter-underscore' %> | |
| <%= form.text_area :content, :class => 'code' %> | |
| + | <%= render :partial => 'cms_admin/categories/form', :object => form %> |
| + | |
| <%= form.simple_field nil, nil, :class => 'submit_element' do %> | |
| <%= form.submit t(@snippet.new_record?? '.create' : '.update'), :disable_builder => true %> | |
| <% end %> | |