Module: Blacksand::ApplicationHelper

Defined in:
app/helpers/blacksand/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#filed_options(f) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/blacksand/application_helper.rb', line 10

def filed_options(f)
  filed_options = {}
  case f.object.field.field_type
    when 'date' then
      filed_options = {data: {provide: 'datepicker', 'date-format' => 'yyyy-mm-dd', 'date-language' => 'zh-CN', 'date-autoclose' => true}}
    when 'gallery' then
      filed_options = {multiple: true}
    when 'page' then
      filed_options = { class: 'test', data: {provide: 'select2'} }
  end
  return filed_options.merge({label: "#{f.object.field.description}", label_class: "#{'required' if f.object.field.required?}"})
end

#page_optionsObject



37
38
39
# File 'app/helpers/blacksand/application_helper.rb', line 37

def page_options
  @_page_options || {}
end

#paginate(objects, options = {}) ⇒ Object



4
5
6
7
8
# File 'app/helpers/blacksand/application_helper.rb', line 4

def paginate objects, options = {}
  options.reverse_merge!(theme: 'twitter-bootstrap-3')

  super(objects, options)
end

#select_choices(f) ⇒ Object



23
24
25
26
27
28
29
30
# File 'app/helpers/blacksand/application_helper.rb', line 23

def select_choices(f)
  if f.object.value.present?
    page = f.object.content
    [['', ''], ["##{page.id} #{page.title}", f.object.value]]
  else
    [['', '']]
  end
end

#set_page_options(hash) ⇒ Object



32
33
34
35
# File 'app/helpers/blacksand/application_helper.rb', line 32

def set_page_options(hash)
  @_page_options ||= {}
  @_page_options.merge!(hash)
end