From f7ce8c245fde3f6202103ae614b181c0ba44ed93 Mon Sep 17 00:00:00 2001 From: hukl Date: Wed, 9 Sep 2009 15:19:33 +0200 Subject: 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 --- app/controllers/nodes_controller.rb | 1 + app/models/node.rb | 9 +++++++++ app/views/nodes/edit.html.erb | 22 +++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'app') 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 end def update + @node.update_attributes(params[:node]) @draft = @node.find_or_create_draft current_user @draft.tag_list = params[:tag_list] 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 self.head = self.draft self.head.save! self.draft = nil + + if staged_slug && (staged_slug != slug) + self.slug = staged_slug + end + + if staged_parent_id && (staged_parent_id != parent_id) + self.parent_id = staged_parent_id + end + self.save! self.unlock! 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 @@ Slug - <%= f.text_field :slug %> + + <%= + f.text_field( + :staged_slug, :value => @node.staged_slug || @node.slug + ) + %> + + + + parent + + <%= text_field_tag :move_to_search_term, @node.parent.title rescue "" %> +
+ +
+ <%= f.hidden_field( + :staged_parent_id, + :value => @node.staged_parent_id || @node.parent_id + ) + %> + <% fields_for @draft do |d| %> -- cgit v1.3