fix default widget link
This commit is contained in:
parent
8592015b1b
commit
73bca03b33
|
@ -54,7 +54,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
binding.pry
|
||||
|
||||
@part = PagePart.find(params[:id])
|
||||
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type],params[:page_part][:widget_field_is_link] )
|
||||
|
||||
|
@ -73,7 +73,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
params[:page_part][:category] = []
|
||||
end
|
||||
|
||||
|
||||
params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )}
|
||||
|
||||
if @part.update_attributes(params[:page_part])
|
||||
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
|
||||
|
|
|
@ -60,15 +60,12 @@ class DefaultWidgetController< OrbitWidgetController
|
|||
when "typeA"
|
||||
@tag_class = 'default_widget_typeA'
|
||||
@partial = "typeA"
|
||||
render "typeA"
|
||||
when /typeB_/
|
||||
@tag_class = "default_widget_#{params[:type]}"
|
||||
@partial = "typeB"
|
||||
render "typeB"
|
||||
when "typeC"
|
||||
@tag_class = 'default_widget_typeC'
|
||||
@partial = "typeC"
|
||||
render "typeC"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,11 +21,10 @@ module Admin::PagePartsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def field_link_switch(i,object_name,field_name,local_item=nil,prefill_value=nil)
|
||||
def link_to_field_switch(i,object_name,field_name,local_item=nil,prefill_value=nil) #link_to_field is for showing
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @page if local_item.nil? && @page
|
||||
res = ''
|
||||
|
||||
choosen_value = prefill_value || (local_item[:widget_field][i][0] rescue nil)
|
||||
|
||||
if choosen_value
|
||||
|
@ -38,13 +37,13 @@ module Admin::PagePartsHelper
|
|||
if choosen_field_is_link
|
||||
value = case local_item
|
||||
when Page
|
||||
local_item[:frontend_field][i][2]
|
||||
local_item[:frontend_field][i][2] rescue false
|
||||
when PagePart
|
||||
local_item[:widget_field][i][2]
|
||||
local_item[:widget_field][i][2] rescue false
|
||||
end
|
||||
|
||||
|
||||
res = label_tag '' do
|
||||
check_box_tag("#{object_name}[#{field_name}_is_link][]", value = "true", value) + I18n.t("default_widget.field_is_link")
|
||||
check_box_tag("#{object_name}[#{field_name}_is_link][]", "true", value) + I18n.t("default_widget.field_is_link")
|
||||
end
|
||||
else # choosen_field_not_link
|
||||
res = hidden_field_tag "#{object_name}[#{field_name}_is_link][]", 'false'
|
||||
|
|
|
@ -6,7 +6,7 @@ module DefaultWidgetHelper
|
|||
def link_to_field(row_data,field, switch, options=nil)
|
||||
method_ary = @page_part.module_app.widget_fields_link_method
|
||||
field = field.to_sym
|
||||
if(method_ary.has_key?(field) and (switch == "true"))
|
||||
if(method_ary.has_key?(field) and (switch == true))
|
||||
url = case method_ary[field][:args]
|
||||
when nil # no args
|
||||
get_data_link(method_ary[field]["method"], options)
|
||||
|
@ -51,7 +51,7 @@ module DefaultWidgetHelper
|
|||
eval eval("#{method_entry}(#{options})")
|
||||
when BSON::ObjectId
|
||||
object = "'#{object.to_s}'"
|
||||
eval("#{method_entry}(#{object}, #{options})")
|
||||
eval("#{method_entry}(#{{:id => object}.merge options})")
|
||||
when Hash
|
||||
eval("#{method_entry}(#{object.merge options})")
|
||||
else
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<%= select_tag "#{object_name}[#{field_name}_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
|
||||
</span>
|
||||
<span class="span5 link_switch_holder">
|
||||
<%= field_link_switch(i,object_name,field_name) %>
|
||||
<%= link_to_field_switch(i,object_name,field_name) %>
|
||||
</span>
|
||||
</div><br/>
|
||||
<% end %>
|
||||
|
|
|
@ -1 +1 @@
|
|||
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j field_link_switch(@index,'page_part','widget_field',nil,@choosen_field) %>");
|
||||
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j link_to_field_switch(@index,'page_part','widget_field',nil,@choosen_field) %>");
|
Loading…
Reference in New Issue