59 lines
1.6 KiB
Ruby
59 lines
1.6 KiB
Ruby
|
module Admin::FrontendWidgetInterface
|
||
|
|
||
|
protected
|
||
|
def get_categories_and_tags
|
||
|
unless @selected[:module_app].nil?
|
||
|
@categories = @selected[:module_app].get_categories
|
||
|
@tags = @selected[:module_app].get_tags
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def get_frontend_data_count
|
||
|
local_item = set_local_item
|
||
|
@page_frontend_data_counts = @selected[:module_app].get_registration.get_data_count rescue []
|
||
|
@selected[:page_frontend_data_count] = case local_item
|
||
|
when PagePart
|
||
|
local_item.widget_data_count
|
||
|
when Page
|
||
|
local_item.frontend_data_count
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def clean_tags_and_category_params
|
||
|
field_name = set_field_name
|
||
|
|
||
|
if self.class==Admin::PagePartsController and params[field_name][:module_app].blank?
|
||
|
params[field_name][:module_app] = nil
|
||
|
end
|
||
|
if params[field_name][:tag].nil? || params[:page][:tag].include?("nil")
|
||
|
params[field_name][:tag] = []
|
||
|
end
|
||
|
|
||
|
if params[field_name][:category].nil? || params[:page][:category].include?("nil")
|
||
|
params[field_name][:category] = []
|
||
|
end
|
||
|
end #of clean_tags_and_category_params
|
||
|
|
||
|
def set_local_item
|
||
|
local_item = @part
|
||
|
local_item = @item if local_item.nil? && @item
|
||
|
local_item
|
||
|
end
|
||
|
|
||
|
def set_field_name
|
||
|
case self.class.to_s
|
||
|
when "Admin::PagesController"
|
||
|
return "page"
|
||
|
when "Admin::PagePartsController"
|
||
|
return "page_part"
|
||
|
end # of case
|
||
|
end
|
||
|
|
||
|
def select_array_for_app_frontend_urls(hash)
|
||
|
ary = hash.collect{|name,data| [I18n.t(data["i18n"]),name]}
|
||
|
ary << [I18n.t('default_widget.name'),'default_widget'] if @selected[:module_app] and @selected[:module_app].has_default_widget?
|
||
|
ary
|
||
|
end
|
||
|
|
||
|
|
||
|
end
|