noodall-ui 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,15 +2,18 @@ module Noodall
2
2
  module Admin
3
3
  class NodesController < BaseController
4
4
  include Canable::Enforcers
5
+ include SortableTable::App::Controllers::ApplicationController
6
+
5
7
  layout 'noodall_admin'
6
8
  before_filter :set_title, :enforce_editor_permission
9
+ sortable_attributes :position, :admin_title, :title, :type, :updated_at
7
10
 
8
11
  def index
9
12
  if params[:node_id].nil?
10
- @nodes = Node.roots.paginate(:per_page => 20, :page => params[:page])
13
+ @nodes = Node.roots.paginate(:per_page => 20, :page => params[:page], :order => sort_order(:default => "ascending") )
11
14
  else
12
15
  @parent = Node.find(params[:node_id])
13
- @nodes = @parent.children.paginate(:per_page => 20, :page => params[:page])
16
+ @nodes = @parent.children.paginate(:per_page => 20, :page => params[:page], :order => sort_order(:default => "ascending") )
14
17
  end
15
18
 
16
19
  respond_to do |format|
@@ -11,4 +11,16 @@ module Noodall::Admin::BaseHelper
11
11
  content_tag :li, link_to( title, send(link) )
12
12
  end.join.html_safe
13
13
  end
14
+
15
+ # Monkey-patch for the thoughtbot/sortabletable headers, adding 'colspan' option
16
+ def sortable_table_header(opts = {})
17
+ raise ArgumentError if opts[:name].nil? || opts[:sort].nil?
18
+ anchor = opts[:anchor].blank? ? "" : "##{opts[:anchor]}"
19
+ content_tag :th,
20
+ link_to(opts[:name],
21
+ sortable_url(opts) + anchor,
22
+ :title => opts[:title]),
23
+ :class => sortable_table_header_classes(opts),
24
+ :colspan => opts[:colspan]
25
+ end
14
26
  end
@@ -24,11 +24,18 @@
24
24
  <table border="0" cellspacing="0" cellpadding="0" class="content">
25
25
  <thead>
26
26
  <tr>
27
- <th>Title</th>
28
- <th>Type</th>
29
- <th colspan="2">Arrange</th>
27
+ <%= sortable_table_header :name => "Title", :sort => "admin_title", :class => 'sort' %>
28
+ <%= sortable_table_header :name => "Type", :sort => "_type", :class => 'sort' %>
29
+
30
+ <%# Change 'position' header if we are sorting by position %>
31
+ <% if(params[:sort] && params[:sort] != "position" || params[:order] == "descending") %>
32
+ <%= sortable_table_header :name => "Position", :sort => "position", :class => 'sort' %>
33
+ <% else %>
34
+ <%= sortable_table_header :name => "Position", :sort => "position", :class => 'sort', :colspan => 2 %>
35
+ <% end %>
36
+
30
37
  <th width="120">Sub Section</th>
31
- <th>Updated</th>
38
+ <%= sortable_table_header :name => "Updated", :sort => "updated_at", :class => 'sort' %>
32
39
  <th width="45">Show</th>
33
40
  <th width="45">Published</th>
34
41
  <th width="45">Delete</th>
@@ -37,10 +44,19 @@
37
44
  <tbody>
38
45
  <% @nodes.each do |node| %>
39
46
  <tr id="node-<%= node.id %>" class="<%=cycle('odd', 'even')%>">
40
- <td class="edit"><%= link_to h(node.title), noodall_admin_node_path(node), :class => 'edit', :title => "Edit #{node.title}" %></td>
47
+ <td class="edit"><%= link_to h(node.admin_title), noodall_admin_node_path(node), :class => 'edit', :title => "Edit #{node.title}" %></td>
41
48
  <td><%= node.class.name.titleize %></td>
42
- <td width="25"><%= link_to 'up', move_up_noodall_admin_node_path(node), { :class => "page_up", :title => 'Move this content higher in the navigation' } unless node.first? %></td>
43
- <td width="30" class="down"><%= link_to 'down', move_down_noodall_admin_node_path(node), { :class => 'page_down', :title => 'Move this content lower in the navigation' } unless node.last? %></td>
49
+
50
+ <%# Change 'position' content if we are sorting by position %>
51
+ <% if(params[:sort] && params[:sort] != "position" || params[:order] == "descending") %>
52
+ <td width="55"><%= node.position %></td>
53
+ <% else %>
54
+
55
+ <td width="25"><%= link_to 'up', move_up_noodall_admin_node_path(node), { :class => "page_up", :title => 'Move this content higher in the navigation' } unless node.first? %></td>
56
+ <td width="30" class="down"><%= link_to 'down', move_down_noodall_admin_node_path(node), { :class => 'page_down', :title => 'Move this content lower in the navigation' } unless node.last? %></td>
57
+ <% end %>
58
+
59
+
44
60
  <td class="child">
45
61
  <% unless node.class.template_classes.blank? -%>
46
62
  <%= link_to pluralize(node.children.size, "Child"), noodall_admin_node_nodes_path(node), :title => "View content under #{h(node.title)}", :class => 'child-no' %>
@@ -56,11 +72,18 @@
56
72
  </tbody>
57
73
  <tfoot>
58
74
  <tr>
