Class: Releaf::Content::NodesController
- Inherits:
-
BaseController
- Object
- BaseController
- Releaf::Content::NodesController
- Defined in:
- app/controllers/releaf/content/nodes_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#add_resource_breadcrumb(resource) ⇒ Object
override base_controller method for adding content tree ancestors to breadcrumbs.
- #builder_scopes ⇒ Object
- #content_type_dialog ⇒ Object
- #copy ⇒ Object
- #copy_dialog ⇒ Object
- #generate_url ⇒ Object
- #go_to_dialog ⇒ Object
- #move ⇒ Object
- #move_dialog ⇒ Object
- #node_builder_scope ⇒ Object
- #setup ⇒ Object
Class Method Details
.resource_class ⇒ Object
84 85 86 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 84 def self.resource_class ::Node end |
Instance Method Details
#add_resource_breadcrumb(resource) ⇒ Object
override base_controller method for adding content tree ancestors to breadcrumbs
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 66 def (resource) ancestors = [] if resource.new_record? if resource.parent_id ancestors = resource.parent.ancestors ancestors += [resource.parent] end else ancestors = resource.ancestors end ancestors.each do |ancestor| @breadcrumbs << { name: ancestor, url: url_for( action: :edit, id: ancestor.id ) } end super end |
#builder_scopes ⇒ Object
26 27 28 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 26 def builder_scopes [node_builder_scope] + super end |
#content_type_dialog ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 20 def content_type_dialog @content_types = resource_class.valid_node_content_classes(params[:parent_id]).sort do |a, b| I18n.t(a.name.underscore, scope: 'admin.content_types') <=> I18n.t(b.name.underscore, scope: 'admin.content_types') end end |
#copy ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 42 def copy copy_move_common do |resource| resource.copy params[:new_parent_id] end end |
#copy_dialog ⇒ Object
34 35 36 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 34 def copy_dialog copy_move_dialog_common end |
#generate_url ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 10 def generate_url tmp_resource = prepare_resource tmp_resource.name = params[:name] tmp_resource.reasign_slug respond_to do |format| format.js { render text: tmp_resource.slug } end end |
#go_to_dialog ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 54 def go_to_dialog @collection = resource_class.roots respond_to do |format| format.html do render layout: nil end end end |
#move ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 48 def move copy_move_common do |resource| resource.move params[:new_parent_id] end end |
#move_dialog ⇒ Object
38 39 40 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 38 def move_dialog copy_move_dialog_common end |
#node_builder_scope ⇒ Object
30 31 32 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 30 def node_builder_scope [application_scope, "Nodes"].reject(&:blank?).join("::") end |
#setup ⇒ Object
5 6 7 8 |
# File 'app/controllers/releaf/content/nodes_controller.rb', line 5 def setup super @features[:create_another] = false end |