Module: LoldesignPublisher::PublisherHelper

Defined in:
app/helpers/loldesign_publisher/publisher_helper.rb

Instance Method Summary collapse

Instance Method Details

#activable_field_for(resource, options = {}) ⇒ Object



92
93
94
95
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 92

def activable_field_for(resource, options={})
  klass = options[:klass] || resource.class.to_s
  check_box_tag resource, :active, resource.active, data: {resource: klass, id: resource.id}, class: 'activable'
end

#add_resource(text, path) ⇒ Object



17
18
19
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 17

def add_resource(text, path)
  render partial: '/layouts/loldesign_publisher/modules/add_resource', locals: {text: text, path: path}
end

#cancel_action(options = {}) ⇒ Object



43
44
45
46
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 43

def cancel_action(options={})
  path = options[:path] || 'javascript://'
  default_button('Cancelar', path)      
end

#default_button(text, path = 'javascript://') ⇒ Object



48
49
50
51
52
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 48

def default_button(text, path='javascript://')
   :div, class: 'pretty medium info btn cancel' do
    link_to text, path
  end
end

#display_list_for(resources, options = {}) ⇒ Object



86
87
88
89
90
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 86

def display_list_for(resources, options={})
  total_fields = options[:fields] || 2
  
  render(resources) || render(partial: '/layouts/loldesign_publisher/modules/td_not_found', locals: {colspan: total_fields})
end

#edit_resource(path) ⇒ Object



21
22
23
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 21

def edit_resource(path)
  link_to(path) { gumby_icon 'pencil' }
end

#gumby_icon(icon_name) ⇒ Object



97
98
99
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 97

def gumby_icon(icon_name)
   :i, '', class: "icon-#{icon_name}"
end


72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 72

def nav_main_link(key)
  link_name = LoldesignPublisher.config[:menu_links][key]['name']

  if LoldesignPublisher.config[:menu_links][key]['path'].present?
    link_path = send(LoldesignPublisher.config[:menu_links][key]['path'])
    options   = {data: {active: controller_name == key}}
  else
    link_path = 'javascript://'
    options   = {}
  end
  
  link_to link_name, link_path, options
end

#remove_resource(path, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 29

def remove_resource(path, options={})
  message = options[:message] || 'Você tem certeza que deseja remover?'
  type    = options[:type]    || :link
  text    = options[:text]    || 'Remover'

  if type == :link
    link_to(path, method: :delete, data: {confirm: message}) { gumby_icon 'cancel-circled' }
  else
     :div, class: 'pretty medium danger btn remove' do
      link_to text, path, method: :delete, data: {confirm: message}
    end
  end
end

#save_resource(text, path) ⇒ Object



54
55
56
57
58
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 54

def save_resource(text, path)
   :div, class: 'pretty medium secondary btn save' do
    link_to text, path, data: {disable_with: '...'}
  end
end

#show_resource(text, path) ⇒ Object



66
67
68
69
70
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 66

def show_resource(text, path)
   :div, class: 'pretty medium default btn show' do
    link_to text, path
  end
end

#show_resource_with_icon(path) ⇒ Object



25
26
27
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 25

def show_resource_with_icon(path)
  link_to(path){ gumby_icon 'info-circled' }
end

#submit_button(form, text = 'Salvar') ⇒ Object



60
61
62
63
64
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 60

def submit_button(form, text='Salvar')
   :div, class: 'pretty medium secondary btn save' do
    form.submit text, data: {'disable-with' => '...'}
  end
end

#title_page(title, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/loldesign_publisher/publisher_helper.rb', line 5

def title_page(title, options={})
  save_options     = {display: options[:save].present?    , path: options[:save]     || 'javascript://'}
  show_options     = {display: options[:show].present?    , path: options[:show]     || 'javascript://'}
  subtitle_options = {display: options[:subtitle].present?, text: options[:subtitle] || ''             }

  render partial: '/layouts/loldesign_publisher/modules/title_page', locals: {title: title, 
                                                                              show_options:     show_options, 
                                                                              save_options:     save_options,
                                                                              subtitle_options: subtitle_options
                                                                            }
end