bmc 1.4.3 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0e0c4e5ab78a01fd7654084f301d4f5b1a742d63c5db56868933d9fd2f7089f
4
- data.tar.gz: 717ee2dcc037bb32ef59e290ed6ff3505e567e4c2ae8a90e7cb7ef1ef19714fa
3
+ metadata.gz: 4b45ace9fe342248cb63e77ac701779ed69c5d6bf05ff3f0b0e2b23a7b46665b
4
+ data.tar.gz: 057b8aacdcd98a348b54276233b0a5ffc353580e79256c4d05c700c402779d55
5
5
  SHA512:
6
- metadata.gz: 12c39ca13cca306fb378fedf40993aa1dc689bf64f3f9707704a5b13f4afaa9028c145d6ae30baba97443460a57ca74c84cf30550c21186afe6aa9ec55ae177a
7
- data.tar.gz: c0ad050d9893e63177e464c1fb70de88d178b89acef88ab1db2dafa5b7a9272772541710cbbc562c4b58d674da076090ba4497c2af35e05dc91e1eb1cb9d7ddd
6
+ metadata.gz: 222d61f28a75cf0699935d6272599737ac4eb9c984b5f6012c8b174f593c2eae007d91a758d1a33f67f23d2bc8b13ceb9009979e45317d758dbd184600db19ff
7
+ data.tar.gz: 6f51eeb1722bf8bc536871700f4e633157e29f100f2677de68fc174cd93e30508511e2087b0aad626de55c7f77789d8d648bf3a982a90ec8a517b426ea763b46
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## v1.5.1
6
+ - Add options to filters and sorters
7
+ - Fix BMC::ButtonHelper configuration
8
+
9
+ ## v1.5.0
10
+ - Use Turbo instead of rails-ujs by default
11
+
5
12
  ## v1.4.3
6
13
  - Rails 7.1
7
14
 
@@ -14,9 +14,9 @@ class BMC::Filter::ByKeyValue
14
14
 
15
15
  column = column_for(query)
16
16
 
17
- if value.to_s.in?(%w(nil null))
17
+ if value.to_s.in?(%w[nil null])
18
18
  query.where("#{column} IS NULL")
19
- elsif value.to_s.in?(%w(not_nil not_null))
19
+ elsif value.to_s.in?(%w[not_nil not_null])
20
20
  query.where("#{column} IS NOT NULL")
21
21
  else
22
22
  query.where("#{column} = ?", value)
@@ -3,10 +3,11 @@ class BMC::Filter
3
3
 
4
4
  STRATEGIES = {}
5
5
 
6
- attr_reader :jar
6
+ attr_reader :jar, :options
7
7
 
8
- def initialize(jar)
8
+ def initialize(jar, options = {})
9
9
  @jar = jar
10
+ @options = options
10
11
  end
11
12
 
12
13
  def strategies
@@ -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
@@ -9,6 +9,14 @@ module BMC::ButtonHelper
9
9
  def default_style
10
10
  @default_style ||= :outline_primary
11
11
  end
12
+
13
+ def confirm_attribute
14
+ @confirm_attribute ||= :"data-turbo-confirm"
15
+ end
16
+
17
+ def method_attribute
18
+ @method_attribute ||= :"data-turbo-method"
19
+ end
12
20
  end
13
21
 
14
22
  def bs_button( # rubocop:disable Metrics/ParameterLists
@@ -30,7 +38,12 @@ module BMC::ButtonHelper
30
38
  content = fa_s(icon).concat(" ").concat(tag.span(text, class: "text"))
31
39
 
32
40
  if method != :get
33
- options[:method] = method
41
+ if helper == :link_to
42
+ options[BMC::ButtonHelper.method_attribute] = method
43
+ options[:rel] = "nofollow"
44
+ elsif helper == :button_to
45
+ options[:method] = method
46
+ end
34
47
  confirm = true if confirm.nil?
35
48
  end
36
49
 
@@ -48,7 +61,7 @@ module BMC::ButtonHelper
48
61
 
49
62
  unless confirm.nil?
50
63
  confirm = ta(:confirm) if confirm == true
51
- options.deep_merge!(data: {confirm: confirm})
64
+ options[BMC::ButtonHelper.confirm_attribute] = confirm
52
65
  end
53
66
 
54
67
  public_send(helper, content, url, options.sort.to_h)
@@ -21,7 +21,7 @@ module BMC::SetupJobConcern
21
21
  end
22
22
 
23
23
  attrs.length.times do |i|
24
- instance_variable_set("@#{attrs[i]}", args[i])
24
+ instance_variable_set(:"@#{attrs[i]}", args[i])
25
25
  end
26
26
  end
27
27
  end
@@ -5,7 +5,7 @@ module BMC::DefaultValuesConcern
5
5
  end
6
6
 
7
7
  def assign_default(attribute, value)
8
- send("#{attribute}=", value) if send(attribute).nil?
8
+ send(:"#{attribute}=", value) if send(attribute).nil?
9
9
  end
10
10
 
11
11
  included do
@@ -1,6 +1,6 @@
1
1
  module BMC::ModelToS
2
2
  def to_s
3
- %w(name title label).map do |m|
3
+ %w[name title label].map do |m|
4
4
  return send(m) if respond_to?(m)
5
5
  end
6
6
 
@@ -20,7 +20,7 @@ module BMC::Search
20
20
  }.join(" OR ")
21
21
  }.map { |e| "(#{e})" }.join(" AND ")
22
22
 
23
- sql_params = words.map.with_index { |word, index| ["w#{index}".to_sym, "%#{word}%"] }.to_h
23
+ sql_params = words.map.with_index { |word, index| [:"w#{index}", "%#{word}%"] }.to_h
24
24
 
25
25
  where(sql_query, sql_params)
26
26
  end # def search
@@ -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 = nil)
11
- @collection = collection
12
- @sort_param = 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
 
@@ -2,9 +2,9 @@ module BMC::ActiveModelTypeCast
2
2
  module Decimal
3
3
  def cast_value(value)
4
4
  if value.is_a?(String)
5
- super value.tr(",", ".").gsub(/[^-0-9.]/, "")
5
+ super(value.tr(",", ".").gsub(/[^-0-9.]/, ""))
6
6
  else
7
- super value
7
+ super(value)
8
8
  end
9
9
  end
10
10
  end
@@ -19,9 +19,9 @@ module BMC::ActiveModelTypeCast
19
19
 
20
20
  def cast_value(value)
21
21
  if sanitizable?(value)
22
- super sanitize(value)
22
+ super(sanitize(value))
23
23
  else
24
- super value
24
+ super(value)
25
25
  end
26
26
  end
27
27
 
@@ -41,7 +41,7 @@ module BMC::ActiveModelTypeCast
41
41
  module Boolean
42
42
  def cast_value(value)
43
43
  value = value.strip if value.is_a?(String)
44
- super value
44
+ super(value)
45
45
  end
46
46
  end
47
47
  end
@@ -3,7 +3,7 @@ module BMC::FormBackUrl
3
3
  tag.input(
4
4
  :type => "hidden",
5
5
  :name => "back_url",
6
- :value => (params[:back_url].presence || request.referer),
6
+ :value => params[:back_url].presence || request.referer,
7
7
  )
8
8
  end
9
9
 
data/lib/bmc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BMC
2
- VERSION = "1.4.3"
2
+ VERSION = "1.5.1"
3
3
  end
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.3
4
+ version: 1.5.1
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: 2023-11-21 00:00:00.000000000 Z
11
+ date: 2024-04-11 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.4.10
233
+ rubygems_version: 3.5.6
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: BMC