bmc 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/app/controllers/bmc/filters_controller.rb +9 -5
- data/app/controllers/concerns/bmc/api_controller_concern.rb +3 -3
- data/app/filters/bmc/filter/by_date.rb +1 -1
- data/app/filters/bmc/filter/by_date_begin.rb +1 -1
- data/app/filters/bmc/filter/by_date_end.rb +1 -1
- data/app/filters/bmc/filter/by_date_or_datetime_period.rb +1 -1
- data/app/filters/bmc/filter/by_key_value.rb +1 -1
- data/app/filters/bmc/filter/by_key_values.rb +1 -1
- data/app/filters/bmc/filter.rb +13 -47
- data/app/helpers/bmc/button_helper.rb +3 -3
- data/app/helpers/bmc/font_awesome_helper.rb +6 -6
- data/app/helpers/bmc/form_helper.rb +1 -1
- data/app/helpers/bmc/link_helper.rb +2 -2
- data/app/helpers/bmc/text_helper.rb +2 -2
- data/app/jobs/concerns/bmc/setup_job_concern.rb +2 -2
- data/app/libs/bmc/mini_model_serializer/serializer.rb +2 -2
- data/app/libs/bmc/token_generator.rb +2 -2
- data/app/models/concerns/bmc/model_i18n.rb +2 -2
- data/app/serializers/bmc/serializers/xlsx.rb +2 -2
- data/app/sms/bmc/sms/strategies/amazon.rb +0 -2
- data/app/sorters/bmc/sorter.rb +5 -4
- data/lib/bmc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 761e510c5a970c4720e50d7cb25193dbd77f1d0181151fbdb9b60fa1df105826
|
4
|
+
data.tar.gz: 0d1564a511deab185e8cfc85816c4dac045ff5420a13ca64a7550fb0fb580688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1217842ff462ceee4909c28bea5a5f42db0ccf6addcc13f54e18fc573e1564795f13eef2c5f8043667cf2ec6fffd7f4836f1e4af32537b5e2b3dc4e2e833c50
|
7
|
+
data.tar.gz: 2d5bca38555fe9c116aa783f05943320e78a86cfecd2502adbce9e8cf4b29b682a5ce04de53359c54ae87f41927cf7eaf6bcf2a9cba08f20a7ca6f368f20aac5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Next version
|
4
4
|
|
5
|
+
## v1.6.0
|
6
|
+
- Filters v2
|
7
|
+
- Ruby min version is 3.3
|
8
|
+
- Rails min version is 7.1
|
9
|
+
|
10
|
+
## v1.5.1
|
11
|
+
- Add options to filters and sorters
|
12
|
+
- Fix BMC::ButtonHelper configuration
|
13
|
+
|
5
14
|
## v1.5.0
|
6
15
|
- Use Turbo instead of rails-ujs by default
|
7
16
|
|
@@ -4,14 +4,18 @@ class BMC::FiltersController < BMC::ApplicationController
|
|
4
4
|
skip_after_action :verify_authorized, raise: false
|
5
5
|
skip_after_action :verify_policy_scoped, raise: false
|
6
6
|
|
7
|
+
def self.parse(json)
|
8
|
+
JSON.parse(json.to_s).with_indifferent_access
|
9
|
+
rescue JSON::ParserError
|
10
|
+
{}.with_indifferent_access
|
11
|
+
end
|
12
|
+
|
7
13
|
def create
|
8
|
-
filters =
|
9
|
-
|
10
|
-
filters.merge new_filters
|
14
|
+
filters = self.class.parse(cookies[:filters])
|
15
|
+
filters.merge! params.fetch(:filters, {}).permit!.to_h
|
11
16
|
|
12
|
-
# Rewrite cookie with 1 year expiry
|
13
17
|
cookies[:filters] = {
|
14
|
-
:value =>
|
18
|
+
:value => JSON.dump(filters),
|
15
19
|
:expires => 1.year.from_now,
|
16
20
|
:path => "/",
|
17
21
|
}
|
@@ -4,12 +4,12 @@ module BMC::ApiControllerConcern
|
|
4
4
|
private
|
5
5
|
|
6
6
|
def render_json(json = {}, options = {})
|
7
|
-
json.reverse_merge!(current_user:
|
8
|
-
options.reverse_merge!(current_user:
|
7
|
+
json.reverse_merge!(current_user:)
|
8
|
+
options.reverse_merge!(current_user:)
|
9
9
|
|
10
10
|
json = BMC::MiniModelSerializer::Serialize.call(json, options)
|
11
11
|
|
12
|
-
render options.merge(json:
|
12
|
+
render options.merge(json:)
|
13
13
|
end
|
14
14
|
|
15
15
|
def render_json_error(any_object, options = {})
|
data/app/filters/bmc/filter.rb
CHANGED
@@ -3,67 +3,43 @@ class BMC::Filter
|
|
3
3
|
|
4
4
|
STRATEGIES = {}
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :values, :options
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(values, options = {})
|
9
|
+
@values = values.with_indifferent_access
|
10
|
+
@options = options
|
10
11
|
end
|
11
12
|
|
12
13
|
def strategies
|
13
14
|
self.class::STRATEGIES.with_indifferent_access
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
+
def call(query)
|
17
18
|
strategies.each do |key, strategy|
|
18
|
-
value =
|
19
|
+
value = values[key]
|
19
20
|
|
20
21
|
next if value.blank?
|
21
22
|
|
22
|
-
query = strategy.
|
23
|
+
query = strategy.call(query, value)
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
+
query
|
26
27
|
end
|
27
28
|
|
28
|
-
def method_missing(method,
|
29
|
-
if
|
30
|
-
|
31
|
-
value = args.first
|
32
|
-
action = :write
|
33
|
-
else
|
34
|
-
key = method.to_s
|
35
|
-
action = :read
|
36
|
-
end
|
37
|
-
|
38
|
-
if strategies.key?(key) && action == :read
|
39
|
-
get(key)
|
40
|
-
elsif strategies.key?(key) && action == :write
|
41
|
-
set(key, value)
|
29
|
+
def method_missing(method, ...)
|
30
|
+
if strategies.key?(method)
|
31
|
+
values[method]
|
42
32
|
else
|
43
33
|
super
|
44
34
|
end
|
45
35
|
end
|
46
36
|
|
47
37
|
def respond_to_missing?(method, include_private = false)
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
def read
|
52
|
-
JSON.parse jar["filters"].to_s
|
53
|
-
rescue JSON::ParserError
|
54
|
-
{}
|
55
|
-
end
|
56
|
-
|
57
|
-
def write(filters)
|
58
|
-
jar["filters"] = filters.to_json
|
59
|
-
end
|
60
|
-
|
61
|
-
def merge(new_filters)
|
62
|
-
write read.merge(new_filters)
|
38
|
+
strategies.key?(method) || super
|
63
39
|
end
|
64
40
|
|
65
41
|
def actives_count
|
66
|
-
|
42
|
+
values.count { |k, v| strategies.key?(k) && v.present? }
|
67
43
|
end
|
68
44
|
|
69
45
|
def any?
|
@@ -73,14 +49,4 @@ class BMC::Filter
|
|
73
49
|
def empty?
|
74
50
|
!any?
|
75
51
|
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def get(key)
|
80
|
-
read[key.to_s]
|
81
|
-
end
|
82
|
-
|
83
|
-
def set(key, value)
|
84
|
-
merge(key.to_s => value)
|
85
|
-
end
|
86
52
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module BMC::ButtonHelper
|
2
2
|
class << self
|
3
|
-
attr_writer :default_size, :default_style
|
3
|
+
attr_writer :default_size, :default_style, :confirm_attribute, :method_attribute
|
4
4
|
|
5
5
|
def default_size
|
6
6
|
@default_size ||= :sm
|
@@ -67,8 +67,8 @@ module BMC::ButtonHelper
|
|
67
67
|
public_send(helper, content, url, options.sort.to_h)
|
68
68
|
end
|
69
69
|
|
70
|
-
def bs_button_to(url, **
|
71
|
-
bs_button(url, helper: :button_to, **
|
70
|
+
def bs_button_to(url, **)
|
71
|
+
bs_button(url, helper: :button_to, **)
|
72
72
|
end
|
73
73
|
|
74
74
|
def new_button(url = url_for(action: :new), **options)
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module BMC::FontAwesomeHelper
|
2
|
-
def fa_s(id, **
|
3
|
-
_bmc_fa_icon(id, fa_style: "fas", **
|
2
|
+
def fa_s(id, **)
|
3
|
+
_bmc_fa_icon(id, fa_style: "fas", **)
|
4
4
|
end
|
5
5
|
|
6
|
-
def fa_r(id, **
|
7
|
-
_bmc_fa_icon(id, fa_style: "far", **
|
6
|
+
def fa_r(id, **)
|
7
|
+
_bmc_fa_icon(id, fa_style: "far", **)
|
8
8
|
end
|
9
9
|
|
10
|
-
def fa_b(id, **
|
11
|
-
_bmc_fa_icon(id, fa_style: "fab", **
|
10
|
+
def fa_b(id, **)
|
11
|
+
_bmc_fa_icon(id, fa_style: "fab", **)
|
12
12
|
end
|
13
13
|
|
14
14
|
def _bmc_fa_icon(id, fa_style: nil, size: nil, spin: false, **options)
|
@@ -9,7 +9,7 @@ module BMC::FormHelper
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def search_form(action: request.fullpath, placeholder: ta(:search))
|
12
|
-
render "bmc/search/form", action
|
12
|
+
render "bmc/search/form", action:, placeholder:
|
13
13
|
end
|
14
14
|
|
15
15
|
def hidden_inputs_for_get_form(url, except: nil, only: nil)
|
@@ -9,9 +9,9 @@ module BMC::LinkHelper
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def icon_link_to(icon, name, options = nil, html_options = nil, &
|
12
|
+
def icon_link_to(icon, name, options = nil, html_options = nil, &)
|
13
13
|
name = fa_s(icon).concat(" ").concat(name)
|
14
|
-
link_to(name, options, html_options, &
|
14
|
+
link_to(name, options, html_options, &)
|
15
15
|
end
|
16
16
|
|
17
17
|
def web_link(text, opts = {})
|
@@ -84,11 +84,11 @@ module BMC::TextHelper
|
|
84
84
|
label: object.t(attribute)
|
85
85
|
)
|
86
86
|
if default == :hide
|
87
|
-
value = fma(object, attribute, value
|
87
|
+
value = fma(object, attribute, value:, helper:)
|
88
88
|
return if value.nil?
|
89
89
|
end
|
90
90
|
|
91
|
-
value = fma(object, attribute, value
|
91
|
+
value = fma(object, attribute, value:, default:, helper:)
|
92
92
|
|
93
93
|
separator = " :<br/>".html_safe if separator == :br
|
94
94
|
klass = object.is_a?(Module) ? object : object.class
|
@@ -1,13 +1,11 @@
|
|
1
1
|
class BMC::SMS::Strategies::Amazon
|
2
2
|
attr_reader :region, :access_key_id, :secret_access_key
|
3
3
|
|
4
|
-
# rubocop:disable Layout/LineLength
|
5
4
|
def initialize(region: nil, access_key_id: nil, secret_access_key: nil)
|
6
5
|
@region = region || ENV["SNS_REGION"] || ENV["AWS_REGION"]
|
7
6
|
@access_key_id = access_key_id || ENV["SNS_ACCESS_KEY_ID"] || ENV["AWS_ACCESS_KEY_ID"]
|
8
7
|
@secret_access_key = secret_access_key || ENV["SNS_SECRET_ACCESS_KEY"] || ENV["AWS_SECRET_ACCESS_KEY"]
|
9
8
|
end
|
10
|
-
# rubocop:enable Layout/LineLength
|
11
9
|
|
12
10
|
def client
|
13
11
|
@client ||= Aws::SNS::Client.new(
|
data/app/sorters/bmc/sorter.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
class BMC::Sorter
|
2
2
|
include BMC::SortingHelper
|
3
3
|
|
4
|
-
attr_reader :collection, :sort_param, :column, :direction
|
4
|
+
attr_reader :collection, :sort_param, :options, :column, :direction
|
5
5
|
|
6
6
|
def self.call(...)
|
7
7
|
new(...).call
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize(collection, sort_param =
|
11
|
-
@collection
|
12
|
-
@sort_param
|
10
|
+
def initialize(collection, sort_param, options = {})
|
11
|
+
@collection = collection
|
12
|
+
@sort_param = sort_param
|
13
|
+
@options = options
|
13
14
|
@column, @direction = sortable_column_order(sort_param.to_s)
|
14
15
|
end
|
15
16
|
|
data/lib/bmc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit MARTIN-CHAVE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
230
|
- !ruby/object:Gem::Version
|
231
231
|
version: '0'
|
232
232
|
requirements: []
|
233
|
-
rubygems_version: 3.5.
|
233
|
+
rubygems_version: 3.5.11
|
234
234
|
signing_key:
|
235
235
|
specification_version: 4
|
236
236
|
summary: BMC
|