update ModuleApp and OrbitWidget registration

This commit is contained in:
manson 2014-08-05 18:22:36 +08:00
parent 43e1a669d6
commit 14bfbe2d8a
4 changed files with 17 additions and 6 deletions

View File

@ -43,8 +43,8 @@ class PagePartsController < ApplicationController
app = OrbitWidget.find_by_key(module_name) if app.nil?
@categories = app.categories rescue []
@tags = app.tags rescue []
@widget_methods = app.get_registration.get_widget_methods
@widget_settings = app.get_registration.get_widget_settings
@widget_methods = app.widget_methods
@widget_settings = app.widget_settings
@data_count = nil
if !@widget_settings.blank?
@data_count = @widget_settings["data_count"] rescue nil
@ -102,8 +102,8 @@ class PagePartsController < ApplicationController
app = OrbitWidget.find_by_key(module_name) if app.nil?
@categories = app.categories rescue []
@tags = app.tags rescue []
@widget_methods = app.get_registration.get_widget_methods
@widget_settings = app.get_registration.get_widget_settings
@widget_methods = app.widget_methods
@widget_settings = app.widget_settings
@data_count = nil
if !@widget_settings.blank?
@data_count = @widget_settings["data_count"] rescue nil

View File

@ -11,6 +11,8 @@ class ModuleApp
field :sidebar_order,type: Integer,default: 0
field :authorizable_models, type: Array
field :widget_enable, type: Boolean, default: false
field :widget_methods
field :widget_settings
has_many :categories, dependent: :destroy, :autosave => true
has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true
@ -26,6 +28,8 @@ class ModuleApp
self[:authorizable_models] = reg.get_authorizable_models
self[:frontend_enable] = reg.is_frontend_enabled
self[:widget_enable] = reg.is_widget_enabled
self[:widget_methods] = reg.get_widget_methods
self[:widget_settings] = reg.get_widget_settings
end
def get_registration

View File

@ -4,10 +4,17 @@ class OrbitWidget
field :title, type: String
field :key, type: String
field :widget_methods
field :widget_settings
def refetch_setting!(reg)
self[:widget_methods] = reg.get_widget_methods
self[:widget_settings] = reg.get_widget_settings
end
def get_registration
OrbitApp::Widget::Registration.find_by_key(key)
end
end
def self.find_by_key(key)
self.find_by(:key => key)

View File

@ -51,7 +51,7 @@ module OrbitApp
def setup_module_app
orbit_widget = get_orbit_widget
orbit_widget = OrbitWidget.new(:key=>@key,:title=>name) if orbit_widget.nil?
# orbit_widget.refetch_setting!(self)
orbit_widget.refetch_setting!(self)
orbit_widget.save(:validate=>false)
end