Class: PageComponent

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Translator
Defined in:
app/models/page_component.rb

Overview

This is a Device-User-Class extended with ROLES, Avatar-handling, and more

Instance Method Summary (collapse)

Methods included from Translator

included

Instance Method Details

- (Object) __original__delete

Ask our page if removing of components is allowed



45
# File 'app/models/page_component.rb', line 45

alias_method :__original__delete, :delete

- (Object) delete(options = {})



46
47
48
49
50
51
52
53
# File 'app/models/page_component.rb', line 46

def delete(options={})
  if self.page.is_template || self.page.allow_removing_component == true
    __original__delete(options)
  else
    self.errors.add('base', "Removing components is not allowed")
    false
  end
end

- (Object) page_template



20
21
22
# File 'app/models/page_component.rb', line 20

def page_template
  PageTemplate.criteria.for_ids(self.page_template_id).first || page.page_template
end

- (Object) page_template=(new_template)



23
24
25
# File 'app/models/page_component.rb', line 23

def page_template=(new_template)
  self.page_template_id = new_template.id if new_template
end

- (Object) render_body(view_context = nil, &block)

TODO: Remove duplication! TODO: This code occurs in Page and PageComponent. Move it to a single TODO: place.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/page_component.rb', line 30

def render_body(view_context=nil,&block)
  @view_context = view_context
  rc = "\n<div class='page-component' id='page-component-#{self.id.to_s}'>\n"
  if self.page_template
    rc += self.page_template.render do |template|
      insert_placeholders_content(template, view_context,&block)
    end
  else
    rc += insert_placeholders_content("TITLE BODY BUTTONS COMPONENTS ATTACHMENTS COMMENTS", view_context,&block)
  end
  rc += "\n</div>\n"
end