59
- <th>Title</th>
60
- <th>Type</th>
61
- <th colspan="2">Arrange</th>
62
- <th width="100">Sub-Section</th>
63
- <th>Updated</th>
75
+ <%= sortable_table_header :name => "Title", :sort => "admin_title", :class => 'sort' %>
76
+ <%= sortable_table_header :name => "Type", :sort => "_type", :class => 'sort' %>
77
+
78
+ <%# Change 'position' header if we are sorting by position %>
79
+ <% if(params[:sort] && params[:sort] != "position" || params[:order] == "descending") %>
80
+ <%= sortable_table_header :name => "Position", :sort => "position", :class => 'sort' %>
81
+ <% else %>
82
+ <%= sortable_table_header :name => "Position", :sort => "position", :class => 'sort', :colspan => 2 %>
83
+ <% end %>
84
+
85
+ <th width="120">Sub Section</th>
86
+ <%= sortable_table_header :name => "Updated", :sort => "updated_at", :class => 'sort' %>
64
87
  <th width="45">Show</th>
65
88
  <th width="45">Published</th>
66
89
  <th width="45">Delete</th>
@@ -22,7 +22,9 @@
22
22
  </p>
23
23
 
24
24
  <p>
25
+
25
26
  <%= f.label :link %><br />
27
+ <p>Remember to add <em>http://</em> to the beginning of external links (not part of this website).</p>
26
28
  <span class="input-wrap">
27
29
  <%= f.text_field :link %><br/>
28
30
  <span class="link-node">Content</span> |
@@ -0,0 +1,16 @@
1
+ Feature: Sort nodes by column
2
+ As a website admin
3
+ In order to peruse nodes more effectively
4
+ I want to be able to order them by their various column titles
5
+
6
+ Scenario Outline:
7
+ Given some nodes exist
8
+ When I am on the content admin page
9
+ And I follow <Title>
10
+ Then the nodes should be ordered by <Title>
11
+
12
+ Examples:
13
+ | Title |
14
+ | "Title" |
15
+ | "Type" |
16
+ | "Updated" |
@@ -0,0 +1,39 @@
1
+ Given /^some nodes exist$/ do
2
+ Time.stub!(:now).and_return(Time.parse("01/01/2010 13:37"))
3
+ f = Factory.build(:node)
4
+ f.title = "A Header"
5
+ f.save
6
+
7
+ Time.stub!(:now).and_return(Time.parse("01/01/2010 14:37"))
8
+ f = Factory.build(:node)
9
+ f.title = "B Header"
10
+ f.save
11
+
12
+ Time.stub!(:now).and_return(Time.parse("01/01/2010 15:37"))
13
+ f = Factory.build(:page_a)
14
+ f.title = "C Header"
15
+ f.save
16
+
17
+ end
18
+
19
+ Then /^the nodes should be ordered by "Title"$/ do
20
+ Then %{I should see in this order: C Header, B Header, A Header}
21
+ end
22
+
23
+
24
+ Then /^the nodes should be ordered by "Type"$/ do
25
+ Then %{I should see in this order: Page A, Noodall/Node, Noodall/Node}
26
+ end
27
+
28
+
29
+ Then /^the nodes should be ordered by "Updated"$/ do
30
+ Then %{I should see in this order: 15:37:00, 14:37:00, 13:37:00 }
31
+ end
32
+
33
+ Then /^(?:|I )should see in this order(?: within "([^\"]*)")?: (.*)$/ do |selector, text|
34
+ order = Regexp.new(text.gsub(', ', '.*'), Regexp::MULTILINE)
35
+
36
+ with_scope(selector) do
37
+ raise "Did not find keywords (#{text}) in the requested order!" unless page.body =~ order
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module UI
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
data/noodall-ui.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.required_rubygems_version = ">= 1.3.6"
16
16
 
17
- s.add_dependency 'noodall-core', ">= 0.4.3"
17
+ s.add_dependency 'noodall-core', ">= 0.6.0"
18
18
  s.add_dependency 'thoughtbot-sortable_table', "= 0.0.6"
19
19
  s.add_dependency 'will_paginate', "~> 3.0.pre2"
20
20
  s.add_dependency 'dynamic_form', ">= 0"
@@ -533,6 +533,11 @@ a.child-no {
533
533
  overflow:auto;
534
534
  }
535
535
 
536
+ .component_form_detail p{
537
+ position: relative;
538
+ }
539
+
540
+
536
541
  .slot_tag {
537
542
  display:block;
538
543
  float:right;
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-ui
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
8
  - 3
10
- version: 0.2.3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve England
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-24 00:00:00 +00:00
18
+ date: 2011-03-03 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,12 +24,12 @@ dependencies:
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- hash: 9
27
+ hash: 7
28
28
  segments:
29
29
  - 0
30
- - 4
31
- - 3
32
- version: 0.4.3
30
+ - 6
31
+ - 0
32
+ version: 0.6.0
33
33
  name: noodall-core
34
34
  prerelease: false
35
35
  version_requirements: *id001
@@ -207,6 +207,7 @@ files:
207
207
  - features/respond_with_correct_format.feature
208
208
  - features/search.feature
209
209
  - features/sitemap.feature
210
+ - features/sort_nodes_by_column.feature
210
211
  - features/step_definitions/asset_steps.rb
211
212
  - features/step_definitions/cms_node_steps.rb
212
213
  - features/step_definitions/component_steps.rb
@@ -218,6 +219,7 @@ files:
218
219
  - features/step_definitions/pubish_content_steps.rb
219
220
  - features/step_definitions/search_steps.rb
220
221
  - features/step_definitions/sign_in_steps.rb
222
+ - features/step_definitions/sorting_steps.rb
221
223
  - features/step_definitions/web_steps.rb
222
224
  - features/support/cucumber.css
223
225
  - features/support/env.rb