Module: AdminHelper

Defined in:
app/helpers/admin_helper.rb

Instance Method Summary collapse

Instance Method Details



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/admin_helper.rb', line 4

def basket_edit_link basket , options = {}
  return "---" unless basket
  return "" unless request.url.include?("basket")
  text = t(:edit) + " " 
  link = edit_basket_path(basket)
  case basket.kori
  when Order
    text += I18n.t(:order)
    link = order_path(basket.kori) rescue ""
  when Purchase
    text += I18n.t(:purchase)
    link = purchase_path(basket.kori) rescue ""
  else
    text += t(:basket)
  end
  return link_to text , link , options 
end

#in_place(object, field, attributes = {}) ⇒ Object

define a bunch of defaults for the best_in_place call save and cancel buttons with internationlized texts bootstrap form class a default note same signature as best_in_place, ie object, field symbol , hash



32
33
34
35
36
37
38
# File 'app/helpers/admin_helper.rb', line 32

def in_place object , field , attributes ={}
  defaults = { :ok_button => I18n.t(:edit), :ok_button_class => "btn btn-success" , 
               :cancel_button => I18n.t(:cancel) , :cancel_button_class => "btn btn-warning",
               :place_holder => I18n.t(:edit)  , :inner_class => "form-control" }
  attributes.reverse_merge! defaults 
  best_in_place(object , field , attributes)
end

#sort_date(key) ⇒ Object



22
23
24
25
# File 'app/helpers/admin_helper.rb', line 22

def sort_date key
  return "" unless params[:q]
  params[:q][key] || ""
end