simple_admin 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ module SimpleAdmin
20
20
  @collection = @interface.constant
21
21
  @collection = @collection.order("#{@interface.constant.table_name}.#{$1} #{$2}") if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
22
22
  @collection = @collection.metasearch(clean_search_params(params))
23
- @collection = @collection.page(params[:page]).per(@per_page || SimpleAdmin.default_per_page) if params[:format].blank? || params[:format] == 'html'
23
+ @collection = @collection.page(params[:page]).per(params[:per_page] || SimpleAdmin.default_per_page) if params[:format].blank? || params[:format] == 'html'
24
24
  respond_with(@collection)
25
25
  end
26
26
 
@@ -108,7 +108,7 @@ module SimpleAdmin
108
108
  search_params = search_params.dup
109
109
  search_params.delete_if do |key, value|
110
110
  value == "" ||
111
- ["utf8", "scope", "commit", "action", "order", "interface", "controller", "format", "page"].include?(key)
111
+ ["utf8", "scope", "commit", "action", "order", "interface", "controller", "format", "page", "per_page"].include?(key)
112
112
  end
113
113
  search_params
114
114
  end
@@ -6,7 +6,9 @@ module SimpleAdmin
6
6
  options[:as] ||= default_filter_type(klass, method)
7
7
  return "" unless options[:as]
8
8
  field_type = options.delete(:as)
9
- content_tag :div, :class => "filter_form_field filter_#{field_type}" do
9
+ wrapper_options = options[:wrapper_html] || {}
10
+ wrapper_options[:class] = (wrapper_options[:class] || "") + " filter_form_field filter_#{field_type}"
11
+ content_tag :div, wrapper_options do
10
12
  send("filter_#{field_type}_input", klass, method, options)
11
13
  end
12
14
  end
@@ -14,7 +16,7 @@ module SimpleAdmin
14
16
  def filter_string_input(klass, method, options = {})
15
17
  field_name = "#{method}_contains"
16
18
 
17
- [ label(field_name, "Search #{method.to_s.titlecase}"),
19
+ [ label(field_name, options[:title] || "Search #{method.to_s.titlecase}"),
18
20
  text_field_tag(field_name, params[field_name] || '')
19
21
  ].join("\n").html_safe
20
22
  end
@@ -23,7 +25,7 @@ module SimpleAdmin
23
25
  gt_field_name = "#{method}_gte"
24
26
  lt_field_name = "#{method}_lte"
25
27
 
26
- [ label(gt_field_name, method.to_s.titlecase),
28
+ [ label(gt_field_name, options[:title] || method.to_s.titlecase),
27
29
  filter_date_text_field(klass, gt_field_name),
28
30
  " - ",
29
31
  filter_date_text_field(klass, lt_field_name)
@@ -41,7 +43,7 @@ module SimpleAdmin
41
43
  filter_select = select_tag '', options_for_select(filters, current_filter), :onchange => "document.getElementById('#{method}_numeric').name = '' + this.value + '';"
42
44
  filter_input = text_field_tag(current_filter, params[current_filter] || '', :size => 10, :id => "#{method}_numeric")
43
45
 
44
- [ label_tag(method), filter_select, " ", filter_input].join("\n").html_safe
46
+ [ label_tag(method, options[:title]), filter_select, " ", filter_input].join("\n").html_safe
45
47
  end
46
48
 
47
49
  def numeric_filters_for_method(method, filters)
@@ -71,7 +73,7 @@ module SimpleAdmin
71
73
  end
72
74
  input_name = (input_name.to_s + "_eq").to_sym
73
75
  collection = find_collection_for_column(klass, association_name, options)
74
- [ label(input_name, method.to_s.titlecase),
76
+ [ label(input_name, options[:title] || method.to_s.titlecase),
75
77
  select_tag(input_name, options_for_select(collection, params[input_name]), :include_blank => options[:include_blank] || 'Any')
76
78
  ].join("\n").html_safe
77
79
  end
@@ -122,7 +124,7 @@ module SimpleAdmin
122
124
  end.join("\n").html_safe
123
125
  end
124
126
 
125
- [ label(input_name, method.to_s.titlecase),
127
+ [ label(input_name, options[:title] || method.to_s.titlecase),
126
128
  checkboxes
127
129
  ].join("\n").html_safe
128
130
  end
@@ -2,9 +2,7 @@
2
2
  <head>
3
3
  <meta content="text/html; charset=utf-8" http-equiv="Content-type"/>
4
4
  <title><%= title %></title>
5
- <%- if protect_against_forgery? -%>
6
- <meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" />
7
- <%- end -%>
5
+ <%= csrf_meta_tags %>
8
6
  <%= simple_admin_stylesheet_link_tag SimpleAdmin.stylesheet %>
9
7
  <%= simple_admin_javascript_include_tag SimpleAdmin.javascript %>
10
8
  </head>
@@ -3,7 +3,7 @@
3
3
  <fieldset class="inputs">
4
4
  <ol>
5
5
  <% @interface.attributes_for(:form).each do |col| %>
6
- <%= form.input col.attribute %>
6
+ <%= form.input col.attribute, col.options %>
7
7
  <% end %>
8
8
  </ol>
9
9
  </fieldset>
@@ -70,7 +70,7 @@
70
70
  <% end %>
71
71
  <div class="buttons">
72
72
  <input name="commit" type="submit" value="Filter" />
73
- <a href="#" class="clear_filters_btn">Clear Filters</a>
73
+ <a href="?" class="clear_filters_btn">Clear Filters</a>
74
74
  <input id="order" name="order" type="hidden" value="id_desc" />
75
75
  <input id="scope" name="scope" type="hidden" />
76
76
  </div>
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  SimpleAdmin::Engine.routes.draw do
2
+ root :to => "admin#index", :interface => SimpleAdmin::registered.first.try(:collection)
2
3
  SimpleAdmin::registered.each do |interface|
3
4
  resources interface.collection,
4
5
  :controller => :admin,
@@ -25,7 +25,7 @@ module SimpleAdmin
25
25
 
26
26
  def before(options={}, &block)
27
27
  options[:data] = block
28
- options[:actions] = options[:actions] || [:index, :show, :edit, :new, :delete, :create, :update]
28
+ options[:actions] = options[:actions] || [:index, :show, :edit, :new, :destroy, :create, :update]
29
29
  options[:actions] -= options[:except] if options[:except]
30
30
  options[:actions] &= options[:only] if options[:only]
31
31
  @interface.before << options
@@ -39,7 +39,7 @@ module SimpleAdmin
39
39
  end
40
40
 
41
41
  def actions
42
- arr = @options[:actions] || [:index, :show, :edit, :new, :delete, :create, :update]
42
+ arr = @options[:actions] || [:index, :show, :edit, :new, :destroy, :create, :update]
43
43
  arr -= @options[:except] if @options[:except]
44
44
  arr &= @options[:only] if @options[:only]
45
45
  arr
@@ -1,3 +1,3 @@
1
1
  module SimpleAdmin
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -84,7 +84,7 @@ describe SimpleAdmin::Interface do
84
84
 
85
85
  it "defaults to allowing all actions" do
86
86
  @interface = SimpleAdmin.register(:things)
87
- @interface.actions.should == [:index, :show, :edit, :new, :delete, :create, :update]
87
+ @interface.actions.should == [:index, :show, :edit, :new, :destroy, :create, :update]
88
88
  end
89
89
 
90
90
  it "allows overrides to the default set of actions" do
@@ -93,7 +93,7 @@ describe SimpleAdmin::Interface do
93
93
  end
94
94
 
95
95
  it "excludes actions from the default set of actions" do
96
- @interface = SimpleAdmin.register(:things, :except => [:delete])
96
+ @interface = SimpleAdmin.register(:things, :except => [:destroy])
97
97
  @interface.actions.should == [:index, :show, :edit, :new, :create, :update]
98
98
  end
99
99
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_admin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jeff Rafter
@@ -15,24 +14,20 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-06-29 00:00:00 -04:00
17
+ date: 2011-08-10 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rails
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 15424109
30
27
  segments:
31
28
  - 3
32
29
  - 1
33
- - 0
34
- - rc
35
- - 4
30
+ - 0rc4
36
31
  version: 3.1.0rc4
37
32
  type: :runtime
38
33
  version_requirements: *id001
@@ -40,11 +35,9 @@ dependencies:
40
35
  name: kaminari
41
36
  prerelease: false
42
37
  requirement: &id002 !ruby/object:Gem::Requirement
43
- none: false
44
38
  requirements:
45
39
  - - ">="
46
40
  - !ruby/object:Gem::Version
47
- hash: 3
48
41
  segments:
49
42
  - 0
50
43
  version: "0"
@@ -54,11 +47,9 @@ dependencies:
54
47
  name: meta_search
55
48
  prerelease: false
56
49
  requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
50
  requirements:
59
51
  - - ">="
60
52
  - !ruby/object:Gem::Version
61
- hash: 961915996
62
53
  segments:
63
54
  - 1
64
55
  - 1
@@ -71,11 +62,9 @@ dependencies:
71
62
  name: rspec
72
63
  prerelease: false
73
64
  requirement: &id004 !ruby/object:Gem::Requirement
74
- none: false
75
65
  requirements:
76
66
  - - ">="
77
67
  - !ruby/object:Gem::Version
78
- hash: 23
79
68
  segments:
80
69
  - 2
81
70
  - 6
@@ -87,11 +76,9 @@ dependencies:
87
76
  name: rspec-rails
88
77
  prerelease: false
89
78
  requirement: &id005 !ruby/object:Gem::Requirement
90
- none: false
91
79
  requirements:
92
80
  - - ">="
93
81
  - !ruby/object:Gem::Version
94
- hash: 23
95
82
  segments:
96
83
  - 2
97
84
  - 6
@@ -103,11 +90,9 @@ dependencies:
103
90
  name: shoulda
104
91
  prerelease: false
105
92
  requirement: &id006 !ruby/object:Gem::Requirement
106
- none: false
107
93
  requirements:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- hash: 3
111
96
  segments:
112
97
  - 0
113
98
  version: "0"
@@ -117,11 +102,9 @@ dependencies:
117
102
  name: factory_girl
118
103
  prerelease: false
119
104
  requirement: &id007 !ruby/object:Gem::Requirement
120
- none: false
121
105
  requirements:
122
106
  - - ">="
123
107
  - !ruby/object:Gem::Version
124
- hash: 3
125
108
  segments:
126
109
  - 0
127
110
  version: "0"
@@ -131,11 +114,9 @@ dependencies:
131
114
  name: mocha
132
115
  prerelease: false
133
116
  requirement: &id008 !ruby/object:Gem::Requirement
134
- none: false
135
117
  requirements:
136
118
  - - ">"
137
119
  - !ruby/object:Gem::Version
138
- hash: 3
139
120
  segments:
140
121
  - 0
141
122
  version: "0"
@@ -145,11 +126,9 @@ dependencies:
145
126
  name: capybara
146
127
  prerelease: false
147
128
  requirement: &id009 !ruby/object:Gem::Requirement
148
- none: false
149
129
  requirements:
150
130
  - - ">="
151
131
  - !ruby/object:Gem::Version
152
- hash: 15
153
132
  segments:
154
133
  - 0
155
134
  - 4
@@ -161,11 +140,9 @@ dependencies:
161
140
  name: sqlite3-ruby
162
141
  prerelease: false
163
142
  requirement: &id010 !ruby/object:Gem::Requirement
164
- none: false
165
143
  requirements:
166
144
  - - ">="
167
145
  - !ruby/object:Gem::Version
168
- hash: 3
169
146
  segments:
170
147
  - 0
171
148
  version: "0"
@@ -250,27 +227,23 @@ rdoc_options: []
250
227
  require_paths:
251
228
  - lib
252
229
  required_ruby_version: !ruby/object:Gem::Requirement
253
- none: false
254
230
  requirements:
255
231
  - - ">="
256
232
  - !ruby/object:Gem::Version
257
- hash: 3
258
233
  segments:
259
234
  - 0
260
235
  version: "0"
261
236
  required_rubygems_version: !ruby/object:Gem::Requirement
262
- none: false
263
237
  requirements:
264
238
  - - ">="
265
239
  - !ruby/object:Gem::Version
266
- hash: 3
267
240
  segments:
268
241
  - 0
269
242
  version: "0"
270
243
  requirements: []
271
244
 
272
245
  rubyforge_project: simple_admin
273
- rubygems_version: 1.4.1
246
+ rubygems_version: 1.3.6
274
247
  signing_key:
275
248
  specification_version: 3
276
249
  summary: Simple administrative interfaces for data in your rails application