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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 29 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| if 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 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 |
# 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 taxonomy == "categories" || taxonomy == "children" 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)
17 18 19 20 21 22 23 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 17 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 return html end |
#post_type_status(status, color = "default") ⇒ Object
11 12 13 14 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 11 def post_type_status(status, color="default") html = "<span class='label label-#{color} label-form'>#{status}</span>" end |