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 +++++--- public/javascripts/admin_interface.js | 52 +++++++++++++++++++++++++---------- public/javascripts/admin_search.js | 4 +++ public/stylesheets/admin.css | 16 +++++++++++ 7 files changed, 141 insertions(+), 24 deletions(-) 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 %> diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index ea3ab3d..aacb6f8 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js @@ -1,3 +1,15 @@ +function hide_all() { + $('#recent_changes_toggle').attr("class", "unselected"); + $('#my_work_toggle').attr("class", "unselected"); + $('#current_drafts_toggle').attr("class", "unselected"); + $('#admin_sitemap_toggle').attr("class", "unselected"); + + $('#current_drafts_table').hide(); + $('#my_work_table').hide(); + $('#recent_changes_table').hide(); + $('#admin_sitemap_table').hide(); +} + $(document).ready(function () { admin_search.initialize(); @@ -43,36 +55,48 @@ $(document).ready(function () { } if ($('#recent_changes_toggle').length != 0) { - $('#current_drafts_table').hide(); - $('#admin_sitemap_table').hide(); + hide_all(); $('#recent_changes_toggle').attr("class", "selected"); + $('#recent_changes_table').show(); $('#recent_changes_toggle').bind("click", function(){ + hide_all(); $('#recent_changes_toggle').attr("class", "selected"); - $('#current_drafts_toggle').attr("class", "unselected"); - $('#admin_sitemap_toggle').attr("class", "unselected"); $('#recent_changes_table').show(); - $('#current_drafts_table').hide(); - $('#admin_sitemap_table').hide(); + return false; + }); + + $('#my_work_toggle').bind("click", function(){ + hide_all(); + $('#my_work_toggle').attr("class", "selected"); + $('#my_work_table').show(); + return false; + }); + + $('#admin_wizard_my_work').bind("click", function(){ + hide_all(); + $('#my_work_toggle').attr("class", "selected"); + $('#my_work_table').show(); return false; }); $('#current_drafts_toggle').bind("click", function(){ - $('#recent_changes_toggle').attr("class", "unselected"); + hide_all(); $('#current_drafts_toggle').attr("class", "selected"); - $('#admin_sitemap_toggle').attr("class", "unselected"); $('#current_drafts_table').show(); - $('#recent_changes_table').hide(); - $('#admin_sitemap_table').hide(); return false; }); $('#admin_sitemap_toggle').bind("click", function(){ - $('#recent_changes_toggle').attr("class", "unselected"); - $('#current_drafts_toggle').attr("class", "unselected"); + hide_all(); + $('#admin_sitemap_toggle').attr("class", "selected"); + $('#admin_sitemap_table').show(); + return false; + }); + + $('#admin_wizard_create_page').bind("click", function(){ + hide_all(); $('#admin_sitemap_toggle').attr("class", "selected"); - $('#current_drafts_table').hide(); - $('#recent_changes_table').hide(); $('#admin_sitemap_table').show(); return false; }); diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 98571de..78577e7 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js @@ -160,6 +160,10 @@ parent_search = { $("#parent_search_field").hide(); }); + $("#kind_press_release").bind("change", function(){ + $("#parent_search_field").hide(); + }); + $("#kind_generic").bind("change", function(){ $("#parent_search_field").show(); }); diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index fbb8a3f..c7ebb52 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -106,6 +106,22 @@ input[type=submit], text-transform: lowercase; } +#admin_wizard { + margin-bottom: 2rem; +} + +#admin_wizard a { + font-size: 1rem; + font-weight: bold; + padding: 0.5rem; + background-color: green; + color: white; +} + +#admin_wizard a:hover { + background-color: lime; +} + #sub_navigation a { color: #969696; } -- cgit v1.3