summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-08-09 11:57:44 +0200
committerhukl <contact@smyck.org>2009-08-09 11:57:44 +0200
commit9b4d055b649ad24ad1482f72d138aa73da1e4bd7 (patch)
treefa97f1877332fe05d1eb752c7ac63dce44edc32d /app
parent550d9c1790b202175076894bf82d202bc32db5b6 (diff)
refactored the way new menu items are created. went back to rest and added the js ajax search to fill out the form for you. much cleaner, unobtrusive approach.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/menu_items_controller.rb15
-rw-r--r--app/views/menu_items/index.html.erb18
-rw-r--r--app/views/menu_items/new.html.erb34
3 files changed, 43 insertions, 24 deletions
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb
index d6f0252..0ba56c3 100644
--- a/app/controllers/menu_items_controller.rb
+++ b/app/controllers/menu_items_controller.rb
@@ -10,20 +10,15 @@ class MenuItemsController < ApplicationController
10 end 10 end
11 11
12 def new 12 def new
13 @menu_item = MenuItem.new params[:menu_item]
13 end 14 end
14 15
15 def create 16 def create
16 respond_to do |format| 17 if MenuItem.create( params[:menu_item] )
17 format.html {} 18 redirect_to menu_items_path
18 19 else
19 format.js do 20 render :new
20 MenuItem.create params[:menu_item]
21 end
22
23
24 end 21 end
25
26
27 end 22 end
28 23
29 def edit 24 def edit
diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb
index d2ff10e..db4a771 100644
--- a/app/views/menu_items/index.html.erb
+++ b/app/views/menu_items/index.html.erb
@@ -1,18 +1,12 @@
1<% content_for :subnavigation do %>
2 <%= link_to "new", new_menu_item_path %>
3<% end %>
4
5
1<h1>Menu Items</h1> 6<h1>Menu Items</h1>
2 7
3<ul> 8<ul>
4 <% @menu_items.each do |menu_item| %> 9 <% @menu_items.each do |menu_item| %>
5 <li><%= menu_item.title %></li> 10 <li><%= menu_item.title %></li>
6 <% end %> 11 <% end %>
7</ul> 12</ul> \ No newline at end of file
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
diff --git a/app/views/menu_items/new.html.erb b/app/views/menu_items/new.html.erb
index e3f800e..64b9abb 100644
--- a/app/views/menu_items/new.html.erb
+++ b/app/views/menu_items/new.html.erb
@@ -1,2 +1,32 @@
1<h1>MenuItems#new</h1> 1<h1>Add Menu Item</h1>
2<p>Find me in app/views/menu_items/new.html.erb</p> 2
3<% form_for @menu_item do |f| %>
4 <table>
5
6 <tr>
7 <td class="description">Search</td>
8 <td>
9 <%= text_field_tag :menu_search_term %>
10 <div id="search_results">
11
12 </div>
13 </td>
14 </tr>
15 <tr>
16 <td class="description">Node Id</td>
17 <td><%= f.text_field :node_id %></td>
18 </tr>
19 <tr>
20 <td class="description">Path</td>
21 <td><%= f.text_field :path %></td>
22 </tr>
23 <tr>
24 <td class="description">Title</td>
25 <td><%= f.text_field :title %></td>
26 </tr>
27 <tr>
28 <td></td>
29 <td class="right"><%= f.submit 'Create' %></td>
30 </tr>
31 </table>
32<% end %> \ No newline at end of file