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, no_parent_accumulator = nil) ⇒ 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', post_type = nil) ⇒ 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, no_parent_accumulator = nil) ⇒ 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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 36 def cama_hierarchy_post_list(posts_list, parent_id = nil, skip_non_parent_posts = false, no_parent_accumulator = nil) no_parent_accumulator ||= posts_list.clone res = [] posts_list.each do |element| next unless element.post_parent.to_s == parent_id.to_s res << element no_parent_accumulator.delete_item(element) res += cama_hierarchy_post_list(posts_list, element.id, false, no_parent_accumulator) end if parent_id.blank? && !skip_non_parent_posts no_parent_accumulator.each do |element| element.show_title_with_parent = true res << element res += cama_hierarchy_post_list(posts_list, element.id, false, no_parent_accumulator) 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', post_type = nil) ⇒ Object
taxonomies -> (categories || post_tags)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 18 def post_type_list_taxonomy(taxonomies, color = 'primary', post_type = nil) # Legacy 2-arg call sites (e.g. overridden admin posts-index views, camaleon-ecommerce) omit # post_type and expect the controller's @post_type. Restored from #1178; see regression M23. post_type ||= controller.instance_variable_get(:@post_type) if respond_to?(:controller) return safe_join([]) if post_type.blank? safe_join(taxonomies.decorate.map do |f| link_to( cama_admin_post_type_taxonomy_posts_path(post_type.id, f.taxonomy, f.id), class: 'cama_ajax_request' ) do content_tag(:span, f.the_title, class: "label label-#{color} label-form") end end, ' ') 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') content_tag(:span, status, class: "label label-#{color} label-form") end |