Module: Workarea::Admin::TaxonsHelper

Defined in:
app/helpers/workarea/admin/taxons_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/workarea/admin/taxons_helper.rb', line 3

def navigable_types
  [
    [
      t('workarea.admin.navigation_taxons.types.page'),
      'page',
      { data: { new_navigation_taxon_endpoint: content_pages_path(format: :json) } }
    ],
    [
      t('workarea.admin.navigation_taxons.types.category'),
      'category',
      { data: { new_navigation_taxon_endpoint: catalog_categories_path(format: :json) } }
    ],
    [
      t('workarea.admin.navigation_taxons.types.product'),
      'product',
      { data: { new_navigation_taxon_endpoint: catalog_products_path(format: :json) } }
    ]
  ]
end

#taxon_icon(taxon, options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'app/helpers/workarea/admin/taxons_helper.rb', line 43

def taxon_icon(taxon, options = {})
  if taxon.resource_name.category?
    inline_svg('workarea/admin/icons/categories.svg', options)
  elsif taxon.resource_name.page?
    inline_svg('workarea/admin/icons/pages.svg', options)
  else
    inline_svg('workarea/admin/icons/link.svg', options)
  end
end

#taxonomy_insert(taxon) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/workarea/admin/taxons_helper.rb', line 53

def taxonomy_insert(taxon)
  (
    :div,
    render(
      'workarea/admin/navigation_taxons/insert',
      parent: taxon.parent || Navigation::Taxon.root,
      taxon: taxon
    ),
    data: { taxon_insert: '' }
  )
end

#taxonomy_select(name, current = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/workarea/admin/taxons_helper.rb', line 23

def taxonomy_select(name, current = nil)
  current = Navigation::Taxon.where(id: current).first

  (
    :div,
    hidden_field_tag(name, current.try(:id)) +
      render(
        'workarea/admin/navigation_taxons/select',
        taxon: current
      ) +
      (
        :button,
        t('workarea.admin.navigation_taxons.select.reset_button'),
        value: 'reset',
        class: 'button button--small'
      ),
    data: { taxon_select: '' }
  )
end