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



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

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



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

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

  dorsale_button(url, options)
end

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



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

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



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

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



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

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



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

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



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

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

  dorsale_button(url, options)
end


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

def print_button(options = {})
  options = {
    :icon    => :print,
    :action  => :print,
    :class   => "btn btn-xs btn-default",
    :onclick => "print(); return false;",
  }.merge(options)

  dorsale_button("#", options)
end

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



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

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

  dorsale_button(url, options)
end

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



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

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



132
133
134
135
136
137
138
139
140
141
# File 'app/helpers/dorsale/button_helper.rb', line 132

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



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

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

  dorsale_button(url, options)
end