page can use default widget
This commit is contained in:
1 parent
9630d0a841
commit
0cc616f988
28 files changed
+305
-154
No files matched your search
@@ -10,33 +10,60 @@ module Admin::PagePartsHelper
|
||||
end
|
||||
|
||||
def widget_field_options(i,local_item=nil)
|
||||
local_item = @part if local_item.nil?
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @page if local_item.nil? && @page
|
||||
options = @module_app.widget_fields.collect{|widget_field| [I18n.t(widget_field[1]), widget_field[0]]}
|
||||
options_for_select(options, (local_item[:widget_field][i][0] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
|
||||
|
||||
case local_item
|
||||
when Page
|
||||
options_for_select(options, (local_item[:frontend_field][i][0] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
|
||||
when PagePart
|
||||
options_for_select(options, (local_item[:widget_field][i][0] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
|
||||
end
|
||||
end
|
||||
|
||||
def widget_fiield_type_options(i,local_item=nil)
|
||||
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
|
||||
local_item = @part if local_item.nil?
|
||||
options_for_select(options, (local_item[:widget_field][i][1] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @page if local_item.nil? && @page
|
||||
|
||||
case local_item
|
||||
when Page
|
||||
options_for_select(options, (local_item[:frontend_field][i][1] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
|
||||
when PagePart
|
||||
options_for_select(options, (local_item[:widget_field][i][1] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
|
||||
end
|
||||
end
|
||||
|
||||
def tag_checked_value(part,radio_value)
|
||||
part and (part[:tag] == radio_value) ? true : false
|
||||
part and (part[:tag] == radio_value.to_s) ? true : false
|
||||
end
|
||||
|
||||
|
||||
def category_checked_value(part,radio_value)
|
||||
part and (part[:category] == radio_value) ? true : false
|
||||
part and (part[:category] == radio_value.to_s) ? true : false
|
||||
end
|
||||
|
||||
def style_checked_value(part,radio_value)
|
||||
part and (part.widget_style == radio_value) ? true : false
|
||||
case part
|
||||
when Page
|
||||
(part.frontend_style == radio_value) ? true : false
|
||||
when PagePart
|
||||
(part.widget_style == radio_value) ? true : false
|
||||
when nil
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def nil_radio_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 = radio_button("page_part", tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
|
||||
op = radio_button(field_name, tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
|
||||
op << I18n.t("default_widget.no_value")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user