solved conflicts
This commit is contained in:
1 parent
e7bffe4c0f
commit
0781779ac0
28 files changed
+316
-265
No files matched your search
@@ -1,7 +1,6 @@
|
||||
class Admin::PagePartsController < OrbitBackendController
|
||||
|
||||
include Admin::FrontendWidgetInterface
|
||||
layout "site_editor"
|
||||
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :set_current_item
|
||||
@@ -18,59 +17,75 @@ class Admin::PagePartsController < OrbitBackendController
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@part = PagePart.find(params[:id])
|
||||
@module_apps = ModuleApp.where(:key.in=>OrbitApp::Module::WidgetUtility.all.keys).order_by(:title, :asc)
|
||||
@module_app = @part.module_app ? @part.module_app : nil
|
||||
@user_choose = @part.widget_path
|
||||
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
|
||||
if @module_app
|
||||
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
|
||||
@widget_style = @module_app.get_widget_style[@widget_path][:style] unless @widget_path.nil? or @module_app.nil?
|
||||
end
|
||||
|
||||
@module_apps = ModuleApp.for_widget_select
|
||||
@categories = nil
|
||||
@tags = nil
|
||||
@page_frontend_data_counts = nil
|
||||
# @frontend_styles = nil
|
||||
|
||||
unless @module_app.nil?
|
||||
@categories = @module_app.get_categories
|
||||
@tags = @module_app.get_tags
|
||||
end
|
||||
|
||||
@widget_path = @part.widget_path ? @part.widget_path : (@module_app.widgets.keys[0] rescue nil)
|
||||
|
||||
if @module_app && @module_app.widgets.any?{|b| b.class == Array}
|
||||
@widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
|
||||
end
|
||||
@selected={
|
||||
:module_app=> @part.module_app ? @part.module_app : nil,
|
||||
:app_frontend_url=> @part.widget_path, #@module_apps.first
|
||||
:category=>nil, #fetch by method: get_categories_and_tags
|
||||
:tag=>nil, #fetch by method: get_categories_and_tags
|
||||
:page_frontend_data_count=>nil,
|
||||
:frontend_style => nil,
|
||||
:widget_path=> nil
|
||||
}
|
||||
|
||||
@selected[:widget_path] = @part.widget_path ? @part.widget_path : (@selected[:module_app].widgets.keys[0] rescue nil)
|
||||
get_categories_and_tags
|
||||
get_frontend_data_count
|
||||
@app_frontend_urls = get_app_frontend_urls
|
||||
end
|
||||
|
||||
def create
|
||||
def reload_widgets
|
||||
@part = PagePart.find params[:id]
|
||||
@selected={
|
||||
:module_app=> ModuleApp.find(params["module_app_id"])
|
||||
}
|
||||
get_categories_and_tags
|
||||
get_frontend_data_count
|
||||
@selected[:app_frontend_url] = @selected[:module_app].has_default_widget? ? 'default_widget' : @selected[:module_app].widget_options.first.name
|
||||
end
|
||||
|
||||
|
||||
def reload_widget_styles
|
||||
@part = PagePart.find(params[:id])
|
||||
@selected={
|
||||
:module_app=> ModuleApp.find(params["module_app_id"]),
|
||||
:app_frontend_url=> params["frontend"], #@module_apps.first
|
||||
:category=>nil, #fetch by method: get_categories_and_tags
|
||||
:tag=>nil, #fetch by method: get_categories_and_tags
|
||||
:page_frontend_data_count=>nil,
|
||||
:frontend_style => nil,
|
||||
:widget_path=> nil
|
||||
}
|
||||
get_categories_and_tags
|
||||
get_frontend_data_count
|
||||
end
|
||||
|
||||
def reload_widget_field
|
||||
@index = params[:field_seri].to_i
|
||||
@part = PagePart.find(params[:id])
|
||||
@selected = {
|
||||
:module_app=> ModuleApp.find(params["module_app_id"]),
|
||||
:default_widget_field=>params[:widget_field_value]
|
||||
}
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@part = PagePart.find(params[:id])
|
||||
|
||||
# params[:page_part][:widget_field_type] = nil
|
||||
# params[:page_part][:widget_field_is_link] = nil
|
||||
|
||||
if params[:page_part][:module_app].blank?
|
||||
params[:page_part][:module_app] = nil
|
||||
end
|
||||
|
||||
if params[:page_part][:tag].nil? || params[:page_part][:tag].include?("nil")
|
||||
params[:page_part][:tag] = []
|
||||
end
|
||||
|
||||
if params[:page_part][:category].nil? || params[:page_part][:category].include?("nil")
|
||||
params[:page_part][:category] = []
|
||||
end
|
||||
clean_tags_and_category_params
|
||||
|
||||
# params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page_part][:widget_field].blank?
|
||||
if @part.update_attributes(params[:page_part])
|
||||
@@ -101,41 +116,6 @@ class Admin::PagePartsController < OrbitBackendController
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
end
|
||||
|
||||
def reload_widget_field
|
||||
@index = params[:field_seri].to_i
|
||||
@part = PagePart.find params[:id]
|
||||
@choosen_field = params[:widget_field_value]
|
||||
@module_app = @part.module_app
|
||||
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
|
||||
end
|
||||
|
||||
def reload_widgets
|
||||
@part = PagePart.find params[:id]
|
||||
@module_app = ModuleApp.find(params[:module_app_id]) rescue nil
|
||||
@categories =@module_app ? @module_app.get_categories : []
|
||||
@tags =@module_app ? @module_app.get_tags : []
|
||||
@widget_path = @module_app.widgets.keys[0] if (@module_app && @module_app.widgets[0].blank? )
|
||||
@widget_style = @module_app.widgets[@widget_path] if ( !@widget_path.blank? )
|
||||
|
||||
@part.widget_path = @module_app.widgets.first if( @module_app)
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_widget_styles
|
||||
@module_app = ModuleApp.find(params[:module_app_id])
|
||||
|
||||
@part = PagePart.find params[:id]
|
||||
@user_choose =@widget_path= params[:frontend]
|
||||
@widget_style = @module_app.widgets[@widget_path]
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_r_tag_options
|
||||
@part = PagePart.find params[:id]
|
||||
@r_tag = params[:type]
|
||||
@@ -146,6 +126,11 @@ class Admin::PagePartsController < OrbitBackendController
|
||||
end
|
||||
|
||||
protected
|
||||
def get_app_frontend_urls
|
||||
@selected[:module_app] ? @selected[:module_app].widgets.collect{|k,v| [I18n.t(v["i18n"]),k]} : []
|
||||
# has_old_value = @selected[:module_app].app_pages[@selected[:app_frontend_url]]
|
||||
# @frontend_styles = has_old_value ? has_old_value["style"] : (@selected[:module_app].app_pages.first[1]["style"] rescue nil)
|
||||
end
|
||||
|
||||
def set_children_sub_menu(part)
|
||||
part.page.children.each do |child|
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Admin::PagesController < Admin::ItemsController
|
||||
helper Admin::PagePartsHelper
|
||||
include Admin::FrontendWidgetInterface
|
||||
def show
|
||||
@item = Page.find(params[:id])
|
||||
respond_to do |format|
|
||||
@@ -13,40 +14,123 @@ helper Admin::PagePartsHelper
|
||||
def new
|
||||
@item = Page.new
|
||||
@item.parent = Item.find(params[:parent_id]) rescue nil
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
# @apps = ModuleApp.for_frontend_select
|
||||
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
@themes = Design.first.themes
|
||||
@module_apps = ModuleApp.for_frontend_select
|
||||
@app_frontend_urls = nil
|
||||
@categories = nil
|
||||
@tags = nil
|
||||
@page_frontend_data_counts = nil
|
||||
@frontend_styles = nil
|
||||
@selected={
|
||||
:design => @designs.first,
|
||||
:theme=> @themes.first,
|
||||
:module_app=>nil,#@module_apps.first
|
||||
:app_frontend_url=> nil, #@module_apps.first
|
||||
:category=>nil,
|
||||
:tag=>nil,
|
||||
:page_frontend_data_count=>nil,
|
||||
:frontend_style => nil
|
||||
}
|
||||
end
|
||||
|
||||
def edit
|
||||
@item = Page.find(params[:id])
|
||||
@user_choose = @item.app_frontend_url
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
|
||||
|
||||
@designs = Design.all.entries
|
||||
@design = @item.design ? @item.design : @designs.first
|
||||
@themes = @item.design ? @item.design.themes : @designs.first.themes
|
||||
@module_apps = ModuleApp.for_frontend_select
|
||||
@categories = nil
|
||||
@tags = nil
|
||||
@page_frontend_data_counts = nil
|
||||
@frontend_styles = nil
|
||||
|
||||
if @item.module_app
|
||||
@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?
|
||||
@selected={
|
||||
:design => @item.design || @designs.first,
|
||||
:theme=> @item.theme,
|
||||
:module_app=>@item.module_app,#@module_apps.first
|
||||
:app_frontend_url=> @item.app_frontend_url, #@module_apps.first
|
||||
:category=>nil, #fetch by method: get_categories_and_tags
|
||||
:tag=>nil, #fetch by method: get_categories_and_tags
|
||||
:page_frontend_data_count=>nil,
|
||||
:frontend_style => nil
|
||||
}
|
||||
@app_frontend_urls = @item.module_app ? select_array_for_app_frontend_urls(@item.module_app.app_pages) : nil
|
||||
get_categories_and_tags
|
||||
get_frontend_data_count
|
||||
end
|
||||
|
||||
@module_app = @item.module_app
|
||||
@frontend_path = @item.app_frontend_url
|
||||
|
||||
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?
|
||||
end
|
||||
get_categories_and_tags
|
||||
|
||||
else
|
||||
@module_app = @module_apps[0]
|
||||
def reload_themes
|
||||
design = Design.find(params[:design_id])
|
||||
@themes = design.themes
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_frontend_pages
|
||||
@item = Page.find(params[:id]) rescue Page.new
|
||||
@selected={
|
||||
:design => nil,
|
||||
:theme=> nil,
|
||||
:module_app=>(ModuleApp.find(params[:module_app_id]) rescue nil),
|
||||
:app_frontend_url=> @item.app_frontend_url || 'default_widget', #@module_apps.first
|
||||
:category=>nil, #fetch by method: get_categories_and_tags
|
||||
:tag=>nil, #fetch by method: get_categories_and_tags
|
||||
:page_frontend_data_count=>nil,
|
||||
:frontend_style => nil
|
||||
}
|
||||
@app_frontend_urls = @selected[:module_app] ? select_array_for_app_frontend_urls(@selected[:module_app].app_pages) : nil
|
||||
|
||||
get_categories_and_tags
|
||||
get_frontend_data_count
|
||||
get_frontend_styles
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def reload_front_end_setting
|
||||
@item = Page.find(params[:id]) rescue Page.new
|
||||
|
||||
@categories = nil
|
||||
@tags = nil
|
||||
@page_frontend_data_counts = nil
|
||||
|
||||
@selected={
|
||||
# :design => @item.design || @designs.first,
|
||||
# :theme=> @item.theme,
|
||||
:module_app=>ModuleApp.find(params[:module_app_id]),
|
||||
:app_frontend_url=> params[:frontend] ,
|
||||
:category=>nil, #fetch by method: get_categories_and_tags
|
||||
:tag=>nil, #fetch by method: get_categories_and_tags
|
||||
:page_frontend_data_count=>nil,
|
||||
:frontend_style => nil
|
||||
}
|
||||
@app_frontend_urls = @selected[:module_app].nil? ? nil : @selected[:module_app].app_pages.each{|name,data| [I18n.t(data["i18n"]),name]}
|
||||
@frontend_styles = @selected[:module_app].app_pages[params["frontend"]]["style"] rescue nil
|
||||
|
||||
end
|
||||
|
||||
|
||||
def reload_widget_field
|
||||
@index = params[:field_seri].to_i
|
||||
@item = Page.find(params[:id]) rescue Page.new
|
||||
@selected = {
|
||||
:module_app=> (@item.module_app || ModuleApp.find(params[:module_app_id]) ),
|
||||
:default_widget_field=>params[:widget_field_value]
|
||||
}
|
||||
# @choosen_field = params[:widget_field_value]
|
||||
# @module_app = @item.module_app
|
||||
# @module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
|
||||
end
|
||||
|
||||
def create
|
||||
clean_tags_and_category_params
|
||||
@item = Page.new(params[:page])
|
||||
|
||||
if @item.module_app && @item.module_app.key == 'page_content'
|
||||
@@ -63,7 +147,6 @@ helper Admin::PagePartsHelper
|
||||
end
|
||||
else
|
||||
flash.now[:error] = t('create.error.page')
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
render :action => "new"
|
||||
@@ -71,27 +154,12 @@ helper Admin::PagePartsHelper
|
||||
end
|
||||
|
||||
def update
|
||||
clean_tags_and_category_params
|
||||
@item = Page.find(params[:id])
|
||||
|
||||
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
|
||||
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
||||
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_type] = nil
|
||||
# params[:page][:frontend_field_is_link] = nil
|
||||
|
||||
if params[:page][:tag].nil? || params[:page][:tag].include?("nil")
|
||||
params[:page][:tag] = []
|
||||
end
|
||||
|
||||
if params[:page][:category].nil? || params[:page][:category].include?("nil")
|
||||
params[:page][:category] = []
|
||||
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])
|
||||
flash[:notice] = t('update.success.page')
|
||||
@@ -126,65 +194,10 @@ helper Admin::PagePartsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def reload_front_end_setting
|
||||
@item = Page.find params[:id] rescue nil
|
||||
@module_app = ModuleApp.find params[:module_app_id]
|
||||
@user_choose = params[:frontend] #choosen frontend
|
||||
protected
|
||||
|
||||
@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
|
||||
# =======
|
||||
# @chosen_frontend = @user_choose = params[:frontend]
|
||||
# >>>>>>> Stashed changes
|
||||
end
|
||||
|
||||
def get_categories_and_tags
|
||||
unless @module_app.nil?
|
||||
@categories = @module_app.get_categories
|
||||
@tags = @module_app.get_tags
|
||||
end
|
||||
def get_frontend_styles
|
||||
has_old_value = @selected[:module_app].app_pages[@selected[:app_frontend_url]]
|
||||
@frontend_styles = has_old_value ? has_old_value["style"] : (@selected[:module_app].app_pages.first[1]["style"] rescue nil)
|
||||
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]}
|
||||
@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
|
||||
else
|
||||
@module_app.app_pages.each{|name,data| @app_frontend_urls << [I18n.t(data["i18n"]),name]}
|
||||
@frontend_styles = @module_app.app_pages[params["frontend"]]["style"] rescue nil
|
||||
@frontend_styles = @module_app.app_pages.first[1]["style"] if @frontend_styles.nil?
|
||||
end
|
||||
end
|
||||
|
||||
def reload_frontend_pages
|
||||
@item = Page.find params[:id] rescue nil
|
||||
@module_app = ModuleApp.find(params[:module_app_id]) rescue nil
|
||||
@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?)
|
||||
|
||||
get_categories_and_tags
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_themes
|
||||
@design = Design.find(params[:id])
|
||||
@themes = @design.themes
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_widget_field
|
||||
@index = params[:field_seri].to_i
|
||||
@item = params.has_key?(:id) ? Page.find(params[:id] ) : Page.new
|
||||
@choosen_field = params[:widget_field_value]
|
||||
@module_app = @page.module_app
|
||||
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
|
||||
end
|
||||
|
||||
end
|
||||
@@ -48,11 +48,18 @@ class DefaultWidgetController< OrbitWidgetController
|
||||
@widget_image_field = @default_widget["image"] || @default_widget[:image]
|
||||
case @page_part
|
||||
when Page
|
||||
@fields = @page_part.frontend_field
|
||||
@frontend_field_names = @page_part.frontend_field_name
|
||||
@frontend_classes = @page_part.frontend_class
|
||||
@frontend_sat_to_links = @page_part.frontend_sat_to_link
|
||||
|
||||
@data_limit = @page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3)
|
||||
@paginate = true
|
||||
@page_id = @page_part.id
|
||||
when PagePart
|
||||
@frontend_field_names = @page_part.widget_field_name
|
||||
@frontend_classes = @page_part.widget_class
|
||||
@frontend_sat_to_links = @page_part.widget_sat_to_link
|
||||
|
||||
@fields = @page_part.widget_field
|
||||
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user