effective_resources 1.9.9 → 1.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_resources_private_helper.rb +3 -5
- data/app/models/concerns/effective_devise_user.rb +1 -3
- data/app/models/effective/resources/actions.rb +1 -3
- data/app/models/effective/resources/associations.rb +2 -1
- data/app/models/effective/resources/attributes.rb +2 -0
- data/app/models/effective/resources/controller.rb +1 -1
- data/app/models/effective/resources/forms.rb +6 -2
- data/app/models/effective/resources/generator.rb +1 -1
- data/app/models/effective/resources/init.rb +1 -1
- data/app/models/effective/resources/instance.rb +2 -0
- data/app/models/effective/resources/klass.rb +2 -0
- data/app/models/effective/resources/model.rb +2 -4
- data/app/models/effective/resources/naming.rb +2 -0
- data/app/models/effective/resources/relation.rb +12 -2
- data/app/models/effective/resources/sql.rb +11 -9
- data/app/models/effective/resources/tenants.rb +2 -4
- data/lib/effective_resources/version.rb +1 -1
- data/lib/effective_resources.rb +1 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed166aa8aeaf93b66de29429230623cad83d1b55f61b550f0b6e028d619c7362
|
4
|
+
data.tar.gz: 2843fd945c1c9dde784387b7db0d8b38187542f54aeaadee71876a1933c2c46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144e3041a712292e4a7becf6ff9e71c4092c50bff7ebbb06d13fc8f14f92c3ff9a1dcf3aaf20f4c5e5b06a1b6d52745930ab3fe877c88ca5f4c8c9d6a8ee16e3
|
7
|
+
data.tar.gz: e69d047183677c0176e6ffd941983a73bedf40040e49d413f1ea738766193eb686b52bfdb0063c7ca2f1bd637b753264708a99d41d254479689d2c52cc042fcf
|
@@ -1,11 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module EffectiveResourcesPrivateHelper
|
4
4
|
REPLACE_PAGE_ACTIONS = {'update' => :edit, 'create' => :new}
|
5
5
|
BLACKLIST = [:default, :only, :except, :if, :unless, :redirect, :success, :danger, :klass]
|
6
6
|
|
7
|
-
DATA_CONFIRM = 'data-confirm'
|
8
|
-
|
9
7
|
def permitted_resource_actions(resource, actions)
|
10
8
|
page_action = REPLACE_PAGE_ACTIONS[params[:action]] || params[:action].try(:to_sym) || :save
|
11
9
|
executor = Effective::ResourceExec.new(self, resource)
|
@@ -38,8 +36,8 @@ module EffectiveResourcesPrivateHelper
|
|
38
36
|
end
|
39
37
|
|
40
38
|
# Replace resource name in any token strings
|
41
|
-
if opts[
|
42
|
-
opts[
|
39
|
+
if opts['data-confirm'].present? && opts['data-confirm'].include?('@resource'.freeze)
|
40
|
+
opts['data-confirm'] = opts['data-confirm'].gsub('@resource'.freeze, resource_to_s)
|
43
41
|
end
|
44
42
|
|
45
43
|
# Assign class
|
@@ -160,9 +160,7 @@ module EffectiveDeviseUser
|
|
160
160
|
args.last[:tenant] ||= tenant
|
161
161
|
end
|
162
162
|
|
163
|
-
|
164
|
-
|
165
|
-
devise_mailer.send(notification, self, *args).deliver_later(wait: wait)
|
163
|
+
devise_mailer.send(notification, self, *args).deliver_now
|
166
164
|
end
|
167
165
|
|
168
166
|
end
|
@@ -14,9 +14,7 @@ module Effective
|
|
14
14
|
|
15
15
|
def route_engines
|
16
16
|
if tenant? && Tenant.current.present?
|
17
|
-
[Rails.application, Tenant.Engine] + Rails::Engine.subclasses.reverse
|
18
|
-
tenant_engines_blacklist.any? { |name| klass.name.start_with?(name) }
|
19
|
-
end
|
17
|
+
[Rails.application, Tenant.Engine] + (Rails::Engine.subclasses.reverse - Tenant.route_engines)
|
20
18
|
else
|
21
19
|
[Rails.application] + Rails::Engine.subclasses.reverse
|
22
20
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Effective
|
4
4
|
module Resources
|
@@ -21,7 +21,11 @@ module Effective
|
|
21
21
|
collection ||= (klass.const_get(constant_pluralized) rescue nil) if defined?("#{klass.name}::#{constant_pluralized}")
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
if collection.present?
|
25
|
+
{ as: :select, polymorphic: true, collection: (collection || []) }
|
26
|
+
else
|
27
|
+
{ as: :string }
|
28
|
+
end
|
25
29
|
when :has_and_belongs_to_many
|
26
30
|
{ as: :select }.merge(search_form_field_collection(has_and_belongs_to_many(name)))
|
27
31
|
when :has_many
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Effective
|
2
4
|
module Resources
|
3
5
|
module Relation
|
@@ -96,8 +98,16 @@ module Effective
|
|
96
98
|
elsif name == :user # Polymorphic user
|
97
99
|
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
98
100
|
else # Maybe from a string field
|
99
|
-
|
100
|
-
|
101
|
+
collection = relation.none
|
102
|
+
|
103
|
+
relation.distinct("#{name}_type").pluck("#{name}_type").each do |klass_name|
|
104
|
+
resource = Effective::Resource.new(klass_name)
|
105
|
+
next unless resource.klass.present?
|
106
|
+
|
107
|
+
collection = collection.or(relation.where("#{name}_id": resource.search_any(term), "#{name}_type": klass_name))
|
108
|
+
end
|
109
|
+
|
110
|
+
collection
|
101
111
|
end
|
102
112
|
when :has_and_belongs_to_many, :has_many, :has_one
|
103
113
|
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
@@ -1,10 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Effective
|
2
4
|
module Resources
|
3
5
|
module Sql
|
4
|
-
|
5
6
|
def column(name)
|
6
7
|
name = name.to_s
|
7
|
-
|
8
|
+
bt = belongs_to(name)
|
9
|
+
|
10
|
+
columns.find { |col| col.name == name || (bt && col.name == bt.foreign_key) }
|
8
11
|
end
|
9
12
|
|
10
13
|
def columns
|
@@ -32,17 +35,18 @@ module Effective
|
|
32
35
|
end
|
33
36
|
|
34
37
|
def sql_direction(name)
|
35
|
-
name.to_s.downcase == 'desc' ? 'DESC'
|
38
|
+
name.to_s.downcase == 'desc' ? 'DESC' : 'ASC'
|
36
39
|
end
|
37
40
|
|
38
41
|
# This is for EffectiveDatatables (col as:)
|
39
42
|
# Might be :name, or 'users.name'
|
40
43
|
def sql_type(name)
|
41
|
-
name = name.
|
44
|
+
name = (name.kind_of?(String) ? name.split('.').first : name.to_s)
|
42
45
|
|
43
46
|
return :belongs_to if belongs_to(name)
|
44
47
|
|
45
|
-
|
48
|
+
# Skip using columns() cause we dont need to check for belongs_to
|
49
|
+
column = columns.find { |col| col.name == name }
|
46
50
|
|
47
51
|
if column.present?
|
48
52
|
column.type
|
@@ -105,13 +109,11 @@ module Effective
|
|
105
109
|
end
|
106
110
|
|
107
111
|
def postgres?
|
108
|
-
|
109
|
-
@postgres ||= (klass.connection.kind_of?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) rescue false)
|
112
|
+
klass.connection.adapter_name == 'PostgreSQL'
|
110
113
|
end
|
111
114
|
|
112
115
|
def mysql?
|
113
|
-
|
114
|
-
@mysql ||= (klass.connection.kind_of?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) rescue false)
|
116
|
+
klass.connection.adapter_name == 'MySQL'
|
115
117
|
end
|
116
118
|
|
117
119
|
def is_null(sql_column)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Effective
|
2
4
|
module Resources
|
3
5
|
module Tenants
|
@@ -15,10 +17,6 @@ module Effective
|
|
15
17
|
name if Rails.application.config.tenants[name].present?
|
16
18
|
end
|
17
19
|
|
18
|
-
def tenant_engines_blacklist
|
19
|
-
return [] unless tenant?
|
20
|
-
Rails.application.config.tenants.map { |name, _| name.to_s.classify }
|
21
|
-
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
data/lib/effective_resources.rb
CHANGED
@@ -52,11 +52,7 @@ module EffectiveResources
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.transaction(resource = nil, &block)
|
55
|
-
connection =
|
56
|
-
connection ||= (resource.class if resource.class.respond_to?(:transaction))
|
57
|
-
connection ||= '::ApplicationRecord'.safe_constantize
|
58
|
-
connection ||= 'ActiveRecord::Base'.safe_constantize
|
59
|
-
|
55
|
+
connection = 'ActiveRecord::Base'.safe_constantize
|
60
56
|
raise('unable to determine transaction class') unless connection.present?
|
61
57
|
|
62
58
|
connection.transaction { yield }
|
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: 1.9.
|
4
|
+
version: 1.9.13
|
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: 2021-12-
|
11
|
+
date: 2021-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|