summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-09-08 20:06:44 +0200
committerhukl <contact@smyck.org>2009-09-08 20:06:44 +0200
commitb48ee28e586fd75e84e33fabfcba70c05d32a606 (patch)
tree3654bd300fa8a2a387c50b53d23c794da49762d0 /app
parentb981d83e5e005817a67b11ccf92dd65bb506bcd4 (diff)
lots of gui improvements for creating nodes
Diffstat (limited to 'app')
-rw-r--r--app/controllers/nodes_controller.rb14
-rw-r--r--app/views/nodes/new.html.erb12
2 files changed, 16 insertions, 10 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
index f8b8058..a23354c 100644
--- a/app/controllers/nodes_controller.rb
+++ b/app/controllers/nodes_controller.rb
@@ -28,15 +28,17 @@ class NodesController < ApplicationController
28 end 28 end
29 29
30 def create 30 def create
31 @node = Node.new( params[:node] ) 31 parent = case params[:kind]
32 32 when "top_level" then Node.root
33 parent = Node.find(params[:parent_id]) 33 when "update" then Update.find_or_create_parent
34 when "generic" then Node.find(params[:parent_id])
35 end
34 36
35 if parent and @node.save 37 if parent
36 @node.move_to_child_of parent 38 @node = parent.children.create(:slug => params[:title].parameterize.to_s)
39 @node.draft.update_attributes(:title => params[:title])
37 redirect_to(edit_node_path(@node)) 40 redirect_to(edit_node_path(@node))
38 else 41 else
39 @node.errors.add("Parent node")
40 render :action => :new 42 render :action => :new
41 end 43 end
42 end 44 end
diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb
index 935e34f..e11030e 100644
--- a/app/views/nodes/new.html.erb
+++ b/app/views/nodes/new.html.erb
@@ -5,16 +5,20 @@
5 5
6<p>What kind of node do you want to create?</p> 6<p>What kind of node do you want to create?</p>
7 7
8<% form_for nodes_path do %> 8<% form_tag nodes_path do %>
9<table id="new_node"> 9<table id="new_node">
10 <tr> 10 <tr>
11 <td class="description">Type</td> 11 <td class="description">Type</td>
12 <td> 12 <td>
13 <div> 13 <div>
14 <%= radio_button_tag :kind, "generic" %> 14 <%= radio_button_tag :kind, "top_level" %>
15 Generic ( can be created anywhere ) 15 Top Level
16 </div> 16 </div>
17 <p> 17 <p>
18 <%= radio_button_tag :kind, "generic", :selected => true %>
19 Generic ( can be created anywhere )
20 </p>
21 <p>
18 <%= radio_button_tag :kind, "update" %> 22 <%= radio_button_tag :kind, "update" %>
19 Update / Press release ( is automatically created in /updates ) 23 Update / Press release ( is automatically created in /updates )
20 </p> 24 </p>
@@ -24,7 +28,7 @@
24 <td class="description">Title</td> 28 <td class="description">Title</td>
25 <td><%= text_field_tag :title %></td> 29 <td><%= text_field_tag :title %></td>
26 </tr> 30 </tr>
27 <tr> 31 <tr id="parent_search_field">
28 <td class="description">Parent</td> 32 <td class="description">Parent</td>
29 <td> 33 <td>
30 <%= text_field_tag :parent_search_term %> 34 <%= text_field_tag :parent_search_term %>