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/page_part.rb

41 lines
823 B
Ruby

class PagePart
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :content, localize: true
field :kind
field :public_r_tag
field :public_r_tag_object_id, :default => nil
field :public_r_tag_option, :default => nil
field :page_title, localize: true
field :widget_path
field :widget_style
field :widget_field , :type => Array
field :widget_options ,:type=>Hash
field :widget_data_count
belongs_to :page
belongs_to :module_app
before_save :delete_empty_widget_field
after_save :update_parent
protected
def delete_empty_widget_field
if self.widget_field
self.widget_field.reject! { |wf| (wf[0].blank? || wf[1].blank?) }
end
# self.widget_field.delete("") if self.widget_field
end
def update_parent
self.page.save
end
end