effective_resources 2.27.5 → 2.27.6
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5d1215502182180e421e398c91cf2db53fd898a11a0f92572d4cef5c9344f8c
|
4
|
+
data.tar.gz: 95de990e4c79f44ae632b67429f2076cf4692e1d079cd6c3024a02aec391d520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c734af97def1731a3a80f16b20b2f6bc29706abfafcdeabe27de48f6baa73ce0e3be00f1747425ffa43fb06b12279bb5db084c529dfc4ea21cdd7305effced67
|
7
|
+
data.tar.gz: 7b7fdf7a8042b88ea4d93e7282e87ff402be1c93492d0d5e2a622fa91ca60847a29346e5ddcca436d0c1774ac48b4e45f5c98fc78dda60c5d514f7fcdeabbcf3
|
@@ -2,8 +2,12 @@ module Effective
|
|
2
2
|
module Select2AjaxController
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
def
|
6
|
-
|
5
|
+
def respond_with_select2_ajax_array(collection, skip_search: true, skip_authorize: true, skip_scope: true, skip_paginate: true, skip_relation: true, &block)
|
6
|
+
respond_with_select2_ajax(collection, skip_search: skip_search, skip_authorize: skip_authorize, skip_scope: skip_scope, skip_paginate: skip_paginate, skip_relation: skip_relation, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def respond_with_select2_ajax(collection, skip_search: false, skip_authorize: false, skip_scope: false, skip_paginate: false, skip_relation: false, &block)
|
10
|
+
raise('collection should be an ActiveRecord::Relation or Array') unless collection.kind_of?(ActiveRecord::Relation) || skip_relation
|
7
11
|
|
8
12
|
# Authorize
|
9
13
|
EffectiveResources.authorize!(self, :index, collection.klass) unless skip_authorize
|
@@ -27,13 +31,15 @@ module Effective
|
|
27
31
|
end
|
28
32
|
|
29
33
|
# Paginate
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
if !skip_paginate
|
35
|
+
per_page = 50
|
36
|
+
page = (params[:page] || 1).to_i
|
37
|
+
last = (collection.reselect(:id).count.to_f / per_page).ceil
|
38
|
+
more = page < last
|
39
|
+
|
40
|
+
offset = [(page - 1), 0].max * per_page
|
41
|
+
collection = collection.limit(per_page).offset(offset)
|
42
|
+
end
|
37
43
|
|
38
44
|
# Results
|
39
45
|
results = collection.map do |resource|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.27.
|
4
|
+
version: 2.27.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|