effective_resources 2.25.5 → 2.25.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/crud_controller/actions.rb +2 -1
- data/app/controllers/concerns/effective/select2_ajax_controller.rb +10 -0
- data/app/helpers/effective_resources_helper.rb +12 -0
- data/app/models/concerns/acts_as_published.rb +6 -2
- data/app/models/concerns/effective_devise_user.rb +4 -0
- data/lib/effective_resources/version.rb +1 -1
- data/lib/effective_resources.rb +4 -0
- 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: de01adb32f1387ff84cc11ad3fbc0859446e955bd293b147fc3901c685236ec0
|
4
|
+
data.tar.gz: fc867fc6b73847530e5a7d631a08809328fa31550c6171fed4d5bf4d7d520ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac5ac456612f209116686abf18121ae62f5b5be8dcb7cf2d87e54a169f6bd645e76058bcf8c4a7b862bc2647cc982ed810bd1039e49649084e3da82e69bcb4aa
|
7
|
+
data.tar.gz: 961fc638312d8da54e755b93665546ec247b46ead0b7bbb8399031b693ca4e249c4f1666cbd7c53cee207bf5fc8f03763c9627fa0f8d0c808d1013f0493d3cea
|
@@ -42,7 +42,8 @@ module Effective
|
|
42
42
|
|
43
43
|
# Duplicate if possible
|
44
44
|
if params[:duplicate_id].present?
|
45
|
-
duplicate = resource_scope.find(params[:duplicate_id])
|
45
|
+
duplicate = (resource_scope.find(params[:duplicate_id]) rescue false)
|
46
|
+
duplicate ||= resource_scope.find_by_id(params[:duplicate_id])
|
46
47
|
|
47
48
|
EffectiveResources.authorize!(self, :show, duplicate)
|
48
49
|
|
@@ -56,6 +56,16 @@ module Effective
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
+
def to_masked_select2(resource)
|
60
|
+
if resource.respond_to?(:public_email)
|
61
|
+
"<span>#{resource}</span> <small>#{view_context.masked_email(resource)}</small>"
|
62
|
+
elsif resource.try(:email).present?
|
63
|
+
"<span>#{resource}</span> <small>#{resource.email}</small>"
|
64
|
+
else
|
65
|
+
"<span>#{resource}</span>"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
59
69
|
def to_select2(resource)
|
60
70
|
if resource.try(:email).present?
|
61
71
|
"<span>#{resource}</span> <small>#{resource.email}</small>"
|
@@ -323,6 +323,18 @@ module EffectiveResourcesHelper
|
|
323
323
|
EffectiveResources.etsd(resource, attribute)
|
324
324
|
end
|
325
325
|
|
326
|
+
def masked_email(resource)
|
327
|
+
public_email = resource.try(:public_email)
|
328
|
+
return public_email if public_email.present?
|
326
329
|
|
330
|
+
email = resource.email
|
331
|
+
return email if email.blank?
|
332
|
+
|
333
|
+
local, domain = email.split('@')
|
334
|
+
masked_local = local[0..1] + '*' * (local.length - 2)
|
335
|
+
masked_domain = domain.split('.').first[0..1] + '*' * (domain.split('.').first.length - 2) + '.' + domain.split('.').last
|
336
|
+
|
337
|
+
"#{masked_local}@#{masked_domain}"
|
338
|
+
end
|
327
339
|
|
328
340
|
end
|
@@ -22,8 +22,12 @@ module ActsAsPublished
|
|
22
22
|
included do
|
23
23
|
attr_writer :save_as_draft
|
24
24
|
|
25
|
-
before_validation do
|
26
|
-
|
25
|
+
before_validation(if: -> { EffectiveResources.falsey?(@save_as_draft) && @save_as_draft.present? }) do
|
26
|
+
self.published_start_at ||= Time.zone.now
|
27
|
+
end
|
28
|
+
|
29
|
+
before_validation(if: -> { EffectiveResources.truthy?(@save_as_draft) }) do
|
30
|
+
assign_attributes(published_start_at: nil, published_end_at: nil)
|
27
31
|
end
|
28
32
|
|
29
33
|
validate(if: -> { published_start_at.present? && published_end_at.present? }) do
|
data/lib/effective_resources.rb
CHANGED
@@ -127,6 +127,10 @@ module EffectiveResources
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
+
def self.falsey?(value)
|
131
|
+
!truthy?(value)
|
132
|
+
end
|
133
|
+
|
130
134
|
def self.advance_date(date, business_days: 1, holidays: [:us, :observed])
|
131
135
|
raise('business_days must be an integer <= 365') unless business_days.kind_of?(Integer) && business_days <= 365
|
132
136
|
|
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.25.
|
4
|
+
version: 2.25.7
|
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: 2024-07-
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|