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/desktop/desktop_widget.rb

37 lines
1.1 KiB
Ruby
Raw Normal View History

2012-11-01 12:42:40 +00:00
class DesktopWidget
include Mongoid::Document
include Mongoid::Timestamps
include ParserLayoutWidget
field :name
field :author
field :shape, default: "w1 h1"
field :fullsize, :type => Boolean, default: false
2012-11-01 12:42:40 +00:00
field :version, :type => String
2013-05-13 09:13:44 +00:00
field :text_color, :type => String, default: ""
field :bg_color, :type => String, default: ""
field :icon, default: "icon.png"
2012-11-01 12:42:40 +00:00
2012-11-05 15:04:54 +00:00
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
2012-11-01 12:42:40 +00:00
has_one :widget_layout, :autosave => true, :dependent => :destroy
2012-11-05 15:04:54 +00:00
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_and_belongs_to_many :desktops, :autosave => true
has_many :tiles, :autosave => true
2012-11-01 12:42:40 +00:00
accepts_nested_attributes_for :images, :allow_destroy => true
2012-11-05 15:04:54 +00:00
accepts_nested_attributes_for :javascripts, :allow_destroy => true
2012-11-01 12:42:40 +00:00
after_save :parse_css_for_images
# belongs_to :desktop
protected
def parse_css_for_images
2012-11-05 15:04:54 +00:00
self.css_default.parse_urls
2012-11-01 12:42:40 +00:00
parse_widget_for_images(self)
end
end