This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/models/module_app.rb

131 lines
3.0 KiB
Ruby
Raw Normal View History

2011-11-19 06:33:26 +00:00
class ModuleApp
include Mongoid::Document
include Mongoid::Timestamps
2012-12-03 10:52:36 +00:00
include OrbitCoreLib::ObjectTokenUtility
include OrbitApp::ModuleAppMembershipTools
field :key
field :title
field :sidebar_order#,type: Integer
def refetch_setting!(reg)
# %w{module_label category base_url version organization author intro update_info create_date}.each do |field|
# self[field.to_sym] = reg.send field
# end
self[:app_pages] = reg.get_app_pages
self[:enable_frontend] = reg.get_enable_frontend
self[:get_widget_style] = reg.get_widgets
self[:using_default_widget] = !reg.get_default_widget.blank?
self[:widgets] = reg.get_widgets
end
# def app_pages
# get_registration.get_app_pages
# end
2012-12-03 10:52:36 +00:00
def enable_frontend?
self[:enable_frontend]
end
def get_default_widget
raise 'Need to link with OrbitApp [type: Array]'
end
2012-12-03 10:52:36 +00:00
def get_widget_for_select
widgets = get_widget_style
2012-12-03 10:52:36 +00:00
ary = widgets.collect do |k,v|
if k == 'default_widget'
[I18n.t('widget.default_widget'),'default_widget']
else
[I18n.t(v[:label]),k]
end
end
end
# def get_widget_style
# get_registration.get_widgets
# end
def has_default_widget?
self[:widgets].has_key? 'default_widget'
end
def label
I18n.t(label_i18n)
end
def label_i18n
reg = get_registration
reg.nil? ? 'Init is not defined completely' : get_registration.get_label_i18n
end
# def needs_to_widget_option?
# if self.widget_options
# self.widget_options.has_key? widgets.first
# else
# false
# end
# end
def using_default_widget?
# !get_registration.get_default_widget.blank?
self[:get_default_widget]
end
def widget_fields
# binding.pry
# raise 'Need to link with OrbitApp [type: Array]'
get_registration.get_default_widget_fields
2012-01-13 10:20:04 +00:00
end
# def widgets
# # get_registration.get_widgets
# # get_registration.get_default_widget
# end
def widget_options(widget_path=nil)
get_registration.get_widget_by_path(widget_path)
# raise 'Need to link with OrbitApp [type: Hash]'
2012-01-13 10:20:04 +00:00
end
def widget_options_fields_i18n
raise 'Need to link with OrbitApp [type: Hash]'
2012-01-13 10:20:04 +00:00
end
def widget_fields_link_method
raise 'Need to link with OrbitApp [type: Hash]'
2012-01-13 10:20:04 +00:00
end
has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app
has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
# # has_many :tags
has_many :page_parts
has_many :pages
has_one :app_auth,dependent: :delete
def get_tags
get_registration.get_tags
end
def get_categories
get_registration.get_categories
2012-12-28 07:30:46 +00:00
end
def module_name
I18n.t(get_registration.get_label_i18n)
2013-01-14 10:49:23 +00:00
end
def get_registration
OrbitApp::Module::Registration.find_by_key(key)
end
2011-12-23 10:34:21 +00:00
end