diff options
| author | hukl <contact@smyck.org> | 2009-02-22 17:00:57 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-22 17:00:57 +0100 |
| commit | c129af3e013edb9e68bdf9069bd2879590bc54fd (patch) | |
| tree | 3bef8df8e42e5b25225a10a994673b139ef03fca | |
| parent | 3df96bbb94a6d89709983d0911ca79491ed6e981 (diff) | |
replaced freeform textfield with select tag which has to be replaced with something more decent soon. but it works for now
| -rw-r--r-- | app/controllers/nodes_controller.rb | 14 | ||||
| -rw-r--r-- | app/views/nodes/new.html.erb | 9 |
2 files changed, 14 insertions, 9 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 829e26f..a558a86 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -24,15 +24,15 @@ class NodesController < ApplicationController | |||
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | def create | 26 | def create |
| 27 | parent = Node.find_by_unique_name(params[:parent_unique_name]) | ||
| 28 | parent ||= Node.root | ||
| 29 | |||
| 30 | @node = Node.new( params[:node] ) | 27 | @node = Node.new( params[:node] ) |
| 31 | 28 | ||
| 32 | if request.post? and @node.save | 29 | parent = Node.find(params[:parent_id]) |
| 30 | |||
| 31 | if parent and @node.save | ||
| 33 | @node.move_to_child_of parent | 32 | @node.move_to_child_of parent |
| 34 | redirect_to(@node) | 33 | redirect_to(@node) |
| 35 | else | 34 | else |
| 35 | @node.errors.add("Parent node") | ||
| 36 | render :action => :new | 36 | render :action => :new |
| 37 | end | 37 | end |
| 38 | end | 38 | end |
| @@ -46,9 +46,9 @@ class NodesController < ApplicationController | |||
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | def update | 48 | def update |
| 49 | draft = @node.find_or_create_draft current_user | 49 | @draft = @node.find_or_create_draft current_user |
| 50 | 50 | @draft.tag_list = params[:tag_list] | |
| 51 | if draft.update_attributes( params[:page] ) | 51 | if @draft.update_attributes( params[:page] ) |
| 52 | redirect_to(@node) | 52 | redirect_to(@node) |
| 53 | else | 53 | else |
| 54 | render :action => :edit | 54 | render :action => :edit |
diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index d657eb3..29a26b6 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb | |||
| @@ -4,8 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | <% form_for @node do |f| %> | 5 | <% form_for @node do |f| %> |
| 6 | <p> | 6 | <p> |
| 7 | <%= f.label 'Parent node - Leave empty for top level' %><br /> | 7 | <%= f.label 'Parent node' %><br /> |
| 8 | <%= text_field_tag :parent_unique_name %> | 8 | <%= select_tag( |
| 9 | :parent_id, | ||
| 10 | options_for_select( | ||
| 11 | Node.root.self_and_descendants.select{|x| x.level < 3}.map{|x| [x.unique_name,x.id]} | ||
| 12 | ) | ||
| 13 | ) %> | ||
| 9 | </p> | 14 | </p> |
| 10 | <p> | 15 | <p> |
| 11 | <%= f.label :slug %><br /> | 16 | <%= f.label :slug %><br /> |
