sferik-merb-admin 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -14,7 +14,7 @@ At the command prompt, type:
14
14
 
15
15
  In your app, add the following dependency to `config/dependencies.rb`:
16
16
 
17
- dependency "sferik-merb-admin", "0.1.8", :require_as => "merb-admin"
17
+ dependency "sferik-merb-admin", "0.1.9", :require_as => "merb-admin"
18
18
 
19
19
  Add the following route to `config/router.rb`:
20
20
 
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ AUTHOR = "Erik Michaels-Ober"
12
12
  EMAIL = "sferik@gmail.com"
13
13
  HOMEPAGE = "http://twitter.com/sferik"
14
14
  SUMMARY = "MerbAdmin is a merb slice that provides an easy-to-use interface for managing your data."
15
- GEM_VERSION = "0.1.8"
15
+ GEM_VERSION = "0.1.9"
16
16
 
17
17
  spec = Gem::Specification.new do |s|
18
18
  s.rubyforge_project = "merb"
@@ -24,6 +24,17 @@ class MerbAdmin::Forms < MerbAdmin::Application
24
24
  }.merge(options)
25
25
  @instances = @model.all(options).reverse
26
26
  else
27
+ if params[:query]
28
+ condition_statement = []
29
+ conditions = []
30
+ @properties.each do |property|
31
+ next unless property.primitive.to_s == "String"
32
+ condition_statement << "#{property.field} LIKE ?"
33
+ conditions << "%#{params[:query]}%"
34
+ end
35
+ conditions.unshift(condition_statement.join(" OR "))
36
+ options.merge!(:conditions => conditions) unless conditions == [""]
37
+ end
27
38
  # monkey patch pagination
28
39
  @model.class_eval("is_paginated") unless @model.respond_to?(:paginated)
29
40
  @current_page = (params[:page] || 1).to_i
@@ -32,7 +43,10 @@ class MerbAdmin::Forms < MerbAdmin::Application
32
43
  :per_page => 100,
33
44
  }.merge(options)
34
45
  @page_count, @instances = @model.paginated(options)
46
+ options.delete(:page)
47
+ options.delete(:per_page)
35
48
  end
49
+ @record_count = @model.count(options)
36
50
  render(:layout => "list")
37
51
  end
38
52
 
@@ -1,3 +1,4 @@
1
+ <% params = request.params.except(:action, :controller, :model_name) %>
1
2
  <div id="content-main">
2
3
  <ul class="object-tools">
3
4
  <li>
@@ -5,9 +6,26 @@
5
6
  </li>
6
7
  </ul>
7
8
  <div class="module filtered" id="changelist">
9
+ <div id="toolbar">
10
+ <form id="changelist-search" action="" method="get">
11
+ <div>
12
+ <label for="searchbar"><img src="<%= image_path("icon_searchbox.png") %>" alt="Search" /></label>
13
+ <input type="text" size="40" name="query" value="" id="searchbar" />
14
+ <input type="submit" value="Search" />
15
+ <% if params[:query] || params[:filter] %>
16
+ <span class="small quiet"><%= @record_count %> <%= @record_count == 1 ? "result" : "results" %> (<a href="?"><%= @model.count %> total</a>)</span>
17
+ <% end %>
18
+ <% if params[:filter] %>
19
+ <% params[:filter].each do |name, value| %>
20
+ <input type="hidden" name="filter[<%= name %>]" value="<%= value %>"/>
21
+ <% end %>
22
+ <% end %>
23
+ </div>
24
+ </form>
25
+ </div>
26
+ <script type="text/javascript">document.getElementById("searchbar").focus();</script>
8
27
  <div id="changelist-filter">
9
28
  <h2>Filter</h2>
10
- <% params = request.params.except(:action, :controller, :model_name) %>
11
29
  <% @properties.each do |property| %>
12
30
  <% if property.primitive.to_s == "TrueClass" %>
13
31
  <h3>By <%= property.field.gsub('_', ' ') %></h3>
@@ -87,13 +105,13 @@
87
105
  </tbody>
88
106
  </table>
89
107
  <p class="paginator">
90
- <% if @page_count.to_i > 1 %>
91
- <%= paginate(@current_page, @page_count, :url => slice_url(:admin_list, :model_name => @model_name.snake_case)) %>
92
- <% end %>
93
- <%= @model.count %> <%= @model.count == 1 ? @model_name.snake_case.gsub('_', ' ') : @model_name.snake_case.gsub('_', ' ').pluralize %>
94
- <% if @page_count.to_i == 2 %>
95
- <%= link_to("Show all", slice_url(:admin_list, :model_name => @model_name.snake_case, :all => true), :class => "showall") %>
96
- <% end %>
108
+ <% if @page_count.to_i > 1 %>
109
+ <%= paginate(@current_page, @page_count, :url => '?' + Merb::Parse.params_to_query_string(params)) %>
110
+ <% end %>
111
+ <%= @record_count %> <%= @record_count == 1 ? @model_name.snake_case.gsub('_', ' ') : @model_name.snake_case.gsub('_', ' ').pluralize %>
112
+ <% if @page_count.to_i == 2 %>
113
+ <%= link_to("Show all", '?' + Merb::Parse.params_to_query_string(params.merge(:all => true)), :class => "showall") %>
114
+ <% end %>
97
115
  </p>
98
116
  </div>
99
117
  </div>
data/lib/merb-admin.rb CHANGED
@@ -22,7 +22,7 @@ if defined?(Merb::Plugins)
22
22
 
23
23
  # Slice metadata
24
24
  self.description = "MerbAdmin is a merb slice that uses your DataMapper models to provide an easy-to-use, Django-style interface for content managers."
25
- self.version = "0.1.8"
25
+ self.version = "0.1.9"
26
26
  self.author = "Erik Michaels-Ober"
27
27
 
28
28
  # Stub classes loaded hook - runs before LoadClasses BootLoader
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sferik-merb-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-08 00:00:00 -07:00
12
+ date: 2009-08-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency