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
@@ -11,7 +11,7 @@ class DefaultWidgetController< OrbitWidgetController
|
||||
@default_widget = @page_part.module_app.get_default_widget
|
||||
@widget_image_field = @default_widget[:image]
|
||||
data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
||||
@data = eval(@default_widget[:query]).limit(data_limit).includes(@widget_image_field)
|
||||
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field)
|
||||
@fields = @page_part.widget_field
|
||||
|
||||
case params[:type]
|
||||
|
||||
@@ -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
|
||||
@@ -19,6 +19,9 @@ class ModuleApp
|
||||
field :widget_fields ,type: Array
|
||||
field :widget_options,type:Hash
|
||||
field :widget_options_fields_i18n,type:Hash
|
||||
field :widget_fields_link_method,type:Hash
|
||||
field :get_default_widget,type:Hash
|
||||
|
||||
has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app
|
||||
has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
|
||||
|
||||
@@ -30,13 +33,6 @@ class ModuleApp
|
||||
|
||||
before_save :set_key
|
||||
|
||||
#>>>>>>>>>>>>> remove after app config applied
|
||||
def get_default_widget
|
||||
{:query=>'Bulletin.all',:image=> 'image'}
|
||||
end
|
||||
#<<<<<<<<<<<<@@
|
||||
|
||||
|
||||
def is_manager?(user)
|
||||
managing_users.include?(user)
|
||||
end
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<% @module_app.widget_fields.each_with_index do |widget_field, i| %>
|
||||
<%= i+1 %>
|
||||
<%= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %>
|
||||
<%= select_tag "page_part[widget_field_type][]", options_for_select(LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %> <br />
|
||||
<%= select_tag "page_part[widget_field][]", widget_field_options(i), :include_blank => true %>
|
||||
<%= select_tag "page_part[widget_field_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
|
||||
<% end %>
|
||||
|
||||
<%= label_tag :widget_data_count %>
|
||||
|
||||
@@ -4,20 +4,14 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<% @fields.each do |field|%>
|
||||
<th><%= content_tag(:span,field[0],:class=>field[1])%></th>
|
||||
<th><%= content_tag(:span,get_field_header(field[0]),:class=>field[1])%></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @data.each do |row_data| %>
|
||||
<tr>
|
||||
<% @fields.each do |field|%>
|
||||
<% if field[0] == "bulletin_category"%>
|
||||
<td><%= content_tag(:span,row_data.send(field[0]).title,:class=>field[1])%></td>
|
||||
<% elsif field[0] == "title" %>
|
||||
<td><%= content_tag(:span, link_to(row_data.send(field[0]), panel_announcement_front_end_bulletin_path(row_data)), :class=>field[1]) %></td>
|
||||
<% else %>
|
||||
<td><%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%></td>
|
||||
<% end %>
|
||||
<td><%= content_tag(:span,link_to_field(row_data,field[0]),:class=>field[1])%></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -7,13 +7,7 @@
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<% @fields.each do |field|%>
|
||||
<% if field[0] == "bulletin_category"%>
|
||||
<%= content_tag(:span,row_data.send(field[0]).title,:class=>field[1])%>
|
||||
<% elsif field[0] == "title" %>
|
||||
<%= content_tag(:span, link_to(row_data.send(field[0]), panel_announcement_front_end_bulletin_path(row_data)), :class=>field[1]) %>
|
||||
<% else %>
|
||||
<%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%>
|
||||
<% end %>
|
||||
<%= content_tag(:span,link_to_field(row_data,field[0]),:class=>field[1])%>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -6,13 +6,7 @@
|
||||
<% @data.each do |row_data| %>
|
||||
<%= content_tag(:li) do %>
|
||||
<% @fields.each do |field|%>
|
||||
<% if field[0] == "bulletin_category"%>
|
||||
<%= content_tag(:span,row_data.send(field[0]).title,:class=>field[1])%>
|
||||
<% elsif field[0] == "title" %>
|
||||
<%= content_tag(:span, link_to(row_data.send(field[0]), panel_announcement_front_end_bulletin_path(row_data)), :class=>field[1]) %>
|
||||
<% else %>
|
||||
<%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%>
|
||||
<% end %>
|
||||
<%= content_tag(:span,link_to_field(row_data,field[0]),:class=>field[1])%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in new issue
Block a user