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