add conditions for making multi cates and tags more stable
This commit is contained in:
parent
0d5ab20efa
commit
6efef253a6
|
@ -65,11 +65,11 @@ class Admin::PagePartsController < OrbitBackendController
|
||||||
params[:page_part][:module_app] = nil
|
params[:page_part][:module_app] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:page_part][:tag] && params[:page_part][:tag].include?("nil")
|
if params[:page_part][:tag].nil? || params[:page_part][:tag].include?("nil")
|
||||||
params[:page_part][:tag] = []
|
params[:page_part][:tag] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:page_part][:category] && params[:page_part][:category].include?("nil")
|
if params[:page_part][:category].nil? || params[:page_part][:category].include?("nil")
|
||||||
params[:page_part][:category] = []
|
params[:page_part][:category] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,45 +22,25 @@ helper Admin::PagePartsHelper
|
||||||
@item =Page.find(params[:id])
|
@item =Page.find(params[:id])
|
||||||
@user_choose = @item.app_frontend_url
|
@user_choose = @item.app_frontend_url
|
||||||
@apps = ModuleApp.excludes(app_pages: nil).entries
|
@apps = ModuleApp.excludes(app_pages: nil).entries
|
||||||
|
|
||||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||||
|
|
||||||
@designs = Design.all.entries
|
@designs = Design.all.entries
|
||||||
@design = @item.design ? @item.design : @designs.first
|
@design = @item.design ? @item.design : @designs.first
|
||||||
|
|
||||||
if @item.module_app
|
if @item.module_app
|
||||||
@app_frontend_urls = @item.module_app.app_pages.map{|t| [I18n.t(t[0]),t[1]]}
|
@app_frontend_urls = []
|
||||||
|
setup_app_frontend_and_style
|
||||||
@app_frontend_urls << [I18n.t('default_widget.name'),'default_widget'] if @item.module_app.has_default_widget?
|
@app_frontend_urls << [I18n.t('default_widget.name'),'default_widget'] if @item.module_app.has_default_widget?
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if @item.module_app
|
|
||||||
@module_app = @item.module_app
|
@module_app = @item.module_app
|
||||||
@frontend_path = @item.app_frontend_url
|
@frontend_path = @item.app_frontend_url
|
||||||
|
|
||||||
if @module_app && @module_app.widgets && @module_app.widgets.any?{|b| b.class == Array}
|
if @module_app && @module_app.widgets && @module_app.widgets.any?{|b| b.class == Array}
|
||||||
@frontend_style = @module_app.widgets[@frontend_path] if !@frontend_path.blank? && !@module_app.widgets.blank?
|
@frontend_style = @module_app.widgets[@frontend_path] if !@frontend_path.blank? && !@module_app.widgets.blank?
|
||||||
end
|
end
|
||||||
|
get_categories_and_tags
|
||||||
|
|
||||||
case @item.module_app.key
|
|
||||||
when 'announcement'
|
|
||||||
@categories = BulletinCategory.all
|
|
||||||
@tags = AnnouncementTag.all
|
|
||||||
when 'news'
|
|
||||||
@categories = NewsBulletinCategory.all
|
|
||||||
@tags = NewsTag.all
|
|
||||||
when 'web_resource'
|
|
||||||
@categories = WebLinkCategory.all
|
|
||||||
@tags = WebResourceTag.all
|
|
||||||
when 'archive'
|
|
||||||
@categories = ArchiveFileCategory.all
|
|
||||||
@tags = ArchiveTag.all
|
|
||||||
when 'faq'
|
|
||||||
@categories = QaCategory.all
|
|
||||||
@tags = FaqTag.all
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
@categories = nil
|
|
||||||
@module_app = @module_apps[0]
|
@module_app = @module_apps[0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -96,22 +76,17 @@ helper Admin::PagePartsHelper
|
||||||
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
||||||
end
|
end
|
||||||
|
|
||||||
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type], params[:page][:frontend_field_is_link] ) if params[:page][:frontend_field]
|
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) if params[:page][:frontend_field]
|
||||||
|
|
||||||
params[:page][:frontend_field_type] = nil
|
params[:page][:frontend_field_type] = nil
|
||||||
params[:page][:frontend_field_is_link] = nil
|
|
||||||
|
|
||||||
if params[:page][:tag] && params[:page][:tag].include?("nil")
|
if params[:page][:tag].nil? || params[:page][:tag].include?("nil")
|
||||||
params[:page][:tag] = []
|
params[:page][:tag] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:page][:category] && params[:page][:category].include?("nil")
|
if params[:page][:category].nil? || params[:page][:category].include?("nil")
|
||||||
params[:page][:category] = []
|
params[:page][:category] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
params[:page][:frontend_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page][:frontend_field].blank?
|
|
||||||
|
|
||||||
|
|
||||||
if @item.update_attributes(params[:page])
|
if @item.update_attributes(params[:page])
|
||||||
flash[:notice] = t('update.success.page')
|
flash[:notice] = t('update.success.page')
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -146,38 +121,43 @@ helper Admin::PagePartsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_front_end_setting
|
def reload_front_end_setting
|
||||||
@item = Page.find params[:id]
|
@item = Page.find params[:id] rescue nil
|
||||||
@module_app = ModuleApp.find params[:module_app_id]
|
@module_app = ModuleApp.find params[:module_app_id]
|
||||||
@chosen_frontend = @user_choose = params[:frontend]
|
@user_choose = params[:frontend] #choosen frontend
|
||||||
|
|
||||||
|
@app_frontend_urls = @module_app.nil? ? nil : @module_app.app_pages.each{|name,data| [I18n.t(data["i18n"]),name]}
|
||||||
|
@frontend_styles = @module_app.app_pages[params["frontend"]]["style"] rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_categories_and_tags
|
||||||
|
unless @module_app.nil?
|
||||||
|
@categories = @module_app.get_categories
|
||||||
|
@tags = @module_app.get_tags
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_app_frontend_and_style
|
||||||
|
if @module_app.nil?
|
||||||
|
@item.module_app.app_pages.each{|name,data| @app_frontend_urls << [I18n.t(data["i18n"]),name]}
|
||||||
|
else
|
||||||
|
@module_app.app_pages.each{|name,data| @app_frontend_urls << [I18n.t(data["i18n"]),name]}
|
||||||
|
end
|
||||||
|
|
||||||
|
@frontend_styles = @module_app.app_pages[params["frontend"]]["style"] rescue nil
|
||||||
|
@frontend_styles = @item.module_app.app_pages[@item.frontend_style]["style"] if @frontend_styles.nil? && @item && @item.module_app.app_pages[@item.frontend_style]
|
||||||
|
@frontend_styles = @item.module_app.app_pages.first[1]["style"] if @frontend_styles.nil? && @item
|
||||||
|
@frontend_styles = @module_app.app_pages.first[1]["style"] if @frontend_styles.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_frontend_pages
|
def reload_frontend_pages
|
||||||
@item = Page.find params[:id] rescue nil
|
@item = Page.find params[:id] rescue nil
|
||||||
# @categories =[]
|
|
||||||
@module_app = ModuleApp.find(params[:module_app_id]) rescue nil
|
@module_app = ModuleApp.find(params[:module_app_id]) rescue nil
|
||||||
@app_frontend_urls = @module_app.nil? ? nil : @module_app.app_pages.map{|t| [I18n.t(t[0]),t[1]]}
|
@app_frontend_urls = []
|
||||||
|
setup_app_frontend_and_style
|
||||||
@app_frontend_urls << [I18n.t('default_widget.name'),'default_widget'] if(@module_app && @module_app.has_default_widget?)
|
@app_frontend_urls << [I18n.t('default_widget.name'),'default_widget'] if(@module_app && @module_app.has_default_widget?)
|
||||||
|
|
||||||
case (@module_app.nil? ? nil : @module_app.key )
|
get_categories_and_tags
|
||||||
when 'announcement'
|
|
||||||
@categories = BulletinCategory.all
|
|
||||||
@tags = AnnouncementTag.all
|
|
||||||
when 'news'
|
|
||||||
@categories = NewsBulletinCategory.all
|
|
||||||
@tags = NewsTag.all
|
|
||||||
when 'web_resource'
|
|
||||||
@categories = WebLinkCategory.all
|
|
||||||
@tags = WebResourceTag.all
|
|
||||||
when 'archive'
|
|
||||||
@categories = ArchiveFileCategory.all
|
|
||||||
@tags = ArchiveTag.all
|
|
||||||
when 'faq'
|
|
||||||
@categories = QaCategory.all
|
|
||||||
@tags = FaqTag.all
|
|
||||||
else
|
|
||||||
@categories = []
|
|
||||||
@tags = []
|
|
||||||
end
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {}
|
format.js {}
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue