diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2025-02-06 16:49:06 +0100 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2025-02-06 16:49:06 +0100 |
| commit | 375ed745052148faeb34763087fe04214105f1b8 (patch) | |
| tree | 595456cf631087b5530bf5470529faeead1a0aaf | |
| parent | 38d80f0af731326fcd5ae16c0129a056eff2fe32 (diff) | |
Improve worklflow
| -rw-r--r-- | app/controllers/admin_controller.rb | 18 | ||||
| -rw-r--r-- | app/controllers/nodes_controller.rb | 15 | ||||
| -rw-r--r-- | app/views/admin/index.html.erb | 48 | ||||
| -rw-r--r-- | app/views/nodes/new.html.erb | 12 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 52 | ||||
| -rw-r--r-- | public/javascripts/admin_search.js | 4 | ||||
| -rw-r--r-- | 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 | |||
| 6 | 6 | ||
| 7 | def index | 7 | def index |
| 8 | @drafts = Node.all( | 8 | @drafts = Node.all( |
| 9 | :limit => 20, | 9 | :limit => 50, |
| 10 | :order => "updated_at desc", | 10 | :order => "updated_at desc", |
| 11 | :conditions => ["draft_id IS NOT NULL"] | 11 | :conditions => ["draft_id IS NOT NULL"] |
| 12 | ) | 12 | ) |
| 13 | @drafts_count = Node.count( | ||
| 14 | :conditions => ["draft_id IS NOT NULL"] | ||
| 15 | ) | ||
| 13 | @recent_changes = Node.all( | 16 | @recent_changes = Node.all( |
| 14 | :limit => 20, | 17 | :limit => 50, |
| 15 | :order => "updated_at desc", | 18 | :order => "updated_at desc", |
| 16 | :conditions => [ | 19 | :conditions => [ |
| 17 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days | 20 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days |
| @@ -24,6 +27,17 @@ class AdminController < ApplicationController | |||
| 24 | @sitemap_depth[node.id] = level | 27 | @sitemap_depth[node.id] = level |
| 25 | end | 28 | end |
| 26 | @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } | 29 | @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } |
| 30 | |||
| 31 | @mypages = Page.all( | ||
| 32 | :conditions => [ "user_id = ? or editor_id = ?", @current_user, @current_user] | ||
| 33 | ) | ||
| 34 | |||
| 35 | @mynodes = Node.all( | ||
| 36 | :order => "updated_at desc", | ||
| 37 | :joins => :pages, | ||
| 38 | :conditions => [ "pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user ] | ||
| 39 | ).uniq.first(50) | ||
| 40 | |||
| 27 | end | 41 | end |
| 28 | 42 | ||
| 29 | def search | 43 | 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 | |||
| 25 | 25 | ||
| 26 | def new | 26 | def new |
| 27 | @node = Node.new params[:node] | 27 | @node = Node.new params[:node] |
| 28 | if params.has_key?(:parent_id) | ||
| 29 | @parent_id = params[:parent_id] | ||
| 30 | @parent_name = Node.find(@parent_id).title | ||
| 31 | end | ||
| 28 | end | 32 | end |
| 29 | 33 | ||
| 30 | def create | 34 | def create |
| @@ -33,9 +37,16 @@ class NodesController < ApplicationController | |||
| 33 | @node = Node.new | 37 | @node = Node.new |
| 34 | @node.parent_id = find_parent | 38 | @node.parent_id = find_parent |
| 35 | @node.slug = params[:title].parameterize.to_s | 39 | @node.slug = params[:title].parameterize.to_s |
| 36 | 40 | ||
| 37 | if @node.save | 41 | if @node.save |
| 38 | @node.draft.update_attributes(:title => params[:title]) | 42 | @node.draft.update_attributes(:title => params[:title]) |
| 43 | case params[:kind] | ||
| 44 | when "update" | ||
| 45 | @node.draft.tag_list.add("update") | ||
| 46 | when "press_release" | ||
| 47 | @node.draft.tag_list.add("update", "pressemitteilung") | ||
| 48 | end | ||
| 49 | @node.draft.save! | ||
| 39 | redirect_to(edit_node_path(@node)) | 50 | redirect_to(edit_node_path(@node)) |
| 40 | else | 51 | else |
| 41 | render :new | 52 | render :new |
| @@ -107,6 +118,8 @@ class NodesController < ApplicationController | |||
| 107 | Node.root.id | 118 | Node.root.id |
| 108 | when "update" | 119 | when "update" |
| 109 | Update.find_or_create_parent.id | 120 | Update.find_or_create_parent.id |
| 121 | when "press_release" | ||
| 122 | Update.find_or_create_parent.id | ||
| 110 | when "generic" | 123 | when "generic" |
| 111 | if params[:parent_id] && Node.find(params[:parent_id]) | 124 | if params[:parent_id] && Node.find(params[:parent_id]) |
| 112 | params[:parent_id] | 125 | 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 @@ | |||
| 1 | <div id="admin_wizard"> | ||
| 2 | <%= link_to 'Create Update or Pressemitteilung', new_node_path, :only_path => false %> | ||
| 3 | <a href="#" id="admin_wizard_my_work" class="admin_wizard_button button">Continue my work</a> | ||
| 4 | <a href="#" id="admin_wizard_create_page" class="admin_wizard_button button">Add a page in the page tree</a> | ||
| 5 | <%= link_to("Upload a new asset", new_asset_path, :only_path => false) %> | ||
| 6 | </div> | ||
| 7 | |||
| 1 | <p id="overview_toggle"> | 8 | <p id="overview_toggle"> |
| 2 | <a href="#" id="recent_changes_toggle" class="button">recent changes</a> | 9 | <a href="#" id="recent_changes_toggle" class="button">recent changes</a> |
| 10 | <a href="#" id="my_work_toggle" class="button">my work</a> | ||
| 3 | <a href="#" id="current_drafts_toggle" class="button">current drafts</a> | 11 | <a href="#" id="current_drafts_toggle" class="button">current drafts</a> |
| 4 | <a href="#" id="admin_sitemap_toggle" class="button">site map</a> | 12 | <a href="#" id="admin_sitemap_toggle" class="button">site map</a> |
| 5 | </p> | 13 | </p> |
| @@ -38,9 +46,43 @@ | |||
| 38 | </table> | 46 | </table> |
| 39 | </div> | 47 | </div> |
| 40 | 48 | ||
| 49 | <div id="my_work_table"> | ||
| 50 | |||
| 51 | <h1>My Work</h1> | ||
| 52 | |||
| 53 | <table class="node_table"> | ||
| 54 | <tr class="header"> | ||
| 55 | <th class="node_id">ID</th> | ||
| 56 | <th class="title">Title</th> | ||
| 57 | <th class="actions">Actions</th> | ||
| 58 | <th class="editor">Locked by</th> | ||
| 59 | <th class="revision">Rev.</th> | ||
| 60 | </tr> | ||
| 61 | <% @mynodes.each do |node| %> | ||
| 62 | <tr class="<%= cycle("even", "odd") %>"> | ||
| 63 | <td class="node_id"><%= node.id %></td> | ||
| 64 | <td class="title"> | ||
| 65 | <h4><%= link_to title_for_node(node), node_path(node) %></h4> | ||
| 66 | <p><%= link_to_path(node.unique_name, node.unique_name) %></p> | ||
| 67 | </td> | ||
| 68 | <td class="actions"> | ||
| 69 | <%= link_to 'show', node_path(node) %> | ||
| 70 | <%= link_to 'Revisions', node_revisions_path(node) %> | ||
| 71 | </td> | ||
| 72 | <td> | ||
| 73 | <%= node.lock_owner.login if node.lock_owner %> | ||
| 74 | </td> | ||
| 75 | <td> | ||
| 76 | <%= node.draft ? node.draft.revision : node.head.revision %> | ||
| 77 | </td> | ||
| 78 | </tr> | ||
| 79 | <% end %> | ||
| 80 | </table> | ||
| 81 | </div> | ||
| 82 | |||
| 41 | <div id="current_drafts_table"> | 83 | <div id="current_drafts_table"> |
| 42 | 84 | ||
| 43 | <h1>Current Drafts</h1> | 85 | <h1>Current Drafts (<%= @drafts_count %>)</h1> |
| 44 | 86 | ||
| 45 | <table class="node_table"> | 87 | <table class="node_table"> |
| 46 | <tr class="header"> | 88 | <tr class="header"> |
| @@ -92,8 +134,8 @@ | |||
| 92 | <p><%= link_to_path(node.unique_name, node.unique_name) %></p> | 134 | <p><%= link_to_path(node.unique_name, node.unique_name) %></p> |
| 93 | </td> | 135 | </td> |
| 94 | <td class="actions"> | 136 | <td class="actions"> |
| 95 | <%= link_to 'show', node_path(node) %> | 137 | <%= link_to 'create subpage', new_node_path(:parent_id => node.id) %> |
| 96 | <%= link_to 'Revisions', node_revisions_path(node) %> | 138 | <%= link_to ':: Revisions', node_revisions_path(node) %> |
| 97 | </td> | 139 | </td> |
| 98 | <td> | 140 | <td> |
| 99 | <%= node.lock_owner.login if node.lock_owner %> | 141 | <%= 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 @@ | |||
| 20 | </p> | 20 | </p> |
| 21 | <p> | 21 | <p> |
| 22 | <%= radio_button_tag :kind, "update" %> | 22 | <%= radio_button_tag :kind, "update" %> |
| 23 | Update / Press release ( is automatically created in /updates ) | 23 | Update ( is automatically created in /updates/<%= Time.now.year.to_s %>/ and gets tag "update" ) |
| 24 | </p> | ||
| 25 | <p> | ||
| 26 | <%= radio_button_tag :kind, "press_release" %> | ||
| 27 | Pressemitteilung ( is automatically created in /updates/<%= Time.now.year.to_s %>/ and gets tags "update, pressemitteilung" ) | ||
| 24 | </p> | 28 | </p> |
| 25 | </td> | 29 | </td> |
| 26 | </tr> | 30 | </tr> |
| @@ -31,8 +35,8 @@ | |||
| 31 | <tr id="parent_search_field"> | 35 | <tr id="parent_search_field"> |
| 32 | <td class="description">Parent</td> | 36 | <td class="description">Parent</td> |
| 33 | <td> | 37 | <td> |
| 34 | <%= text_field_tag :parent_search_term %> | 38 | <%= text_field_tag :parent_search_term, @parent_name %> |
| 35 | <%= hidden_field_tag :parent_id %> | 39 | <%= hidden_field_tag :parent_id, @parent_id %> |
| 36 | <div id="search_results"> | 40 | <div id="search_results"> |
| 37 | 41 | ||
| 38 | </div> | 42 | </div> |
| @@ -43,4 +47,4 @@ | |||
| 43 | <td class="right"><%= submit_tag "Create" %></td> | 47 | <td class="right"><%= submit_tag "Create" %></td> |
| 44 | </tr> | 48 | </tr> |
| 45 | </table> | 49 | </table> |
| 46 | <% end %> \ No newline at end of file | 50 | <% 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 @@ | |||
| 1 | function hide_all() { | ||
| 2 | $('#recent_changes_toggle').attr("class", "unselected"); | ||
| 3 | $('#my_work_toggle').attr("class", "unselected"); | ||
| 4 | $('#current_drafts_toggle').attr("class", "unselected"); | ||
| 5 | $('#admin_sitemap_toggle').attr("class", "unselected"); | ||
| 6 | |||
| 7 | $('#current_drafts_table').hide(); | ||
| 8 | $('#my_work_table').hide(); | ||
| 9 | $('#recent_changes_table').hide(); | ||
| 10 | $('#admin_sitemap_table').hide(); | ||
| 11 | } | ||
| 12 | |||
| 1 | $(document).ready(function () { | 13 | $(document).ready(function () { |
| 2 | admin_search.initialize(); | 14 | admin_search.initialize(); |
| 3 | 15 | ||
| @@ -43,36 +55,48 @@ $(document).ready(function () { | |||
| 43 | } | 55 | } |
| 44 | 56 | ||
| 45 | if ($('#recent_changes_toggle').length != 0) { | 57 | if ($('#recent_changes_toggle').length != 0) { |
| 46 | $('#current_drafts_table').hide(); | 58 | hide_all(); |
| 47 | $('#admin_sitemap_table').hide(); | ||
| 48 | $('#recent_changes_toggle').attr("class", "selected"); | 59 | $('#recent_changes_toggle').attr("class", "selected"); |
| 60 | $('#recent_changes_table').show(); | ||
| 49 | 61 | ||
| 50 | $('#recent_changes_toggle').bind("click", function(){ | 62 | $('#recent_changes_toggle').bind("click", function(){ |
| 63 | hide_all(); | ||
| 51 | $('#recent_changes_toggle').attr("class", "selected"); | 64 | $('#recent_changes_toggle').attr("class", "selected"); |
| 52 | $('#current_drafts_toggle').attr("class", "unselected"); | ||
| 53 | $('#admin_sitemap_toggle').attr("class", "unselected"); | ||
| 54 | $('#recent_changes_table').show(); | 65 | $('#recent_changes_table').show(); |
| 55 | $('#current_drafts_table').hide(); | 66 | return false; |
| 56 | $('#admin_sitemap_table').hide(); | 67 | }); |
| 68 | |||
| 69 | $('#my_work_toggle').bind("click", function(){ | ||
| 70 | hide_all(); | ||
| 71 | $('#my_work_toggle').attr("class", "selected"); | ||
| 72 | $('#my_work_table').show(); | ||
| 73 | return false; | ||
| 74 | }); | ||
| 75 | |||
| 76 | $('#admin_wizard_my_work').bind("click", function(){ | ||
| 77 | hide_all(); | ||
| 78 | $('#my_work_toggle').attr("class", "selected"); | ||
| 79 | $('#my_work_table').show(); | ||
| 57 | return false; | 80 | return false; |
| 58 | }); | 81 | }); |
| 59 | 82 | ||
| 60 | $('#current_drafts_toggle').bind("click", function(){ | 83 | $('#current_drafts_toggle').bind("click", function(){ |
| 61 | $('#recent_changes_toggle').attr("class", "unselected"); | 84 | hide_all(); |
| 62 | $('#current_drafts_toggle').attr("class", "selected"); | 85 | $('#current_drafts_toggle').attr("class", "selected"); |
| 63 | $('#admin_sitemap_toggle').attr("class", "unselected"); | ||
| 64 | $('#current_drafts_table').show(); | 86 | $('#current_drafts_table').show(); |
| 65 | $('#recent_changes_table').hide(); | ||
| 66 | $('#admin_sitemap_table').hide(); | ||
| 67 | return false; | 87 | return false; |
| 68 | }); | 88 | }); |
| 69 | 89 | ||
| 70 | $('#admin_sitemap_toggle').bind("click", function(){ | 90 | $('#admin_sitemap_toggle').bind("click", function(){ |
| 71 | $('#recent_changes_toggle').attr("class", "unselected"); | 91 | hide_all(); |
| 72 | $('#current_drafts_toggle').attr("class", "unselected"); | 92 | $('#admin_sitemap_toggle').attr("class", "selected"); |
| 93 | $('#admin_sitemap_table').show(); | ||
| 94 | return false; | ||
| 95 | }); | ||
| 96 | |||
| 97 | $('#admin_wizard_create_page').bind("click", function(){ | ||
| 98 | hide_all(); | ||
| 73 | $('#admin_sitemap_toggle').attr("class", "selected"); | 99 | $('#admin_sitemap_toggle').attr("class", "selected"); |
| 74 | $('#current_drafts_table').hide(); | ||
| 75 | $('#recent_changes_table').hide(); | ||
| 76 | $('#admin_sitemap_table').show(); | 100 | $('#admin_sitemap_table').show(); |
| 77 | return false; | 101 | return false; |
| 78 | }); | 102 | }); |
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 = { | |||
| 160 | $("#parent_search_field").hide(); | 160 | $("#parent_search_field").hide(); |
| 161 | }); | 161 | }); |
| 162 | 162 | ||
| 163 | $("#kind_press_release").bind("change", function(){ | ||
| 164 | $("#parent_search_field").hide(); | ||
| 165 | }); | ||
| 166 | |||
| 163 | $("#kind_generic").bind("change", function(){ | 167 | $("#kind_generic").bind("change", function(){ |
| 164 | $("#parent_search_field").show(); | 168 | $("#parent_search_field").show(); |
| 165 | }); | 169 | }); |
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], | |||
| 106 | text-transform: lowercase; | 106 | text-transform: lowercase; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | #admin_wizard { | ||
| 110 | margin-bottom: 2rem; | ||
| 111 | } | ||
| 112 | |||
| 113 | #admin_wizard a { | ||
| 114 | font-size: 1rem; | ||
| 115 | font-weight: bold; | ||
| 116 | padding: 0.5rem; | ||
| 117 | background-color: green; | ||
| 118 | color: white; | ||
| 119 | } | ||
| 120 | |||
| 121 | #admin_wizard a:hover { | ||
| 122 | background-color: lime; | ||
| 123 | } | ||
| 124 | |||
| 109 | #sub_navigation a { | 125 | #sub_navigation a { |
| 110 | color: #969696; | 126 | color: #969696; |
| 111 | } | 127 | } |
