caboose-cms 0.4.98 → 0.4.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/models/caboose/page_bar_generator.rb +36 -8
- data/lib/caboose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGExNDQyODU4OTg2YmNhMDQyNDNlMThiYWIyOTY0NjAxMjU2MzkyNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjcwZThhMzJmNjkwNWM5NGIyN2U2MjIwOTAzN2ZjNDYyYmZkNTc0OA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmQ0MWYxNzQ0Zjc5NjE3Yzk2Y2JhMTZjNDFjYmI4YTA5MTJlNWRmODY2Zjgz
|
10
|
+
NmFmYzViMDMwOWMyZGE5MWIxZTNkZjdiMmRhNjJhZjA3ZWNmZWQ3YmQ5ODI2
|
11
|
+
ZmFkMjI5ZWQ2ZDk2MWNmOTk4YjkyYjczZjIyMjMyOTVhZWFiYWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmI2MzlhMzM0ZTJmYTgxMWMwMjIwNjVmZDY1ZDBlMjIwNjQ5YmJhNDJlOWZl
|
14
|
+
YmI0ZWExOGVjYTdmNDVjOTc3NjhiYTU4NGI5MjQ0NzJiYzJmOGZiYjFjMzI5
|
15
|
+
YjdkYjVkMzllNDUxOTE4Mzg5Y2Y4M2I2OGMxNzFjMTI0MjI3ZDE=
|
@@ -21,7 +21,7 @@ module Caboose
|
|
21
21
|
# itemsPerPage: Number of items you want to show per page. Defaults to 10 if not present.
|
22
22
|
# page: Current page number. Defaults to 0 if not present.
|
23
23
|
#
|
24
|
-
attr_accessor :original_params, :params, :options, :custom_url_vars
|
24
|
+
attr_accessor :original_params, :params, :options, :custom_url_vars, :post_get
|
25
25
|
|
26
26
|
#def initialize(post_get, params = nil, options = nil, &custom_url_vars = nil)
|
27
27
|
def initialize(post_get, params = nil, options = nil)
|
@@ -31,6 +31,7 @@ module Caboose
|
|
31
31
|
|
32
32
|
# Note: a few keys are required:
|
33
33
|
# base_url, page, itemCount, itemsPerPage
|
34
|
+
@post_get = post_get
|
34
35
|
@original_params = {}
|
35
36
|
@params = {}
|
36
37
|
@options = {
|
@@ -83,7 +84,10 @@ module Caboose
|
|
83
84
|
end
|
84
85
|
|
85
86
|
def set_item_count
|
86
|
-
|
87
|
+
m = model_with_includes.where(self.where)
|
88
|
+
n = self.near
|
89
|
+
m = m.near(n[0], n[1]) if n
|
90
|
+
@options['item_count'] = m.count
|
87
91
|
end
|
88
92
|
|
89
93
|
def model_with_includes
|
@@ -146,21 +150,29 @@ module Caboose
|
|
146
150
|
end
|
147
151
|
|
148
152
|
def items
|
149
|
-
|
153
|
+
assoc = model_with_includes.where(self.where)
|
154
|
+
n = self.near
|
155
|
+
assoc = assoc.near(n[0], n[1]) if n
|
150
156
|
if @options['items_per_page'] != -1
|
151
|
-
assoc = assoc.limit(limit).offset(offset)
|
157
|
+
assoc = assoc.limit(self.limit).offset(self.offset)
|
152
158
|
end
|
153
|
-
return assoc.reorder(reorder).all
|
159
|
+
return assoc.reorder(self.reorder).all
|
154
160
|
end
|
155
161
|
|
156
162
|
def all_items
|
157
|
-
|
163
|
+
m = model_with_includes.where(self.where)
|
164
|
+
n = self.near
|
165
|
+
m = m.near(n[0], n[1]) if n
|
166
|
+
return m.all
|
158
167
|
end
|
159
168
|
|
160
169
|
def item_values(attribute)
|
161
170
|
arr = []
|
162
|
-
model_with_includes.where(where)
|
163
|
-
|
171
|
+
m = model_with_includes.where(self.where)
|
172
|
+
n = self.near
|
173
|
+
m = m.near(n[0], n[1]) if n
|
174
|
+
m.all.each do |m2|
|
175
|
+
arr << m2[attribute]
|
164
176
|
end
|
165
177
|
return arr.uniq
|
166
178
|
end
|
@@ -305,6 +317,7 @@ module Caboose
|
|
305
317
|
table = @options['model'].constantize.table_name
|
306
318
|
@params.each do |k,v|
|
307
319
|
next if v.nil? || (v.kind_of?(String) && v.length == 0)
|
320
|
+
next if k.ends_with?('_near')
|
308
321
|
|
309
322
|
col = nil
|
310
323
|
if @options['includes'] && @options['includes'].include?(k)
|
@@ -396,6 +409,21 @@ module Caboose
|
|
396
409
|
return sql
|
397
410
|
end
|
398
411
|
|
412
|
+
def near
|
413
|
+
@params.each do |k,v|
|
414
|
+
next if !k.ends_with?('_near')
|
415
|
+
arr = k.split('_')
|
416
|
+
if arr.length == 3
|
417
|
+
location = @post_get[arr[0]]
|
418
|
+
radius = @post_get[arr[1]]
|
419
|
+
v = [location, radius] if location && radius && location.strip.length > 0 && radius.strip.length > 0
|
420
|
+
end
|
421
|
+
next if v.nil? || !v.is_a?(Array) || v.count != 2
|
422
|
+
return v
|
423
|
+
end
|
424
|
+
return nil
|
425
|
+
end
|
426
|
+
|
399
427
|
def limit
|
400
428
|
return @options['items_per_page'].to_i
|
401
429
|
end
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.99
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|