Top Level Namespace

Defined Under Namespace

Modules: Aerogel

Instance Method Summary collapse

Instance Method Details

#admin_menu(url, opts = {}) ⇒ Object

Defines a menu item



7
8
9
# File 'app/helpers/admin.rb', line 7

def admin_menu( url, opts = {} )
  Aerogel::Admin::Menu::Item.create url, opts
end

#admin_menu_itemsObject

Returns list of menu items ordered by priority



13
14
15
# File 'app/helpers/admin.rb', line 13

def admin_menu_items
  Aerogel::Admin::Menu.instance.items.sort_by( &:priority )
end

#auth_provider_as_icon(provider_key) ⇒ Object

Renders Authentication provier as icon.



19
20
21
22
# File 'app/helpers/decorators.rb', line 19

def auth_provider_as_icon( provider_key )
  provider = Aerogel::Auth.providers[provider_key]
  icon provider[:icon], title: provider[:name]
end

#auth_provider_as_text(provider_key) ⇒ Object

Renders Authentication provier as icon.



26
27
28
29
# File 'app/helpers/decorators.rb', line 26

def auth_provider_as_text( provider_key )
  provider = Aerogel::Auth.providers[provider_key]
  provider[:name]
end

#button_to(url, text = url, opts = {}) ⇒ Object

Creates a <button …>…</button> tag.



48
49
50
51
52
53
54
# File 'app/helpers/admin.rb', line 48

def button_to( url, text = url, opts = {} )
  opts = {
    class: "btn btn-default",
    href: url
  }.deep_merge opts
  tag :a, text, opts
end

#icon_deleteObject

Icon for delete actions.



3
4
5
# File 'app/helpers/icons.rb', line 3

def icon_delete
  icon "fa-times", title: t.aerogel.admin.actions.delete, style: "color:#e02327"
end

#icon_warningObject

Icon for warning notices and actions.



9
10
11
# File 'app/helpers/icons.rb', line 9

def icon_warning
  icon "fa-warning", style: "color:#e7cb2d"
end

Renders a link to open a modal window with remote content.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/admin.rb', line 19

def link_to_modal( url, *args, &block )
  opts = (String === args.first) ? args[1] : args[0]
  opts = {
    href: url,
    'data-toggle' => 'modal',
    'data-target' => '#adminModal'
  }.deep_merge( opts || {} )
  if String === args.first
    args[1] = opts
  else
    args[0] = opts
  end
  tag :a, *args, &block
end

Renders a link to open a modal window with remote content, if this operation is allowed. Renders a plain text otherwise.



38
39
40
41
42
43
44
# File 'app/helpers/admin.rb', line 38

def link_to_modal_if_can( url, text, opts = {} )
  if can? url
    link_to_modal url, text, opts
  else
    text
  end
end

#table(object, options = {}, &block) ⇒ Object

Table builder.



5
6
7
# File 'app/helpers/table_builder.rb', line 5

def table( object, options = {}, &block )
  Aerogel::Admin::TableBuilder.new( object, options, &block ).render
end

#tabs(options = {}, &block) ⇒ Object

Tabs builder.



5
6
7
# File 'app/helpers/tabs_builder.rb', line 5

def tabs( options = {}, &block )
  Aerogel::Admin::TabsBuilder.new( options, &block ).render
end

#user_email_confirmed_as_icon(email) ⇒ Object

Renders UserEmail.confirmed attribute as icon



3
4
5
6
7
# File 'app/helpers/decorators.rb', line 3

def user_email_confirmed_as_icon( email )
  email.confirmed ?
    icon( "glyphicon-ok-sign", title: t.aerogel.admin.decorators.confirmed, style: "color: green" ) :
    icon( "glyphicon-question-sign", title: t.aerogel.admin.decorators.not_confirmed )
end

#user_email_confirmed_as_label(email) ⇒ Object

Renders UserEmail.confirmed attribute as label



11
12
13
14
15
# File 'app/helpers/decorators.rb', line 11

def user_email_confirmed_as_label( email )
  email.confirmed ?
      "<span class='label label-success'>#{t.aerogel.admin.decorators.confirmed}</span>" :
      "<span class='label label-default'>#{t.aerogel.admin.decorators.not_confirmed}</span>"
end