Module: Dorsale::ButtonHelper

Included in:
AllHelpers
Defined in:
app/helpers/dorsale/button_helper.rb

Instance Method Summary collapse

Instance Method Details

#complete_button(url, options = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'app/helpers/dorsale/button_helper.rb', line 88

def complete_button(url, options = {})
  options = {
    :icon    => :check,
    :action  => :complete,
    :class   => "btn btn-xs btn-success link_complete",
    :confirm => true,
    :method  => :patch,
  }.merge(options)

  dorsale_button(url, options)
end

#copy_button(url, options = {}) ⇒ Object



79
80
81
82
83
84
85
86
# File 'app/helpers/dorsale/button_helper.rb', line 79

def copy_button(url, options = {})
  options = {
    :icon    => :copy,
    :action  => :copy,
  }.merge(options)

  dorsale_button(url, options)
end

#create_button(url, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'app/helpers/dorsale/button_helper.rb', line 29

def create_button(url, options = {})
  options = {
    :icon   => :plus,
    :action => :create,
    :class  =>"btn btn-xs btn-success link_create"
  }.merge(options)

  dorsale_button(url, options)
end

#delete_button(url, options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'app/helpers/dorsale/button_helper.rb', line 67

def delete_button(url, options = {})
  options = {
    :icon    => :trash,
    :action  => :delete,
    :class   => "btn btn-xs btn-danger link_delete",
    :confirm => true,
    :method  => :delete,
  }.merge(options)

  dorsale_button(url, options)
end

#dorsale_button(url, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/dorsale/button_helper.rb', line 3

def dorsale_button(url, options = {})
  action = options.delete(:action)
  icon   = options.delete(:icon)
  text   = options.delete(:text) || t("actions.#{action}")
  title  = options.delete(:title) || text

  text   = "#{icon icon} <span>#{text}</span>".html_safe

  options = {
    :class => "btn btn-xs link_#{action}",
    :title => title,
  }.deep_merge(options)

  if confirm = options.delete(:confirm)
    confirm = t("actions.confirm") if confirm == true

    options.deep_merge!(
      :data => {
        :confirm => confirm,
      }
    )
  end

  link_to(text, url, options)
end

#download_button(url, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'app/helpers/dorsale/button_helper.rb', line 48

def download_button(url, options = {})
  options = {
    :icon     => "cloud-download",
    :action   => :download,
    :download => url,
  }.merge(options)

  dorsale_button(url, options)
end

#lock_button(url, options = {}) ⇒ Object



111
112
113
114
115
116
117
118
119
120
# File 'app/helpers/dorsale/button_helper.rb', line 111

def lock_button(url, options = {})
  options = {
    :icon    => :lock,
    :action  => :lock,
    :confirm => true,
    :method  => :patch,
  }.merge(options)

  dorsale_button(url, options)
end

#read_button(url, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
# File 'app/helpers/dorsale/button_helper.rb', line 39

def read_button(url, options = {})
  options = {
    :icon   => "info-circle",
    :action => :read,
  }.merge(options)

  dorsale_button(url, options)
end

#snooze_button(url, options = {}) ⇒ Object



100
101
102
103
104
105
106
107
108
109
# File 'app/helpers/dorsale/button_helper.rb', line 100

def snooze_button(url, options = {})
  options = {
    :icon    => :"clock-o",
    :action  => :snooze,
    :confirm => true,
    :method  => :patch,
  }.merge(options)

  dorsale_button(url, options)
end

#unlock_button(url, options = {}) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'app/helpers/dorsale/button_helper.rb', line 122

def unlock_button(url, options = {})
  options = {
    :icon    => :unlock,
    :action  => :unlock,
    :confirm => true,
    :method  => :patch,
  }.merge(options)

  dorsale_button(url, options)
end

#update_button(url, options = {}) ⇒ Object



58
59
60
61
62
63
64
65
# File 'app/helpers/dorsale/button_helper.rb', line 58

def update_button(url, options = {})
  options = {
    :icon   => :pencil,
    :action => :update,
  }.merge(options)

  dorsale_button(url, options)
end