From c39eb1e9839664deb68b50b2a9db16770d42852c Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 22 Feb 2009 12:52:58 +0100 Subject: another round of view updates --- app/controllers/nodes_controller.rb | 14 ++++++++------ app/models/node.rb | 3 +++ app/views/admin/_menu.html.erb | 5 +++++ app/views/layouts/admin.html.erb | 7 +------ app/views/nodes/edit.html.erb | 11 ++++++----- app/views/nodes/index.html.erb | 3 +++ app/views/nodes/new.html.erb | 5 ++++- public/stylesheets/admin.css | 5 +++++ 8 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 app/views/admin/_menu.html.erb diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index baf023f..829e26f 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -3,7 +3,6 @@ class NodesController < ApplicationController layout 'admin' before_filter :login_required before_filter :find_node, :only => [ - :create, :show, :edit, :update, @@ -21,15 +20,18 @@ class NodesController < ApplicationController end def new - @node = Node.new + @node = Node.new params[:node] end def create - tmp_node = Node.new( params[:node] ) + parent = Node.find_by_unique_name(params[:parent_unique_name]) + parent ||= Node.root - if request.post? and tmp_node.save - tmp_node.move_to_child_of @node - redirect_to(tmp_node) + @node = Node.new( params[:node] ) + + if request.post? and @node.save + @node.move_to_child_of parent + redirect_to(@node) else render :action => :new end diff --git a/app/models/node.rb b/app/models/node.rb index 170ca1c..a6e3867 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -10,6 +10,9 @@ class Node < ActiveRecord::Base # Callbacks after_create :initialize_empty_page + # Validations + validates_length_of :slug, :within => 3..40 + # Class methods # Returns a page for a given node. If no revision is supplied, it returns diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb new file mode 100644 index 0000000..fa616df --- /dev/null +++ b/app/views/admin/_menu.html.erb @@ -0,0 +1,5 @@ +<%= language_selector %> | + +<%= link_to 'Overview', :controller => :admin, :action => 'index' %> | +<%= link_to 'Nodes', nodes_path %> | +<%= link_to 'User', users_path %> \ No newline at end of file diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 73e3b02..d5b1e6f 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -25,12 +25,7 @@
<%= flash[:notice] %> diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index f6513a7..7ec3be0 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -1,3 +1,9 @@ + +

Editing page

Sprache: <%= I18n.locale %> Pfad: <%= @node.unique_name %> @@ -27,9 +33,4 @@ <%= f.submit "Update" %>

<% end %> - - - <%= link_to 'Show', @node %> | - <%= link_to 'Back', nodes_path %> | - <%= link_to 'Publish', publish_node_path, :method => :put %>
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb index 533204d..da69125 100644 --- a/app/views/nodes/index.html.erb +++ b/app/views/nodes/index.html.erb @@ -1,3 +1,6 @@ +

Nodes

<%= will_paginate @nodes %> diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index 1207413..d657eb3 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb @@ -1,12 +1,15 @@

Create new node

+<%= error_messages_for :node %> + <% form_for @node do |f| %>

- <%= f.label 'Parent node' %>
+ <%= f.label 'Parent node - Leave empty for top level' %>
<%= text_field_tag :parent_unique_name %>

<%= f.label :slug %>
<%= f.text_field :slug %>

+

<%= f.submit 'Create node' %>

<% end %> \ No newline at end of file diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 242806f..0b7e630 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -56,6 +56,11 @@ input[type=text] { line-height: 30px; } +#subnavigation { + font-size: 15px; + padding-top: 10px; +} + #navigation a { text-decoration: none; } \ No newline at end of file -- cgit v1.3