upmin-admin 0.1.0 → 0.1.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/Rakefile +40 -4
- data/app/controllers/upmin/models_controller.rb +1 -1
- data/app/views/kaminari/_first_page.html.haml +3 -0
- data/app/views/kaminari/_gap.html.haml +2 -0
- data/app/views/kaminari/_last_page.html.haml +3 -0
- data/app/views/kaminari/_next_page.html.haml +3 -0
- data/app/views/kaminari/_page.html.haml +2 -0
- data/app/views/kaminari/_paginator.html.haml +11 -0
- data/app/views/kaminari/_prev_page.html.haml +3 -0
- data/lib/upmin/configuration.rb +13 -0
- data/lib/upmin/engine.rb +2 -0
- data/lib/upmin/model.rb +27 -15
- data/lib/upmin/railties/paginator.rb +1 -0
- data/lib/upmin/railties/render_helpers.rb +3 -0
- data/lib/upmin/version.rb +1 -1
- data/spec/features/search_spec.rb +28 -4
- data/spec/lib/configuration_spec.rb +13 -0
- data/spec/spec_helper.rb +5 -5
- metadata +9 -5
- data/app/assets/images/upmin/logo_large.png +0 -0
- data/app/assets/images/upmin/logo_small.png +0 -0
- data/lib/tasks/accordive_rails_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 910d8396eb70b53feb5a498af6acc41edb1e3d1e
|
4
|
+
data.tar.gz: 6e2d7366490c0dfb137a503a02fd6784111714c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aea3404252228d686ed20f0a480e7d32898c70ef6edc895b387272bc14cfdb82bf6e06f8044fa15360fcf3ddc3dea147b6429c3cd6997460dff5d785e153e01
|
7
|
+
data.tar.gz: bdb283f1c155465a8f94be4b5d290d21ff0c2883c9536323850b809a5e3a0223df65c2d3212f44bb073c89bd587c3b192e1d49f9ded56fe327a6dbdafc815df8
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Upmin Admin
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/upmin-admin.svg)](http://badge.fury.io/rb/upmin-admin)
|
4
|
+
|
5
|
+
Upmin Admin is a framework for creating powerful Ruby on Rails admin backends with minimal effort.
|
6
|
+
Upmin currently supports Rails 3.2, 4.0, 4.1 & 4.2.
|
4
7
|
|
5
8
|
|
6
9
|
## Demo Videos
|
@@ -59,7 +62,7 @@ For further documentation, please visit our [Wiki](https://github.com/upmin/upmi
|
|
59
62
|
|
60
63
|
## Going Forward
|
61
64
|
|
62
|
-
Upmin Admin is new. It has been live for less than a few months, so there are going to be things missing. If you want to make it better, get involved and [create issues](https://github.com/upmin/upmin-admin-ruby/issues) when you find bugs or want new features, and contribute with pull requests.
|
65
|
+
Upmin Admin is new. It has been live for less than a few months, so there are going to be things missing. If you want to make it better, get involved and [create issues](https://github.com/upmin/upmin-admin-ruby/issues) when you find bugs or want new features, and [contribute](https://github.com/upmin/upmin-admin-ruby/blob/master/CONTRIBUTING.md) with pull requests.
|
63
66
|
|
64
67
|
The major features that are being worked on now are:
|
65
68
|
|
data/Rakefile
CHANGED
@@ -13,12 +13,17 @@ end
|
|
13
13
|
|
14
14
|
task :default => "spec:all"
|
15
15
|
|
16
|
-
def update_files
|
17
|
-
|
16
|
+
def update_files(gemfile = nil)
|
17
|
+
# Drop and reload spec files
|
18
18
|
sh "rm -rf spec/"
|
19
19
|
sh "cp -R ../../spec spec"
|
20
20
|
sh "cp ../../.rspec .rspec"
|
21
21
|
|
22
|
+
# Copy gemfile specific specs if they exist
|
23
|
+
if Dir.exists?("../../spec_#{gemfile}")
|
24
|
+
sh "cp -R ../../spec_#{gemfile} spec/#{gemfile}"
|
25
|
+
end
|
26
|
+
|
22
27
|
# Drop and reload Upmin::Model files
|
23
28
|
sh "rm -rf app/upmin/"
|
24
29
|
sh "cp -R ../../test_app_upmin app/upmin"
|
@@ -69,16 +74,47 @@ namespace :spec do
|
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
77
|
+
desc "Run Tests with namespaced models"
|
78
|
+
task :namespaced_model do
|
79
|
+
Dir.chdir("test_apps/namespaced_model")
|
80
|
+
puts "Testing in #{`pwd`}"
|
81
|
+
sh "bundle install --quiet"
|
82
|
+
sh "bundle update --quiet"
|
83
|
+
|
84
|
+
# Drop migrations and recreate
|
85
|
+
sh "rm -rf db/migrate/*.test_models.rb"
|
86
|
+
sh "bundle exec rake railties:install:migrations > /dev/null"
|
87
|
+
|
88
|
+
sh "RAILS_ENV=test bundle exec rake db:drop db:create db:migrate db:seed --quiet > /dev/null"
|
89
|
+
|
90
|
+
update_files("namespaced_model")
|
91
|
+
|
92
|
+
# Run tests
|
93
|
+
sh "bundle exec rake"
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
desc "Run Tests with namespaced models quickly (no bundle install etc)"
|
98
|
+
task :namespaced_model_quick do
|
99
|
+
Dir.chdir("test_apps/namespaced_model")
|
100
|
+
puts "Re-Testing in #{`pwd`}. Bundle install and migration updates will NOT happen!"
|
101
|
+
|
102
|
+
update_files("namespaced_model")
|
103
|
+
|
104
|
+
# Run tests
|
105
|
+
sh "bundle exec rake"
|
106
|
+
end
|
107
|
+
|
72
108
|
desc "Run Tests against all ORMs"
|
73
109
|
task :all do
|
74
|
-
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper).each do |gemfile|
|
110
|
+
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper namespaced_model).each do |gemfile|
|
75
111
|
sh "rake spec:#{gemfile}"
|
76
112
|
end
|
77
113
|
end
|
78
114
|
|
79
115
|
desc "Run Tests against all ORMs"
|
80
116
|
task :all_quick do
|
81
|
-
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper).each do |gemfile|
|
117
|
+
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper namespaced_model).each do |gemfile|
|
82
118
|
sh "rake spec:#{gemfile}_quick"
|
83
119
|
end
|
84
120
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
= paginator.render do
|
2
|
+
%ul.pagination
|
3
|
+
= first_page_tag unless current_page.first?
|
4
|
+
= prev_page_tag unless current_page.first?
|
5
|
+
- each_page do |page|
|
6
|
+
- if page.left_outer? || page.right_outer? || page.inside_window?
|
7
|
+
= page_tag page
|
8
|
+
- elsif !page.was_truncated?
|
9
|
+
= gap_tag
|
10
|
+
= next_page_tag unless current_page.last?
|
11
|
+
= last_page_tag unless current_page.last?
|
data/lib/upmin/configuration.rb
CHANGED
@@ -45,6 +45,19 @@ module Upmin
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def items_per_page=(items)
|
49
|
+
@custom_items_per_page = true
|
50
|
+
@items_per_page = items
|
51
|
+
end
|
52
|
+
|
53
|
+
def items_per_page
|
54
|
+
if defined?(@custom_items_per_page)
|
55
|
+
return @items_per_page
|
56
|
+
else
|
57
|
+
return 30
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
48
61
|
private
|
49
62
|
|
50
63
|
def default_models
|
data/lib/upmin/engine.rb
CHANGED
data/lib/upmin/model.rb
CHANGED
@@ -96,8 +96,6 @@ module Upmin
|
|
96
96
|
end
|
97
97
|
|
98
98
|
|
99
|
-
|
100
|
-
|
101
99
|
###########################################################
|
102
100
|
### Class methods
|
103
101
|
###########################################################
|
@@ -112,10 +110,23 @@ module Upmin
|
|
112
110
|
|
113
111
|
def Model.find_or_create_class(model_name)
|
114
112
|
::Rails.application.eager_load!
|
115
|
-
|
113
|
+
|
114
|
+
create_name = model_name.gsub(":", "")
|
115
|
+
return "Admin#{create_name}".constantize
|
116
116
|
rescue NameError
|
117
|
-
|
118
|
-
|
117
|
+
if model_name.match(/::/)
|
118
|
+
class_str = <<-class_string
|
119
|
+
class ::Admin#{create_name} < Upmin::Model
|
120
|
+
def self.model_class
|
121
|
+
return #{model_name}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
class_string
|
125
|
+
eval(class_str)
|
126
|
+
else
|
127
|
+
eval("class ::Admin#{create_name} < Upmin::Model; end")
|
128
|
+
end
|
129
|
+
return "Admin#{create_name}".constantize
|
119
130
|
end
|
120
131
|
|
121
132
|
# Returns all upmin models.
|
@@ -127,10 +138,6 @@ module Upmin
|
|
127
138
|
return all
|
128
139
|
end
|
129
140
|
|
130
|
-
def Model.model_class
|
131
|
-
@model_class ||= inferred_model_class
|
132
|
-
end
|
133
|
-
|
134
141
|
def Model.model_class?
|
135
142
|
return model_class
|
136
143
|
rescue Upmin::UninferrableSourceError
|
@@ -142,24 +149,28 @@ module Upmin
|
|
142
149
|
end
|
143
150
|
|
144
151
|
def Model.inferred_model_class
|
145
|
-
name =
|
152
|
+
name = inferred_model_class_name
|
146
153
|
return name.constantize
|
147
154
|
rescue NameError => error
|
148
155
|
raise if name && !error.missing_name?(name)
|
149
156
|
raise Upmin::UninferrableSourceError.new(self)
|
150
157
|
end
|
151
158
|
|
152
|
-
def Model.
|
159
|
+
def Model.inferred_model_class_name
|
153
160
|
raise NameError if name.nil? || name.demodulize !~ /Admin.+$/
|
154
161
|
return name.demodulize[5..-1]
|
155
162
|
end
|
156
163
|
|
164
|
+
def Model.model_class_name
|
165
|
+
return model_class.name
|
166
|
+
end
|
167
|
+
|
157
168
|
def Model.model_name
|
158
169
|
return ActiveModel::Name.new(model_class)
|
159
170
|
end
|
160
171
|
|
161
172
|
def Model.humanized_name(type = :plural)
|
162
|
-
names = model_class_name.split(/(?=[A-Z])/)
|
173
|
+
names = model_class_name.split(/(?=[A-Z])/).map{|n| n.gsub(":", "")}
|
163
174
|
if type == :plural
|
164
175
|
names[names.length-1] = names.last.pluralize
|
165
176
|
end
|
@@ -202,10 +213,9 @@ module Upmin
|
|
202
213
|
return @color_index
|
203
214
|
end
|
204
215
|
|
205
|
-
|
206
216
|
def Model.active_record?
|
207
217
|
if defined?(ActiveRecord)
|
208
|
-
return model_class
|
218
|
+
return (model_class < ::ActiveRecord::Base) == true
|
209
219
|
else
|
210
220
|
return false
|
211
221
|
end
|
@@ -220,7 +230,6 @@ module Upmin
|
|
220
230
|
end
|
221
231
|
|
222
232
|
|
223
|
-
|
224
233
|
###########################################################
|
225
234
|
### Customization methods for Admin<Model> classes
|
226
235
|
###########################################################
|
@@ -273,6 +282,9 @@ module Upmin
|
|
273
282
|
return @actions
|
274
283
|
end
|
275
284
|
|
285
|
+
def Model.items_per_page(items = Upmin.configuration.items_per_page)
|
286
|
+
return @items_per_page ||= items
|
287
|
+
end
|
276
288
|
|
277
289
|
|
278
290
|
###########################################################
|
@@ -4,6 +4,7 @@ module Upmin::Railties
|
|
4
4
|
|
5
5
|
def up_paginate(scope, options = {}, &block)
|
6
6
|
if defined?(WillPaginate)
|
7
|
+
options[:renderer] = BootstrapPagination::Rails if defined?(BootstrapPagination::Rails)
|
7
8
|
return will_paginate(scope, options)
|
8
9
|
else # Use Kaminari
|
9
10
|
return paginate(scope, options, &block)
|
@@ -180,9 +180,12 @@ module Upmin::Railties
|
|
180
180
|
def RenderHelpers.search_box_partials(klass, options = {})
|
181
181
|
partials = []
|
182
182
|
# <options[:as]>
|
183
|
+
# <model_name>_search_box, eg: order_search_box
|
183
184
|
# ransack_search_box
|
185
|
+
model_name = klass.underscore_name
|
184
186
|
|
185
187
|
partials << build_search_box_path(options[:as]) if options[:as]
|
188
|
+
partials << build_search_box_path("#{model_name}_search_box")
|
186
189
|
partials << build_search_box_path(:ransack_search_box)
|
187
190
|
return partials
|
188
191
|
end
|
data/lib/upmin/version.rb
CHANGED
@@ -15,7 +15,7 @@ feature("Search Views") do
|
|
15
15
|
|
16
16
|
# Make sure some basic pagination exits
|
17
17
|
within(".pagination:first-of-type") do
|
18
|
-
within(".current") do
|
18
|
+
within(".active, .current") do
|
19
19
|
expect(page).to(have_content("1"))
|
20
20
|
end
|
21
21
|
|
@@ -24,7 +24,7 @@ feature("Search Views") do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
within(".pagination:nth-of-type(2)") do
|
27
|
-
within(".current") do
|
27
|
+
within(".active, .current") do
|
28
28
|
expect(page).to(have_content("2"))
|
29
29
|
end
|
30
30
|
|
@@ -35,14 +35,14 @@ feature("Search Views") do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
within(".pagination:last-of-type") do
|
38
|
-
within(".current") do
|
38
|
+
within(".active, .current") do
|
39
39
|
expect(page).to(have_content("3"))
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
scenario("Search via integer") do
|
45
|
-
visit("/upmin/m/
|
45
|
+
visit("/upmin/m/User")
|
46
46
|
|
47
47
|
expect(page).to(have_selector("a.search-result-link", count: 30))
|
48
48
|
|
@@ -77,4 +77,28 @@ feature("Search Views") do
|
|
77
77
|
expect(page).to(have_content(expected_user.name))
|
78
78
|
end
|
79
79
|
|
80
|
+
scenario("config.items_per_page") do
|
81
|
+
Upmin.configuration.items_per_page = 25
|
82
|
+
|
83
|
+
visit("/upmin/m/Order")
|
84
|
+
|
85
|
+
# Global config of 25 should override default of 30
|
86
|
+
expect(page).to(have_selector("a.search-result-link", count: 25))
|
87
|
+
|
88
|
+
# Reset this.
|
89
|
+
Upmin.configuration = Upmin::Configuration.new
|
90
|
+
end
|
91
|
+
|
92
|
+
scenario("Model items_per_page with config.items_per_page") do
|
93
|
+
Upmin.configuration.items_per_page = 25
|
94
|
+
|
95
|
+
visit("/upmin/m/Shipment")
|
96
|
+
|
97
|
+
# `items_per_page 20` in the model should override global config of 25
|
98
|
+
expect(page).to(have_selector("a.search-result-link", count: 20))
|
99
|
+
|
100
|
+
# Reset this.
|
101
|
+
Upmin.configuration = Upmin::Configuration.new
|
102
|
+
end
|
103
|
+
|
80
104
|
end
|
@@ -57,4 +57,17 @@ describe Upmin::Configuration do
|
|
57
57
|
|
58
58
|
end
|
59
59
|
|
60
|
+
describe "#items_per_page" do
|
61
|
+
|
62
|
+
context "default items_per_page" do
|
63
|
+
it { expect(@config.items_per_page).to(eq(30)) }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "custom items_per_page" do
|
67
|
+
before(:each) { @config.items_per_page = 10 }
|
68
|
+
it { expect(@config.items_per_page).to(eq(10)) }
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
60
73
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -46,11 +46,11 @@ RSpec.configure do |config|
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Uncomment this if you want to the page to be saved and opened after any test failure.
|
49
|
-
config.after do |example|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
49
|
+
# config.after do |example|
|
50
|
+
# if example.metadata[:type] == :feature && example.exception.present?
|
51
|
+
# save_and_open_page
|
52
|
+
# end
|
53
|
+
# end
|
54
54
|
|
55
55
|
config.include(FactoryGirl::Syntax::Methods)
|
56
56
|
config.include(ActionView::Helpers::NumberHelper, type: :view)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upmin-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.01
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Calhoun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -174,8 +174,6 @@ extra_rdoc_files: []
|
|
174
174
|
files:
|
175
175
|
- README.md
|
176
176
|
- Rakefile
|
177
|
-
- app/assets/images/upmin/logo_large.png
|
178
|
-
- app/assets/images/upmin/logo_small.png
|
179
177
|
- app/assets/javascripts/upmin/application.js
|
180
178
|
- app/assets/javascripts/upmin/attributes/datetime.js
|
181
179
|
- app/assets/javascripts/upmin/helpers.js
|
@@ -196,6 +194,13 @@ files:
|
|
196
194
|
- app/controllers/upmin/models_controller.rb
|
197
195
|
- app/helpers/upmin/application_helper.rb
|
198
196
|
- app/helpers/upmin/models_helper.rb
|
197
|
+
- app/views/kaminari/_first_page.html.haml
|
198
|
+
- app/views/kaminari/_gap.html.haml
|
199
|
+
- app/views/kaminari/_last_page.html.haml
|
200
|
+
- app/views/kaminari/_next_page.html.haml
|
201
|
+
- app/views/kaminari/_page.html.haml
|
202
|
+
- app/views/kaminari/_paginator.html.haml
|
203
|
+
- app/views/kaminari/_prev_page.html.haml
|
199
204
|
- app/views/layouts/upmin/_navbar.html.haml
|
200
205
|
- app/views/layouts/upmin/application.html.haml
|
201
206
|
- app/views/upmin/models/dashboard.html.haml
|
@@ -221,7 +226,6 @@ files:
|
|
221
226
|
- app/views/upmin/partials/search_boxes/_ransack_search_box.html.haml
|
222
227
|
- app/views/upmin/partials/search_results/_results.html.haml
|
223
228
|
- config/routes.rb
|
224
|
-
- lib/tasks/accordive_rails_tasks.rake
|
225
229
|
- lib/tasks/upmin_tasks.rake
|
226
230
|
- lib/upmin.rb
|
227
231
|
- lib/upmin/action.rb
|
Binary file
|
Binary file
|