diff options
| author | hukl <contact@smyck.org> | 2009-09-09 15:19:33 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-09 15:19:33 +0200 |
| commit | f7ce8c245fde3f6202103ae614b181c0ba44ed93 (patch) | |
| tree | 4625c54b0dfb31bdc3e71480fb8936fa5a6c0ca5 /app | |
| parent | f3a8cd8d1e8dfafb987163d95208e0ff2ccbfbc2 (diff) | |
added editing of slugs and moving of nodes. to edit a slug or move a node you edit that node, make your changes and save. the slug and parent node changes get staged and are applied once that revision is published
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/nodes_controller.rb | 1 | ||||
| -rw-r--r-- | app/models/node.rb | 9 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 22 |
3 files changed, 31 insertions, 1 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index a23354c..0d4a3fe 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -57,6 +57,7 @@ class NodesController < ApplicationController | |||
| 57 | end | 57 | end |
| 58 | 58 | ||
| 59 | def update | 59 | def update |
| 60 | @node.update_attributes(params[:node]) | ||
| 60 | @draft = @node.find_or_create_draft current_user | 61 | @draft = @node.find_or_create_draft current_user |
| 61 | @draft.tag_list = params[:tag_list] | 62 | @draft.tag_list = params[:tag_list] |
| 62 | if @draft.update_attributes( params[:page] ) | 63 | if @draft.update_attributes( params[:page] ) |
diff --git a/app/models/node.rb b/app/models/node.rb index a870a3a..057248e 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -87,6 +87,15 @@ class Node < ActiveRecord::Base | |||
| 87 | self.head = self.draft | 87 | self.head = self.draft |
| 88 | self.head.save! | 88 | self.head.save! |
| 89 | self.draft = nil | 89 | self.draft = nil |
| 90 | |||
| 91 | if staged_slug && (staged_slug != slug) | ||
| 92 | self.slug = staged_slug | ||
| 93 | end | ||
| 94 | |||
| 95 | if staged_parent_id && (staged_parent_id != parent_id) | ||
| 96 | self.parent_id = staged_parent_id | ||
| 97 | end | ||
| 98 | |||
| 90 | self.save! | 99 | self.save! |
| 91 | self.unlock! | 100 | self.unlock! |
| 92 | else | 101 | else |
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index e41321d..c23381f 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -18,7 +18,27 @@ | |||
| 18 | </tr> | 18 | </tr> |
| 19 | <tr> | 19 | <tr> |
| 20 | <td class="description">Slug</td> | 20 | <td class="description">Slug</td> |
| 21 | <td><%= f.text_field :slug %></td> | 21 | <td> |
| 22 | <%= | ||
| 23 | f.text_field( | ||
| 24 | :staged_slug, :value => @node.staged_slug || @node.slug | ||
| 25 | ) | ||
| 26 | %> | ||
| 27 | </td> | ||
| 28 | </tr> | ||
| 29 | <tr> | ||
| 30 | <td class="description">parent</td> | ||
| 31 | <td> | ||
| 32 | <%= text_field_tag :move_to_search_term, @node.parent.title rescue "" %> | ||
| 33 | <div id="search_results"> | ||
| 34 | |||
| 35 | </div> | ||
| 36 | <%= f.hidden_field( | ||
| 37 | :staged_parent_id, | ||
| 38 | :value => @node.staged_parent_id || @node.parent_id | ||
| 39 | ) | ||
| 40 | %> | ||
| 41 | </td> | ||
| 22 | </tr> | 42 | </tr> |
| 23 | 43 | ||
| 24 | <% fields_for @draft do |d| %> | 44 | <% fields_for @draft do |d| %> |
