default widget link.
make sure to run rake migrate:make_default_widget_work_config for changing announcement module app
This commit is contained in:
1 parent
a34da20e48
commit
5793f0fe5d
16 files changed
+100
-50
No files matched your search
@@ -8,4 +8,15 @@ module Admin::PagePartsHelper
|
||||
res.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def widget_field_options(i)
|
||||
options = @module_app.widget_fields.collect{|widget_field| [I18n.t(widget_field[1]), widget_field[0]]}
|
||||
options_for_select(options, (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) )
|
||||
end
|
||||
|
||||
def widget_fiield_type_options(i)
|
||||
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
|
||||
options_for_select(options, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
module DefaultWidgetHelper
|
||||
def get_field_header(field)
|
||||
I18n.t(@page_part.module_app.widget_fields.select{|t|t[0]==field}[0][1])
|
||||
end
|
||||
|
||||
def link_to_field(row_data,field)
|
||||
method_ary = @page_part.module_app.widget_fields_link_method
|
||||
if method_ary.has_key? field
|
||||
url = case method_ary[field]["args"]
|
||||
when nil # no args
|
||||
eval(method_ary[field]["method"])
|
||||
when :self # passing self
|
||||
eval "#{method_ary[field]['method']}('#{row_data.id}')"
|
||||
else
|
||||
ary = method_ary[field]["args"].clone
|
||||
object_hash = ary.each do |key,val|
|
||||
ary[key]= row_data.send(val[0]).send(val[1]).to_s
|
||||
end
|
||||
binding.pry
|
||||
eval "#{method_ary[field]['method']}(#{object_hash})"
|
||||
end
|
||||
|
||||
link_to row_data.send(field),url
|
||||
else
|
||||
row_data.send(field)
|
||||
end
|
||||
end
|
||||
|
||||
# def get_args_mapping(object,row_hash)
|
||||
# first_hash = row_hash.first
|
||||
|
||||
# # row_data.send(method_ary[field]["args"])
|
||||
# end
|
||||
|
||||
|
||||
def get_row_data(row_data,field)
|
||||
field_is_link = (field[0][1]== 'false' ? false : true )
|
||||
field_setting = {:class=>field[0][1],:method=>field[0][0]}
|
||||
if field_is_link
|
||||
field_link = field[0][1].to_s + '_path'
|
||||
binding.pry
|
||||
link = link_to(row_data.send(field_setting[:method]),field_link.send(row_data))
|
||||
content_tag(:span,link,:class=>field_setting[:class])
|
||||
else
|
||||
content_tag(:span,row_data.send(field_setting[:method]),:class=>field_setting[:class])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
module DefaultWidgetsHelper
|
||||
def get_row_data(row_data,field)
|
||||
field_is_link = (field[0][1]== 'false' ? false : true )
|
||||
field_setting = {:class=>field[0][1],:method=>field[0][0]}
|
||||
if field_is_link
|
||||
field_link = field[0][1].to_s + '_path'
|
||||
binding.pry
|
||||
link = link_to(row_data.send(field_setting[:method]),field_link.send(row_data))
|
||||
content_tag(:span,link,:class=>field_setting[:class])
|
||||
else
|
||||
content_tag(:span,row_data.send(field_setting[:method]),:class=>field_setting[:class])
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user