Module: Mokio::Backend::CommonHelper

Defined in:
app/helpers/mokio/backend/common_helper.rb

Instance Method Summary collapse

Instance Method Details

#active_button(arg = true) ⇒ Object



105
106
107
108
109
# File 'app/helpers/mokio/backend/common_helper.rb', line 105

def active_button(arg = true)
   :div, :class => "activebutton" do
    tag :input, :type => "checkbox", :checked => ("checked" if arg)
  end
end

#backend_modal_render(type, form_object) ⇒ Object



111
112
113
114
# File 'app/helpers/mokio/backend/common_helper.rb', line 111

def backend_modal_render(type,form_object)
  return "" unless ['google','facebook','seo_tags'].include?(type)
  render("mokio/common/modals/modal_#{type}",f: form_object)
end

#box_title(name = nil, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/mokio/backend/common_helper.rb', line 38

def box_title(name = nil, &block)
   :div, :class => "title" do
     :h4 do
      if name
        tag :span
        concat(name)
      end
      capture(&block) unless name
    end
  end
end

#btn_cancel(link) ⇒ Object



90
91
92
93
94
# File 'app/helpers/mokio/backend/common_helper.rb', line 90

def btn_cancel(link)
   :a, :class => "btn", :href => link do
    concat( bt("cancel") ) # bt in BackendHelper
  end
end

#btn_modal_cancelObject



96
97
98
99
100
101
102
# File 'app/helpers/mokio/backend/common_helper.rb', line 96

def btn_modal_cancel
  capture_haml do
    haml_tag :a, :class => "btn", 'data-dismiss' => 'modal' do
      haml_concat( bt("cancel") ) # bt in BackendHelper
    end
  end
end

#btn_new(name, link) ⇒ Object

action buttons



75
76
77
78
79
80
81
82
# File 'app/helpers/mokio/backend/common_helper.rb', line 75

def btn_new(name, link)
   :a, :href => link do
     :button, :class => "btn btn-primary btn-mini" do
      tag :span, :class => "icomoon-icon-plus white"
      concat(name)
    end
  end
end

#btn_submit(name, save_and_new = nil) ⇒ Object



84
85
86
87
88
# File 'app/helpers/mokio/backend/common_helper.rb', line 84

def btn_submit(name, save_and_new = nil)
   :button, :class => "btn btn-primary", :type => "submit", :name => "save_and_new", :value => "#{save_and_new}" do
    concat(name)
  end
end

#common_form(&block) ⇒ Object



30
31
32
33
34
35
36
# File 'app/helpers/mokio/backend/common_helper.rb', line 30

def common_form(&block)
   :div, :class => "form-row row-fluid" do
     :div, :class => "span12" do
      capture(&block)
    end
  end
end

#data_file_model(obj) ⇒ Object

returns which table stores data files for object default: data_files



13
14
15
# File 'app/helpers/mokio/backend/common_helper.rb', line 13

def data_file_model(obj)
  obj.respond_to?("data_file_type") ? obj.data_file_type.to_s.demodulize.tableize : "data_files"
end

#datatable_source_urlObject



24
25
26
27
28
# File 'app/helpers/mokio/backend/common_helper.rb', line 24

def datatable_source_url
  # with empty return  should work properly
  rescue
    contents_url( format: "json")
end

#has_data_files?(obj) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/helpers/mokio/backend/common_helper.rb', line 5

def has_data_files?(obj)
  obj.respond_to?("data_files") && obj.respond_to?("default_data_file")
end

#responsive_dynamic_table(&block) ⇒ Object



17
18
19
20
21
# File 'app/helpers/mokio/backend/common_helper.rb', line 17

def responsive_dynamic_table(&block)
   :table, :data => {:source => datatable_source_url}, :class => "responsive dynamicTable display table table-bordered", :border => 0, :cellpadding => 0, :cellspacing => 0, :width => "100%", :id =>"dTable" do
    capture(&block)
  end
end

#table_controls_copy_btn(link) ⇒ Object



66
67
68
69
70
# File 'app/helpers/mokio/backend/common_helper.rb', line 66

def table_controls_copy_btn(link)
   :a, :class => "tip", :href => link, "data-hasqtip" => true, "aria-describedby" => "qtip-2", :title => bt("copy") do
    tag :span, :class => "icon12 icomoon-icon-copy-2"
  end
end

#table_controls_delete_btn(link, confirm = bt("confirm")) ⇒ Object



60
61
62
63
64
# File 'app/helpers/mokio/backend/common_helper.rb', line 60

def table_controls_delete_btn(link, confirm = bt("confirm"))
   :a, :rel => "nofollow", :href => link, :data => { :method => "delete", :confirm => confirm, :hasqtip => true }, :class => "tip", :title => bt("delete") do
    tag :span, :class => "icon12 icomoon-icon-remove"
  end
end

#table_controls_edit_btn(link, from_commons_datatable = false) ⇒ Object

Buttons

controls buttons



54
55
56
57
58
# File 'app/helpers/mokio/backend/common_helper.rb', line 54

def table_controls_edit_btn(link, from_commons_datatable = false)
   :a, :class => "tip", :href => link, "data-hasqtip" => true, "aria-describedby" => "qtip-2", :title => bt("edit") do
    tag :span, :class => "icon12 icomoon-icon-pencil"
  end
end