diff options
| author | hukl <contact@smyck.org> | 2009-10-19 23:57:25 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-10-19 23:57:25 +0200 |
| commit | 53d5b59744f43a94756190631a46fd58779b5fb9 (patch) | |
| tree | b28431e1348b4890b459be05cecb6613f3891319 /app | |
| parent | cb914e420c3f95b5f8e31a73ea19b7e53e4aa6c4 (diff) | |
changes for giving root a title
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/admin_controller.rb | 6 | ||||
| -rw-r--r-- | app/models/node.rb | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 0446387..57f0d77 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb | |||
| @@ -35,7 +35,11 @@ class AdminController < ApplicationController | |||
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | def menu_search | 37 | def menu_search |
| 38 | @results = Node.search params[:search_term] | 38 | if params[:search_term] == "Root" |
| 39 | @results = [Node.root] | ||
| 40 | else | ||
| 41 | @results = Node.search params[:search_term] | ||
| 42 | end | ||
| 39 | 43 | ||
| 40 | respond_to do |format| | 44 | respond_to do |format| |
| 41 | format.html do | 45 | format.html do |
diff --git a/app/models/node.rb b/app/models/node.rb index 88a4d68..db484f9 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -155,6 +155,10 @@ class Node < ActiveRecord::Base | |||
| 155 | head ? head.title : draft.title | 155 | head ? head.title : draft.title |
| 156 | end | 156 | end |
| 157 | 157 | ||
| 158 | def update_unique_names? | ||
| 159 | !children.empty? && !children.first.path_to_root.include?(self.slug) | ||
| 160 | end | ||
| 161 | |||
| 158 | protected | 162 | protected |
| 159 | def lock_for! current_user | 163 | def lock_for! current_user |
| 160 | self.lock_owner = current_user | 164 | self.lock_owner = current_user |
| @@ -182,8 +186,10 @@ class Node < ActiveRecord::Base | |||
| 182 | # after_save callback which invokes update_unique_name on its children. | 186 | # after_save callback which invokes update_unique_name on its children. |
| 183 | # Hopefully until no childrens occur | 187 | # Hopefully until no childrens occur |
| 184 | def update_unique_names_of_children | 188 | def update_unique_names_of_children |
| 185 | self.descendants.each do |descendant| | 189 | unless root? |
| 186 | descendant.update_unique_name | 190 | self.descendants.each do |descendant| |
| 191 | descendant.update_unique_name | ||
| 192 | end | ||
| 187 | end | 193 | end |
| 188 | end | 194 | end |
| 189 | 195 | ||
