diff options
| author | hukl <contact@smyck.org> | 2009-09-08 16:35:22 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-08 16:35:22 +0200 |
| commit | b981d83e5e005817a67b11ccf92dd65bb506bcd4 (patch) | |
| tree | 046778c6ef694178b12acf28837aa63d6b0a7493 | |
| parent | 03bde9fb42235af7147d6312e2cf6d928111dee1 (diff) | |
new interface for adding nodes. still needs a bit radio button magick
| -rw-r--r-- | app/views/nodes/new.html.erb | 52 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 1 | ||||
| -rw-r--r-- | public/javascripts/admin_search.js | 54 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 8 |
4 files changed, 98 insertions, 17 deletions
diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index 29a26b6..935e34f 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb | |||
| @@ -2,19 +2,41 @@ | |||
| 2 | 2 | ||
| 3 | <%= error_messages_for :node %> | 3 | <%= error_messages_for :node %> |
| 4 | 4 | ||
| 5 | <% form_for @node do |f| %> | 5 | |
| 6 | <p> | 6 | <p>What kind of node do you want to create?</p> |
| 7 | <%= f.label 'Parent node' %><br /> | 7 | |
| 8 | <%= select_tag( | 8 | <% form_for nodes_path do %> |
| 9 | :parent_id, | 9 | <table id="new_node"> |
| 10 | options_for_select( | 10 | <tr> |
| 11 | Node.root.self_and_descendants.select{|x| x.level < 3}.map{|x| [x.unique_name,x.id]} | 11 | <td class="description">Type</td> |
| 12 | ) | 12 | <td> |
| 13 | ) %> | 13 | <div> |
| 14 | </p> | 14 | <%= radio_button_tag :kind, "generic" %> |
| 15 | <p> | 15 | Generic ( can be created anywhere ) |
| 16 | <%= f.label :slug %><br /> | 16 | </div> |
| 17 | <%= f.text_field :slug %> | 17 | <p> |
| 18 | </p> | 18 | <%= radio_button_tag :kind, "update" %> |
| 19 | <p><%= f.submit 'Create node' %></p> | 19 | Update / Press release ( is automatically created in /updates ) |
| 20 | </p> | ||
| 21 | </td> | ||
| 22 | </tr> | ||
| 23 | <tr> | ||
| 24 | <td class="description">Title</td> | ||
| 25 | <td><%= text_field_tag :title %></td> | ||
| 26 | </tr> | ||
| 27 | <tr> | ||
| 28 | <td class="description">Parent</td> | ||
| 29 | <td> | ||
| 30 | <%= text_field_tag :parent_search_term %> | ||
| 31 | <%= hidden_field_tag :parent_id %> | ||
| 32 | <div id="search_results"> | ||
| 33 | |||
| 34 | </div> | ||
| 35 | </td> | ||
| 36 | </tr> | ||
| 37 | <tr> | ||
| 38 | <td></td> | ||
| 39 | <td class="right"><%= submit_tag "Create" %></td> | ||
| 40 | </tr> | ||
| 41 | </table> | ||
| 20 | <% end %> \ No newline at end of file | 42 | <% end %> \ No newline at end of file |
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 57bf8c6..47a4bac 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -3,6 +3,7 @@ $(document).ready(function () { | |||
| 3 | menu_items.initialize_search(); | 3 | menu_items.initialize_search(); |
| 4 | meta_data.initialize(); | 4 | meta_data.initialize(); |
| 5 | menu_item_sorter.initialize(); | 5 | menu_item_sorter.initialize(); |
| 6 | parent_search.initialize_search(); | ||
| 6 | 7 | ||
| 7 | jQuery.ajaxSetup({ | 8 | jQuery.ajaxSetup({ |
| 8 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");} | 9 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");} |
diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index c8d269f..1800506 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js | |||
| @@ -95,5 +95,55 @@ menu_items = { | |||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | return barf; | 97 | return barf; |
| 98 | } | 98 | } |
| 99 | }; \ No newline at end of file | 99 | }; |
| 100 | |||
| 101 | parent_search = { | ||
| 102 | initialize_search : function() { | ||
| 103 | $("#parent_search_term").bind("keyup", function() { | ||
| 104 | if ($(this).attr("value")) { | ||
| 105 | $.ajax({ | ||
| 106 | type: "GET", | ||
| 107 | url: "/admin/menu_search", | ||
| 108 | data: "search_term=" + $(this).attr("value"), | ||
| 109 | dataType: "json", | ||
| 110 | success : function(results) { | ||
| 111 | parent_search.show_results(results); | ||
| 112 | } | ||
| 113 | }); | ||
| 114 | } | ||
| 115 | else { | ||
| 116 | $('#search_results').slideUp(); | ||
| 117 | $('#search_results').empty(); | ||
| 118 | } | ||
| 119 | }); | ||
| 120 | }, | ||
| 121 | show_results : function(results) { | ||
| 122 | $("#search_results").empty(); | ||
| 123 | for (result in results) { | ||
| 124 | var link = $(("<a href='#' rel='" + results[result].id+ "'>"+ results[result].title + "</a>")); | ||
| 125 | $(link).bind("click", parent_search.link_closure(results[result])); | ||
| 126 | |||
| 127 | |||
| 128 | // Sometimes I don't get jquery; wrap() didn't work *sigh* | ||
| 129 | // Guess I'll need a book someday or another framework | ||
| 130 | var wrapper = $("<div></div>"); | ||
| 131 | $(wrapper).append(link) | ||
| 132 | |||
| 133 | $("#search_results").append(wrapper); | ||
| 134 | |||
| 135 | } | ||
| 136 | }, | ||
| 137 | link_closure : function(node) { | ||
| 138 | var barf = function(){ | ||
| 139 | $("#parent_search_term").attr("value", node.title); | ||
| 140 | alert(node.id); | ||
| 141 | $("#parent_id").attr("value", node.node_id); | ||
| 142 | $('#search_results').slideUp(); | ||
| 143 | $('#search_results').empty(); | ||
| 144 | return false; | ||
| 145 | } | ||
| 146 | |||
| 147 | return barf; | ||
| 148 | } | ||
| 149 | } | ||
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index f7ef868..9fa503b 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css | |||
| @@ -276,6 +276,14 @@ textarea#page_abstract { | |||
| 276 | margin-left: -125px; | 276 | margin-left: -125px; |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | #new_node { | ||
| 280 | margin-left: -118px; | ||
| 281 | } | ||
| 282 | |||
| 283 | #new_node input[type=text] { | ||
| 284 | width: 350px; | ||
| 285 | } | ||
| 286 | |||
| 279 | tr {} | 287 | tr {} |
| 280 | 288 | ||
| 281 | td { | 289 | td { |
