2013-01-02 06:34:34 +00:00
|
|
|
module Admin::PagePartsHelper
|
|
|
|
|
|
|
|
def support_link
|
|
|
|
url_method = @module_app.get_default_widget[:url_method]
|
|
|
|
unless url_method.nil?
|
|
|
|
res = "Link:"
|
|
|
|
res << select_tag( "page_part[widget_field_is_link][]", options_for_select([["NotLink",false],["Link1",url_method]]))
|
|
|
|
res.html_safe
|
|
|
|
end
|
|
|
|
end
|
2013-01-04 10:42:25 +00:00
|
|
|
|
2013-02-18 07:13:31 +00:00
|
|
|
def get_widget_field_rel(local_item=nil)
|
|
|
|
local_item = @part if local_item.nil? && @part
|
2013-03-19 09:49:46 +00:00
|
|
|
local_item = @item if local_item.nil? && @item
|
2013-02-18 07:13:31 +00:00
|
|
|
case local_item
|
|
|
|
when Page
|
2013-03-28 10:29:24 +00:00
|
|
|
reload_after_list_changed_admin_pages_path
|
2013-02-18 07:13:31 +00:00
|
|
|
when PagePart
|
2013-03-28 10:29:24 +00:00
|
|
|
reload_after_list_changed_admin_page_part_path
|
2013-02-18 07:13:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-28 10:29:24 +00:00
|
|
|
def link_to_field_switch( i ,object_name,field_name,local_item=nil,assign_field_name_value=nil) #link_to_field is for showing
|
|
|
|
field_is_checked = nil
|
|
|
|
local_item = case
|
|
|
|
when local_item.nil? && @part
|
|
|
|
@part
|
|
|
|
when local_item.nil? && @item
|
|
|
|
@item
|
|
|
|
end
|
2013-02-18 11:04:04 +00:00
|
|
|
|
2013-03-28 10:29:24 +00:00
|
|
|
field_is_checked = local_item.default_widget_field_sat_to_link?(i)
|
|
|
|
res = hidden_field_tag "#{object_name}[#{field_name}][][sat_to_link]", 'false'
|
2013-02-18 07:13:31 +00:00
|
|
|
|
2013-03-28 10:29:24 +00:00
|
|
|
unless field_is_checked.nil? and assign_field_name_value.nil?
|
|
|
|
origin_field = nil
|
|
|
|
|
|
|
|
origin_field = @module_app.widget_fields.select{|t| t.first.to_s==(assign_field_name_value || local_item.default_widget_field_name[i])}.first
|
2013-02-23 07:19:51 +00:00
|
|
|
|
2013-03-28 10:29:24 +00:00
|
|
|
if origin_field and origin_field[2]==:link #choosen_field_is_link
|
2013-02-18 07:13:31 +00:00
|
|
|
|
2013-03-28 10:29:24 +00:00
|
|
|
res = label_tag '' do
|
|
|
|
check_box_tag("#{object_name}[#{field_name}][][sat_to_link]", "true", field_is_checked) + I18n.t("default_widget.field_is_link")
|
|
|
|
end
|
|
|
|
else # choosen_field_not_link
|
|
|
|
return res
|
|
|
|
end # of if choosen_field_is_link
|
|
|
|
else
|
|
|
|
return res
|
|
|
|
end
|
2013-02-18 07:13:31 +00:00
|
|
|
end
|
|
|
|
|
2013-01-09 03:23:18 +00:00
|
|
|
def widget_field_options(i,local_item=nil)
|
2013-01-21 08:56:37 +00:00
|
|
|
local_item = @part if local_item.nil? && @part
|
2013-03-19 09:49:46 +00:00
|
|
|
local_item = @item if local_item.nil? && @item
|
2013-01-29 12:33:40 +00:00
|
|
|
|
|
|
|
options = @module_app.widget_fields.collect do |widget_field|
|
|
|
|
label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}")
|
|
|
|
[label, widget_field[0]]
|
|
|
|
end
|
2013-01-21 08:56:37 +00:00
|
|
|
case local_item
|
|
|
|
when Page
|
2013-03-28 10:29:24 +00:00
|
|
|
options_for_select(options, (local_item.frontend_field_name[i] if(local_item) ))
|
2013-01-21 08:56:37 +00:00
|
|
|
when PagePart
|
2013-03-28 10:29:24 +00:00
|
|
|
options_for_select(options, (local_item.widget_field_name[i] if(local_item) ))
|
2013-01-21 08:56:37 +00:00
|
|
|
end
|
2013-01-04 10:42:25 +00:00
|
|
|
end
|
|
|
|
|
2013-03-28 10:29:24 +00:00
|
|
|
def widget_fiield_class_options(i,local_item=nil)
|
2013-01-04 10:42:25 +00:00
|
|
|
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
|
2013-01-21 08:56:37 +00:00
|
|
|
local_item = @part if local_item.nil? && @part
|
2013-03-19 09:49:46 +00:00
|
|
|
local_item = @item if local_item.nil? && @item
|
2013-01-21 08:56:37 +00:00
|
|
|
|
|
|
|
case local_item
|
|
|
|
when Page
|
2013-03-28 10:29:24 +00:00
|
|
|
options_for_select(options, (local_item.frontend_class[i] if (local_item) ))
|
2013-01-21 08:56:37 +00:00
|
|
|
when PagePart
|
2013-03-28 10:29:24 +00:00
|
|
|
options_for_select(options, (local_item.widget_class[i] if (local_item) ))
|
2013-01-21 08:56:37 +00:00
|
|
|
end
|
2013-01-04 10:42:25 +00:00
|
|
|
end
|
|
|
|
|
2013-01-10 10:00:58 +00:00
|
|
|
def tag_checked_value(part,radio_value)
|
2013-01-23 10:51:18 +00:00
|
|
|
if radio_value.blank?
|
2013-02-06 11:51:53 +00:00
|
|
|
(part.nil? || part[:tag].blank?) ? true : false
|
2013-01-23 10:51:18 +00:00
|
|
|
else
|
2013-02-06 11:51:53 +00:00
|
|
|
part and (part[:tag].include?(radio_value.to_s)) ? true : false
|
2013-01-23 10:51:18 +00:00
|
|
|
end
|
2013-01-10 10:00:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def category_checked_value(part,radio_value)
|
2013-01-23 10:51:18 +00:00
|
|
|
if radio_value.blank?
|
2013-02-06 11:51:53 +00:00
|
|
|
(part.nil? || part[:category].blank?) ? true : false
|
2013-01-23 10:51:18 +00:00
|
|
|
else
|
2013-02-06 11:51:53 +00:00
|
|
|
part and (part[:category].include?(radio_value.to_s)) ? true : false
|
2013-01-23 10:51:18 +00:00
|
|
|
end
|
2013-01-10 10:00:58 +00:00
|
|
|
end
|
2013-01-09 03:23:18 +00:00
|
|
|
|
2013-01-10 10:00:58 +00:00
|
|
|
def style_checked_value(part,radio_value)
|
2013-01-21 08:56:37 +00:00
|
|
|
case part
|
|
|
|
when Page
|
2013-01-23 10:51:18 +00:00
|
|
|
if part.frontend_style.nil? && radio_value == "typeA"
|
|
|
|
true
|
|
|
|
else
|
|
|
|
(part.frontend_style == radio_value) ? true : false
|
|
|
|
end
|
2013-01-21 08:56:37 +00:00
|
|
|
when PagePart
|
2013-01-23 10:51:18 +00:00
|
|
|
if part.widget_style.nil? && radio_value == "typeA"
|
|
|
|
true
|
|
|
|
else
|
|
|
|
(part.widget_style == radio_value) ? true : false
|
|
|
|
end
|
2013-01-21 08:56:37 +00:00
|
|
|
when nil
|
|
|
|
false
|
|
|
|
end
|
2013-01-10 10:00:58 +00:00
|
|
|
end
|
2013-01-09 03:23:18 +00:00
|
|
|
|
2013-02-06 11:51:53 +00:00
|
|
|
def nil_checkbox_button(part,tag_or_cate)
|
|
|
|
field_name = case part
|
|
|
|
when PagePart
|
|
|
|
'page_part'
|
|
|
|
when Page
|
|
|
|
'page'
|
|
|
|
end
|
|
|
|
content_tag :label,:class=>"radio inline" do
|
|
|
|
op = check_box_tag("#{field_name}[#{tag_or_cate}][]", 'nil' , eval("#{tag_or_cate}_checked_value(part,'')"),:class=>'select_all')
|
|
|
|
op << I18n.t("default_widget.no_value")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-10 10:00:58 +00:00
|
|
|
def nil_radio_button(part,tag_or_cate)
|
2013-01-21 08:56:37 +00:00
|
|
|
field_name = case part
|
|
|
|
when PagePart
|
|
|
|
'page_part'
|
|
|
|
when Page
|
|
|
|
'page'
|
|
|
|
end
|
2013-01-10 10:00:58 +00:00
|
|
|
content_tag :label,:class=>"radio inline" do
|
2013-01-21 08:56:37 +00:00
|
|
|
op = radio_button(field_name, tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
|
2013-01-10 10:00:58 +00:00
|
|
|
op << I18n.t("default_widget.no_value")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_default_widget_setting_panel
|
2013-01-24 05:39:08 +00:00
|
|
|
@module_app && @module_app.has_default_widget? && (!@user_choose.nil? && @user_choose== 'default_widget') #&& @part.widget_path == 'default_widget'
|
2013-01-10 10:00:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show_custom_widget_setting_panel
|
2013-01-14 10:49:23 +00:00
|
|
|
true
|
2013-01-10 10:00:58 +00:00
|
|
|
end
|
2013-01-09 03:23:18 +00:00
|
|
|
|
2013-01-02 06:34:34 +00:00
|
|
|
end
|