diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb
index b7a03690..a78f72f5 100644
--- a/app/controllers/admin/page_parts_controller.rb
+++ b/app/controllers/admin/page_parts_controller.rb
@@ -24,7 +24,7 @@ class Admin::PagePartsController < OrbitBackendController
def edit
@part = PagePart.find(params[:id])
- @module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
+ @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
diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb
index b66a9727..79831849 100644
--- a/app/controllers/admin/pages_controller.rb
+++ b/app/controllers/admin/pages_controller.rb
@@ -13,7 +13,7 @@ helper Admin::PagePartsHelper
def new
@item = Page.new
@item.parent = Item.find(params[:parent_id]) rescue nil
- @apps = ModuleApp.excludes(app_pages: nil).entries
+ @apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
@designs = Design.all.entries
@design = Design.first
end
@@ -21,7 +21,7 @@ helper Admin::PagePartsHelper
def edit
@item = Page.find(params[:id])
@user_choose = @item.app_frontend_url
- @apps = ModuleApp.excludes(app_pages: nil).entries
+ @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
@@ -62,7 +62,7 @@ helper Admin::PagePartsHelper
end
else
flash.now[:error] = t('create.error.page')
- @apps = ModuleApp.all
+ @apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
@designs = Design.all.entries
@design = Design.first
render :action => "new"
diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb
index d3308bc6..e3eb4244 100644
--- a/app/views/admin/pages/_form.html.erb
+++ b/app/views/admin/pages/_form.html.erb
@@ -42,7 +42,7 @@
<%= f.label '',t("default_widget.select_module_app"), :class => 'control-label' %>
- <%= render :partial => "app_selector", :locals => { :f => f } %>
+ <%= render :partial => "app_selector", :locals => { :f => f } %>
diff --git a/lib/orbit_app/module/front_end.rb b/lib/orbit_app/module/front_end.rb
index 5547404c..67db3231 100644
--- a/lib/orbit_app/module/front_end.rb
+++ b/lib/orbit_app/module/front_end.rb
@@ -1,20 +1,27 @@
module OrbitApp
module Module
module FrontendUtility
- Version = "0.1"
+ Version = "0.2"
module ClassMethods
- @@frontend_pages = []
+ @@frontend_pages = {}
#Record all frontend pages of orbit
- def add(var) #build @@frontend_pages
- @@frontend_pages << var
+ def add(key,var) #build @@frontend_pages
+ if @@frontend_pages[key].nil?
+ @@frontend_pages[key]= {"frontend"=>var}
+ else
+ @@frontend_pages[key]["frontend"]= var
+ end
+ end
+
+ def add_default_widget(key,var)
+ @@frontend_pages[key]["default_widget"]= var
end
def all #return all frontend_pages of orbit
return @@frontend_pages
end
-
end
extend ClassMethods
@@ -23,9 +30,10 @@ module OrbitApp
end
class AppPageSet # From Registration
- def initialize(&block)
+ def initialize(name,key,&block)
@frontend_pages = []
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
+ OrbitApp::Module::FrontendUtility.add(key,@frontend_pages)
end
def app_page(name,&block)
diff --git a/lib/orbit_app/module/registration.rb b/lib/orbit_app/module/registration.rb
index 5dbc3605..0b767c5a 100644
--- a/lib/orbit_app/module/registration.rb
+++ b/lib/orbit_app/module/registration.rb
@@ -1,7 +1,7 @@
module OrbitApp
module Module
module Registration
- Version = "0.1"
+ Version = "0.2"
module ClassMethods
@@registrations = []
@@ -120,7 +120,7 @@ module OrbitApp
end
def front_end(&block) #setter for front_end from init
- @front_end_app_pages = FrontendUtility::AppPageSet.new(&block)
+ @front_end_app_pages = FrontendUtility::AppPageSet.new(@name,@key,&block)
end
def side_bar(&block) #setter for side_bar from init
@@ -129,12 +129,12 @@ module OrbitApp
def personal_plugin(params) #setter for personal_plugin from init
# TODO 這裡要看是一些檔案是不是都有
- Plugin::Registration.new_from_module_app(@name,@base_path,params)
+ Plugin::Registration.new_from_module_app(@name,@key,@base_path,params)
end
def widgets(&block) #setter for widget from init
# @widgets = WidgetRegisition::WidgetSet.new(&block)
- @widget_set = WidgetUtility::WidgetSet.new(&block)
+ @widget_set = WidgetUtility::WidgetSet.new(@name,@key,&block)
# @widgets = widget_set.widgets
# @default_widget = widget_set.default_widget
diff --git a/lib/orbit_app/module/side_bar.rb b/lib/orbit_app/module/side_bar.rb
index 79019bf0..8e7a7c26 100644
--- a/lib/orbit_app/module/side_bar.rb
+++ b/lib/orbit_app/module/side_bar.rb
@@ -1,7 +1,7 @@
module OrbitApp
module Module
module SideBarRegisition
- Version = "0.1"
+ Version = "0.2"
module ClassMethods
@@side_bars = []
diff --git a/lib/orbit_app/module/widget.rb b/lib/orbit_app/module/widget.rb
index c932a7f7..9976c9ff 100644
--- a/lib/orbit_app/module/widget.rb
+++ b/lib/orbit_app/module/widget.rb
@@ -1,13 +1,14 @@
module OrbitApp
module Module
module WidgetUtility
- Version = "0.1"
+ Version = "0.2"
module ClassMethods
- @@widgets = []
+ @@widgets = {}
- def add(var)
- @@widgets << var
+ def add(name,default_widget,customize_widget)
+ @@widgets[name] = {:default_widget=>default_widget,:customize_widget=>customize_widget}
+ Hash[@@widgets.sort]
end
def all
@@ -22,12 +23,13 @@ module OrbitApp
class WidgetSet
attr_reader :widgets,:categories_query,:tags_query
- def initialize(&block)
+ def initialize(name,key,&block)
@widgets = []
@default_widget = nil
@categories_query = ''
@tags_query = ''
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
+ OrbitApp::Module::WidgetUtility.add(key,@default_widget,@widgets)
end
%w{categories_query tags_query}.each do |field|
@@ -58,6 +60,7 @@ module OrbitApp
def default_widget(&block)
@default_widget = DefaultWidget.new(&block)
+ # OrbitApp::Module::FrontendUtility.add()
end
def customize_widget(name,&block)
@@ -72,7 +75,7 @@ module OrbitApp
# @customize_widget_options_fields_i18n = settings
# end
- def to_module_app_format
+ def to_module_app_format
hash = {}
@widgets.collect{|t| hash[t.name] = t.to_hash}
hash["default_widget"]= DefaultWidget.get_interface_args unless @default_widget.blank?
@@ -115,7 +118,6 @@ module OrbitApp
end
def self.get_interface_args
- #will need to work with design
{:name=>"default_widget",:field=>@fields,:style=>@enabled_styles,:i18n=>'default_widget.default_widget'}
end
diff --git a/lib/orbit_app/plugin/registration.rb b/lib/orbit_app/plugin/registration.rb
index 126faf34..2c3f52f8 100644
--- a/lib/orbit_app/plugin/registration.rb
+++ b/lib/orbit_app/plugin/registration.rb
@@ -1,7 +1,7 @@
module OrbitApp
module Plugin
module Registration
- Version = "0.1"
+ Version = "0.2"
module ClassMethods
@@registrations = []
@@ -10,7 +10,7 @@ module OrbitApp
@@registrations << DataSheet.new(name,&block)
end
- def new_from_module_app(name,base_path,*args)
+ def new_from_module_app(name,key,base_path,*args)
@@registrations << DataSheet.new(name,args,:base_path=>base_path)
end
diff --git a/lib/orbit_app/summary.rb b/lib/orbit_app/summary.rb
index d936aa87..6de44e52 100644
--- a/lib/orbit_app/summary.rb
+++ b/lib/orbit_app/summary.rb
@@ -1,6 +1,6 @@
module OrbitApp
module Summary
- Version = "0.1"
+ Version = "0.2"
module ClassMethods
@@summaries = []