summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-08-08 22:38:48 +0200
committerhukl <contact@smyck.org>2009-08-08 22:38:48 +0200
commit46117a9f103e2d547be2a47724e872b3f57ce983 (patch)
tree3360a066676ecf776f62212912abcec4965bdf27 /app
parent4f249507da36f219b208f88e4dea5a5cd90ca254 (diff)
lots of new code to manage menu items - harder than expected :/
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_controller.rb19
-rw-r--r--app/controllers/menu_items_controller.rb11
-rw-r--r--app/views/admin/_menu_search_results.html.erb3
-rw-r--r--app/views/menu_items/index.html.erb13
4 files changed, 45 insertions, 1 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 517506f..b911727 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -27,4 +27,23 @@ class AdminController < ApplicationController
27 end 27 end
28 end 28 end
29 29
30 def menu_search
31 @results = Node.search params[:search_term]
32
33 respond_to do |format|
34 format.html do
35 render :partial => 'admin/menu_search_results'
36 end
37
38
39 format.js do
40 render( :json => @results.map do |node|
41 {:node_id => node.id, :title => node.title, :unique_name => node.unique_name}
42 end
43 )
44
45 end
46 end
47 end
48
30end 49end
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb
index 1ac3ddb..d6f0252 100644
--- a/app/controllers/menu_items_controller.rb
+++ b/app/controllers/menu_items_controller.rb
@@ -13,6 +13,17 @@ class MenuItemsController < ApplicationController
13 end 13 end
14 14
15 def create 15 def create
16 respond_to do |format|
17 format.html {}
18
19 format.js do
20 MenuItem.create params[:menu_item]
21 end
22
23
24 end
25
26
16 end 27 end
17 28
18 def edit 29 def edit
diff --git a/app/views/admin/_menu_search_results.html.erb b/app/views/admin/_menu_search_results.html.erb
new file mode 100644
index 0000000..15a40d4
--- /dev/null
+++ b/app/views/admin/_menu_search_results.html.erb
@@ -0,0 +1,3 @@
1<%- @results.each do |result| %>
2<div><%= result.unique_name %></div>
3<% end %>
diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb
index 05cc530..d2ff10e 100644
--- a/app/views/menu_items/index.html.erb
+++ b/app/views/menu_items/index.html.erb
@@ -4,4 +4,15 @@
4 <% @menu_items.each do |menu_item| %> 4 <% @menu_items.each do |menu_item| %>
5 <li><%= menu_item.title %></li> 5 <li><%= menu_item.title %></li>
6 <% end %> 6 <% end %>
7</ul> \ No newline at end of file 7</ul>
8
9<div id="menu_item_search">
10 <div>
11 <% form_tag admin_search_path do %>
12 <span>Add menu item: </span><%= text_field_tag :search_term %>
13 <% end %>
14 </div>
15 <div id="search_results">
16
17 </div>
18</div> \ No newline at end of file