From 375ed745052148faeb34763087fe04214105f1b8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 6 Feb 2025 16:49:06 +0100 Subject: Improve worklflow --- app/controllers/admin_controller.rb | 18 ++++++++++++-- app/controllers/nodes_controller.rb | 15 +++++++++++- app/views/admin/index.html.erb | 48 ++++++++++++++++++++++++++++++++++--- app/views/nodes/new.html.erb | 12 ++++++---- 4 files changed, 83 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7c1375a..f3cc221 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -6,12 +6,15 @@ class AdminController < ApplicationController def index @drafts = Node.all( - :limit => 20, + :limit => 50, :order => "updated_at desc", :conditions => ["draft_id IS NOT NULL"] ) + @drafts_count = Node.count( + :conditions => ["draft_id IS NOT NULL"] + ) @recent_changes = Node.all( - :limit => 20, + :limit => 50, :order => "updated_at desc", :conditions => [ "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days @@ -24,6 +27,17 @@ class AdminController < ApplicationController @sitemap_depth[node.id] = level end @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } + + @mypages = Page.all( + :conditions => [ "user_id = ? or editor_id = ?", @current_user, @current_user] + ) + + @mynodes = Node.all( + :order => "updated_at desc", + :joins => :pages, + :conditions => [ "pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user ] + ).uniq.first(50) + end def search diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 4f72744..b8cd644 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -25,6 +25,10 @@ class NodesController < ApplicationController def new @node = Node.new params[:node] + if params.has_key?(:parent_id) + @parent_id = params[:parent_id] + @parent_name = Node.find(@parent_id).title + end end def create @@ -33,9 +37,16 @@ class NodesController < ApplicationController @node = Node.new @node.parent_id = find_parent @node.slug = params[:title].parameterize.to_s - + if @node.save @node.draft.update_attributes(:title => params[:title]) + case params[:kind] + when "update" + @node.draft.tag_list.add("update") + when "press_release" + @node.draft.tag_list.add("update", "pressemitteilung") + end + @node.draft.save! redirect_to(edit_node_path(@node)) else render :new @@ -107,6 +118,8 @@ class NodesController < ApplicationController Node.root.id when "update" Update.find_or_create_parent.id + when "press_release" + Update.find_or_create_parent.id when "generic" if params[:parent_id] && Node.find(params[:parent_id]) params[:parent_id] diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index 8c8271f..edad1d6 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,5 +1,13 @@ +
+ <%= link_to 'Create Update or Pressemitteilung', new_node_path, :only_path => false %> + Continue my work + Add a page in the page tree + <%= link_to("Upload a new asset", new_asset_path, :only_path => false) %> +
+

recent changes + my work current drafts site map

@@ -38,9 +46,43 @@ +
+ +

My Work

+ + + + + + + + + + <% @mynodes.each do |node| %> + "> + + + + + + + <% end %> +
IDTitleActionsLocked byRev.
<%= node.id %> +

<%= link_to title_for_node(node), node_path(node) %>

+

<%= link_to_path(node.unique_name, node.unique_name) %>

+
+ <%= link_to 'show', node_path(node) %> + <%= link_to 'Revisions', node_revisions_path(node) %> + + <%= node.lock_owner.login if node.lock_owner %> + + <%= node.draft ? node.draft.revision : node.head.revision %> +
+
+
-

Current Drafts

+

Current Drafts (<%= @drafts_count %>)

@@ -92,8 +134,8 @@

<%= link_to_path(node.unique_name, node.unique_name) %>

@@ -31,8 +35,8 @@
- <%= link_to 'show', node_path(node) %> - <%= link_to 'Revisions', node_revisions_path(node) %> + <%= link_to 'create subpage', new_node_path(:parent_id => node.id) %> + <%= link_to ':: Revisions', node_revisions_path(node) %> <%= node.lock_owner.login if node.lock_owner %> diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index 850207b..7d744de 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb @@ -20,7 +20,11 @@

<%= radio_button_tag :kind, "update" %> - Update / Press release ( is automatically created in /updates ) + Update ( is automatically created in /updates/<%= Time.now.year.to_s %>/ and gets tag "update" ) +

+

+ <%= radio_button_tag :kind, "press_release" %> + Pressemitteilung ( is automatically created in /updates/<%= Time.now.year.to_s %>/ and gets tags "update, pressemitteilung" )

Parent - <%= text_field_tag :parent_search_term %> - <%= hidden_field_tag :parent_id %> + <%= text_field_tag :parent_search_term, @parent_name %> + <%= hidden_field_tag :parent_id, @parent_id %>
@@ -43,4 +47,4 @@
<%= submit_tag "Create" %>
-<% end %> \ No newline at end of file +<% end %> -- cgit v1.3