diff --git a/app/assets/javascripts/page_edit.js.erb b/app/assets/javascripts/page_edit.js.erb index 3ab9c18c..f2b8722f 100644 --- a/app/assets/javascripts/page_edit.js.erb +++ b/app/assets/javascripts/page_edit.js.erb @@ -1,5 +1,10 @@ -function get_part_id(){ - return $(".edit_page_part,.edit_page").attr("action").split('/').pop(); +function append_id(){ + if ($("#object_id").length == 1) { + return "&id="+$("#object_id").val(); + } + else{ + return ''; + }; } $("div.editable").live("mouseenter mouseleave", function (event) { @@ -7,37 +12,24 @@ $("div.editable").live("mouseenter mouseleave", function (event) { }); $("#page_design").live('change', function() { - $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); + $.getScript($(this).attr('rel') + '?design_id=' + $(this).val() + append_id()); }); -// $("#page_module_app_id").live('change', function() { -// var app_id = $(this).val(); -// if(app_id!=''){ -// $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_after_module_changed',function(data, textStatus){ -// if(textStatus == 'success'){ -// $(this).after(data); -// } -// }); -// } -// else{ -// $("#app_page_url").children().remove(); -// } -// }); $("#module_app_list select").live('change', function() { - $.getScript($(this).attr('rel') + '?module_app_id='+$(this).val()); //?part_id=' + get_part_id()); + $.getScript($(this).attr('rel') + '?module_app_id='+$(this).val() + append_id()); }); $("#widget_list select,#frontend_list select").live('change', function() { - $.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() );//+ '&part_id=' + get_part_id()); + $.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() + append_id() ); }); $("#tag_list select").live('change', function() { - $.getScript($(this).attr('rel') + '?type=' + $(this).val()); + $.getScript($(this).attr('rel') + '?type=' + $(this).val() + append_id() ); }); $("select.widget_field_select").live('change', function() { - $.getScript($(this).attr('rel') + '?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val()); + $.getScript($(this).attr('rel') + '?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val() + append_id() ); }); $('.part_kind').live('click', function() { diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index ed1374cc..d4f439c9 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -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| diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 7d6de997..424a3ae4 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -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 diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index a9aec4b8..c8b4eddd 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -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 diff --git a/app/helpers/admin/frontend_widget_interface.rb b/app/helpers/admin/frontend_widget_interface.rb new file mode 100644 index 00000000..66061ae8 --- /dev/null +++ b/app/helpers/admin/frontend_widget_interface.rb @@ -0,0 +1,59 @@ +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 \ No newline at end of file diff --git a/app/helpers/admin/page_parts_helper.rb b/app/helpers/admin/page_parts_helper.rb index afe26f80..4d78ef4c 100644 --- a/app/helpers/admin/page_parts_helper.rb +++ b/app/helpers/admin/page_parts_helper.rb @@ -1,7 +1,8 @@ module Admin::PagePartsHelper + include Admin::FrontendWidgetInterface def support_link - url_method = @module_app.get_default_widget[:url_method] + url_method = @selected[: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]])) @@ -9,10 +10,8 @@ module Admin::PagePartsHelper end end - def get_widget_field_rel(local_item=nil) - local_item = @part if local_item.nil? && @part - local_item = @item if local_item.nil? && @item - case local_item + def get_widget_field_rel + case set_local_item when Page reload_after_list_changed_admin_pages_path when PagePart @@ -35,7 +34,7 @@ module Admin::PagePartsHelper 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 + origin_field = @selected[:module_app].widget_fields.select{|t| t.first.to_s==(assign_field_name_value || local_item.default_widget_field_name[i])}.first if origin_field and origin_field[2]==:link #choosen_field_is_link @@ -51,11 +50,10 @@ module Admin::PagePartsHelper end def widget_field_options(i,local_item=nil) - local_item = @part if local_item.nil? && @part - local_item = @item if local_item.nil? && @item + local_item = set_local_item - options = @module_app.widget_fields.collect do |widget_field| - label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}") + options = @selected[:module_app].widget_fields.collect do |widget_field| + label = I18n.t("#{@selected[:module_app].key}.default_widget.#{widget_field[0]}") [label, widget_field[0]] end case local_item @@ -66,11 +64,9 @@ module Admin::PagePartsHelper end end - def widget_fiield_class_options(i,local_item=nil) + def widget_field_class_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? && @part - local_item = @item if local_item.nil? && @item - + local_item = set_local_item case local_item when Page options_for_select(options, (local_item.frontend_class[i] if (local_item) )) @@ -115,12 +111,8 @@ module Admin::PagePartsHelper end def nil_checkbox_button(part,tag_or_cate) - field_name = case part - when PagePart - 'page_part' - when Page - 'page' - end + field_name = set_field_name + 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") @@ -128,12 +120,8 @@ module Admin::PagePartsHelper end def nil_radio_button(part,tag_or_cate) - field_name = case part - when PagePart - 'page_part' - when Page - 'page' - end + field_name = set_field_name + content_tag :label,:class=>"radio inline" do op = radio_button(field_name, tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')")) op << I18n.t("default_widget.no_value") @@ -141,7 +129,7 @@ module Admin::PagePartsHelper end def show_default_widget_setting_panel - @module_app && @module_app.has_default_widget? && (!@user_choose.nil? && @user_choose== 'default_widget') #&& @part.widget_path == 'default_widget' + @selected[:module_app] && @selected[:module_app].has_default_widget? && (@selected[:app_frontend_url]== 'default_widget') end def show_custom_widget_setting_panel diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 5aa5a11d..d185b50c 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -19,11 +19,10 @@ class ModuleApp self[:widgets] = reg.get_widgets end - - # def app_pages - # get_registration.get_app_pages - # end + scope :for_frontend_select,where(:key.in => OrbitApp::Module::FrontendUtility.all.keys).excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc) + scope :for_widget_select,where(:key.in=>OrbitApp::Module::WidgetUtility.all.keys).order_by(:title, :asc) + scope :standard_sorting ,order_by(:title, :asc) def enable_frontend? self[:enable_frontend] diff --git a/app/models/page.rb b/app/models/page.rb index 91a76de8..b2947ca8 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -7,7 +7,7 @@ class Page < Item field :content, localize: true field :app_frontend_url - field :theme_id, :type => BSON::ObjectId, :default => nil + # field :theme_id, :type => BSON::ObjectId, :default => nil field :category,type: Array, :default => [] field :tag, type: Array,:default => [] field :view_count, :type => Integer, :default => 0 @@ -21,7 +21,8 @@ class Page < Item field :frontend_sat_to_link , :type => Array,:default => [] field :frontend_data_count - + + belongs_to :theme belongs_to :design belongs_to :module_app has_many :page_parts, :dependent => :destroy diff --git a/app/views/admin/module_apps/_app_selector.html.erb b/app/views/admin/module_apps/_app_selector.html.erb index 60cf2d6f..7ce95e05 100644 --- a/app/views/admin/module_apps/_app_selector.html.erb +++ b/app/views/admin/module_apps/_app_selector.html.erb @@ -1 +1 @@ -<%= f.select :module_app_id, @apps.collect { |t| [t.module_name, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> +<%= f.select :module_app_id, @module_apps.collect { |t| [t.module_name, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> diff --git a/app/views/admin/page_parts/_custom_widget_setting.html.erb b/app/views/admin/page_parts/_custom_widget_setting.html.erb index 998b5853..7a3838e6 100644 --- a/app/views/admin/page_parts/_custom_widget_setting.html.erb +++ b/app/views/admin/page_parts/_custom_widget_setting.html.erb @@ -3,14 +3,14 @@ <%= t("default_widget.select_widget_style") %>
<%= content_tag(:span,get_field_header(field[0]),:class=>field[1])%> | + <% @frontend_field_names.each_with_index do |field,index|%> + <%= content_tag(:th,content_tag(:span,get_field_header(field),:class=>@frontend_classes[index]))unless field.blank?%> <% end %>
---|
<%= content_tag(:span,link_to_field(row_data,field[0], field[2], {orig_page: @page_id.to_s}),:class=>field[1])%> | + <% @frontend_field_names.each_with_index do |field,index|%> + <%= content_tag(:td,content_tag(:span,link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]))unless field.blank?%> <% end %>