Module: CamaleonCms::Admin::PostTypeHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/camaleon_cms/admin/post_type_helper.rb
Instance Method Summary collapse
-
#cama_hierarchy_post_list(posts_list, parent_id = nil, skip_non_parent_posts = false) ⇒ Object
sort array of posts to build post’s tree skip_non_parent_posts: don’t include post’s where root post doesn’t exist internal control for recursive items.
-
#post_type_html_inputs(post_type, taxonomy = 'categories', name = 'categories', type = 'checkbox', values = [], class_cat = 'categorychecklist', required = false) ⇒ Object
taxonomy -> (categories || post_tags).
-
#post_type_list_taxonomy(taxonomies, color = 'primary') ⇒ Object
taxonomies -> (categories || post_tags).
- #post_type_status(status, color = 'default') ⇒ Object
Instance Method Details
#cama_hierarchy_post_list(posts_list, parent_id = nil, skip_non_parent_posts = false) ⇒ Object
sort array of posts to build post’s tree skip_non_parent_posts: don’t include post’s where root post doesn’t exist internal control for recursive items
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 30 def cama_hierarchy_post_list(posts_list, parent_id = nil, skip_non_parent_posts = false) res = [] @_cama_hierarchy_post_list_no_parent ||= posts_list.clone posts_list.each do |element| next unless element.post_parent.to_s == parent_id.to_s res << element @_cama_hierarchy_post_list_no_parent.delete_item(element) res += cama_hierarchy_post_list(posts_list, element.id) end if !parent_id.present? && !skip_non_parent_posts @_cama_hierarchy_post_list_no_parent.each do |element| element.show_title_with_parent = true res << element res += cama_hierarchy_post_list(posts_list, element.id) end end res end |
#post_type_html_inputs(post_type, taxonomy = 'categories', name = 'categories', type = 'checkbox', values = [], class_cat = 'categorychecklist', required = false) ⇒ Object
taxonomy -> (categories || post_tags)
5 6 7 8 9 10 11 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 5 def post_type_html_inputs(post_type, taxonomy = 'categories', name = 'categories', type = 'checkbox', values = [], class_cat = 'categorychecklist', required = false) categories = post_type.send(taxonomy) categories = categories.eager_load(:children, :post_type_parent, :parent) if %w[categories children].include?(taxonomy) post_type_taxonomy_html_(categories, taxonomy, name, type, values, class_cat, required) end |
#post_type_list_taxonomy(taxonomies, color = 'primary') ⇒ Object
taxonomies -> (categories || post_tags)
18 19 20 21 22 23 24 25 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 18 def post_type_list_taxonomy(taxonomies, color = 'primary') html = '' taxonomies.decorate.each do |f| html += "<a class='cama_ajax_request' href='#{cama_admin_post_type_taxonomy_posts_path(@post_type.id, f.taxonomy, f.id)}'><span class='label label-#{color} label-form'>#{f.the_title}</span></a> " end html end |
#post_type_status(status, color = 'default') ⇒ Object
13 14 15 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 13 def post_type_status(status, color = 'default') "<span class='label label-#{color} label-form'>#{status}</span>" end |