ocean-rails 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocean/ocean_application_controller.rb +12 -4
- data/lib/ocean/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee568551ab7cc1568b5a5f42ed9fb178059f454e
|
4
|
+
data.tar.gz: 8bcdd5311573411e7de5a5be71b7749a560c0986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d8ad03e2440314d32da75347424f88519f576190d269dd5157b0e0365f62a891231afe15962dee612e1682e562cf0eb3850a3bc5dcc1bd1257b06bfa96840c6
|
7
|
+
data.tar.gz: 511d8a48333a4b1309031a1e82c290b31fed9f2c35b2608a407e26c081cd170ad1eeec3ba6cf173bbb496db5fafd2322b20a12ab7b55ee1cfd61f6433fa86ed8
|
@@ -178,6 +178,10 @@ module OceanApplicationController
|
|
178
178
|
locals: {m.class.model_name.i18n_key => m}) }
|
179
179
|
count = resources.count
|
180
180
|
total_count = x.unscope(:limit, :offset).count
|
181
|
+
# page = nil
|
182
|
+
# page_size = nil
|
183
|
+
# prev_page = nil
|
184
|
+
# next_page = nil
|
181
185
|
attrs = {count: count,
|
182
186
|
total_count: total_count
|
183
187
|
}
|
@@ -187,7 +191,8 @@ module OceanApplicationController
|
|
187
191
|
if params[:page]
|
188
192
|
page = params[:page].to_i
|
189
193
|
page_size = params[:page_size].to_i || x.collection_page_size
|
190
|
-
|
194
|
+
total_pages = (total_count.to_f / page_size.to_f).ceil
|
195
|
+
last_page = total_pages - 1
|
191
196
|
prev_page = page > 0 && page - 1
|
192
197
|
next_page = page != last_page && page + 1
|
193
198
|
links['first_page'] = {href: url_for(params.merge(page: 0)), type: 'application/json'}
|
@@ -196,9 +201,12 @@ module OceanApplicationController
|
|
196
201
|
links['next_page'] = {href: url_for(params.merge(page: next_page)), type: 'application/json'} if next_page
|
197
202
|
end
|
198
203
|
end
|
199
|
-
|
200
|
-
|
201
|
-
|
204
|
+
|
205
|
+
attrs['_links'] = links if links
|
206
|
+
attrs['page'] = page if page
|
207
|
+
attrs['page_size'] = page_size if page_size
|
208
|
+
attrs['total_pages'] = total_pages if total_pages
|
209
|
+
|
202
210
|
render text: '{"_collection":{"resources":[' + resources.join(',') + ']' +
|
203
211
|
(attrs.collect do |k, v|
|
204
212
|
',"' + k.to_s + '":' + v.to_json
|
data/lib/ocean/version.rb
CHANGED