From 46117a9f103e2d547be2a47724e872b3f57ce983 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 8 Aug 2009 22:38:48 +0200 Subject: lots of new code to manage menu items - harder than expected :/ --- app/controllers/admin_controller.rb | 19 +++++++++++++++++++ app/controllers/menu_items_controller.rb | 11 +++++++++++ app/views/admin/_menu_search_results.html.erb | 3 +++ app/views/menu_items/index.html.erb | 13 ++++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/_menu_search_results.html.erb (limited to 'app') 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 end end + def menu_search + @results = Node.search params[:search_term] + + respond_to do |format| + format.html do + render :partial => 'admin/menu_search_results' + end + + + format.js do + render( :json => @results.map do |node| + {:node_id => node.id, :title => node.title, :unique_name => node.unique_name} + end + ) + + end + end + end + end 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 end def create + respond_to do |format| + format.html {} + + format.js do + MenuItem.create params[:menu_item] + end + + + end + + end 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 @@ +<%- @results.each do |result| %> +
<%= result.unique_name %>
+<% 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 @@ <% @menu_items.each do |menu_item| %>
  • <%= menu_item.title %>
  • <% end %> - \ No newline at end of file + + + \ No newline at end of file -- cgit v1.3