bmc 1.3.1 → 1.3.4

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: dc16d49ff09c9a3ebd6f1404ecd8eed011333e58842f67824adf17897d681f58
4
- data.tar.gz: 743ab9c8a8fc353bb0758c6071d53e181231f60796c20fe986ff2d5b16a55d9e
3
+ metadata.gz: 36427ac2fef1204c03e2312f26c86ae44adb70e06db9eee946b4ed492981465d
4
+ data.tar.gz: a3d8968195b88c1c01672ac01e77a49580afafced26ec4934447645041b305da
5
5
  SHA512:
6
- metadata.gz: 7ccc820fbfaf071b33d7bb7ee3e735651491594d4413ab4b0d09fe9bc0cbc2f12e36a4c00ab5676c022615d5b7032d46d9b75bddb4297c0b454ac9775d7da2f1
7
- data.tar.gz: 3fbf31cfe70e3762536559e1ed79ecdb970987234712c0e67b20739d39d2da54325ec2fd99656ab500e5323f032002c287f2388e11fbe9443157124756f0fdfc
6
+ metadata.gz: cc1d839ab3c11269332e6bfdd21cbd8ecfa08dd32f5e24e8fdba58de35bab82160d06ca8ff1ea59a3c257511f108dcfaf5deb44e6cd865dad482d33efdffd30d
7
+ data.tar.gz: 0dcc1dd8dbc696d9dd52aa584322e64d6dd627b00c1b463f0e6c3b3b131173c6368dd48897207c2609c73281f5ff056a93b5272ec11f47cb889ce32cf0065dff
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## v1.3.4
6
+ - Add `all` support to filters `ByKeyValue` and `ByKeyValues`
7
+
8
+ ## v1.3.3
9
+ - Add `only:` support to `hidden_inputs_for_get_form` helper
10
+
11
+ ## v1.3.2
12
+ - Add `bs_button_to` helper
13
+
5
14
  ## v1.3.1
6
15
  - Add sorter helpers
7
16
 
@@ -7,6 +7,8 @@ class BMC::Filter::ByKeyValue
7
7
  end
8
8
 
9
9
  def apply(query, value)
10
+ return query if value == "all"
11
+
10
12
  value = true if value == "true"
11
13
  value = false if value == "false"
12
14
 
@@ -2,6 +2,9 @@ class BMC::Filter::ByKeyValues < BMC::Filter::ByKeyValue
2
2
  def apply(query, value)
3
3
  value = value.split if value.is_a?(String)
4
4
  value = value.select(&:present?)
5
+
6
+ return query if value == ["all"]
7
+
5
8
  column = column_for(query)
6
9
 
7
10
  if value.any?
@@ -22,6 +22,7 @@ module BMC::ButtonHelper
22
22
  btn_size: BMC::ButtonHelper.default_size,
23
23
  btn_style: BMC::ButtonHelper.default_style,
24
24
  add_class: [],
25
+ helper: :link_to,
25
26
  **options
26
27
  )
27
28
  text = ta(action) if text.nil? && action
@@ -50,7 +51,11 @@ module BMC::ButtonHelper
50
51
  options.deep_merge!(data: {confirm: confirm})
51
52
  end
52
53
 
53
- link_to(content, url, options.sort.to_h)
54
+ public_send(helper, content, url, options.sort.to_h)
55
+ end
56
+
57
+ def bs_button_to(url, **options)
58
+ bs_button(url, helper: :button_to, **options)
54
59
  end
55
60
 
56
61
  def new_button(url = url_for(action: :new), **options)
@@ -5,17 +5,17 @@ module BMC::FormHelper
5
5
  # Does not work if display:none
6
6
  def form_hidden_submit
7
7
  css = "position:absolute;top:-9999px;left:-9999px;opacity:0;height:0;width:0;visibility: hidden"
8
- tag(:input, type: "submit", class: "hidden-submit", style: css)
8
+ tag.input(type: "submit", class: "hidden-submit", style: css)
9
9
  end
10
10
 
11
11
  def search_form(action: request.fullpath)
12
12
  render "bmc/search/form", action: action
13
13
  end
14
14
 
15
- def hidden_inputs_for_get_form(url, except: [])
16
- query_values = Addressable::URI.parse(url).query_values.to_h
17
- .with_indifferent_access
18
- .except(*except)
15
+ def hidden_inputs_for_get_form(url, except: nil, only: nil)
16
+ query_values = Addressable::URI.parse(url).query_values.to_h.with_indifferent_access
17
+ query_values.except!(*except) if except
18
+ query_values.select! { only.map(&:to_sym).include?(_1.to_sym) } if only
19
19
 
20
20
  return if query_values.empty?
21
21
 
@@ -8,7 +8,7 @@ class BMC::MiniModelSerializer::Serialize
8
8
 
9
9
  def call
10
10
  if object.is_a?(Hash)
11
- object.map { |k, v| [k.to_s, serialize(v)] }.to_h
11
+ object.to_h { |k, v| [k.to_s, serialize(v)] }
12
12
  elsif object.is_a?(Enumerable)
13
13
  object.map { |e| serialize(e) }
14
14
  elsif (serializer = "#{object.class}Serializer".safe_constantize)
@@ -4,7 +4,7 @@ class BMC::MiniModelSerializer::Serializer < BMC::MiniModelSerializer::Serialize
4
4
  end
5
5
 
6
6
  def call
7
- serialize attributes.map { |k| [k, send(k)] }.to_h
7
+ serialize(attributes.index_with { |k| send(k) })
8
8
  end
9
9
 
10
10
  private
@@ -11,9 +11,7 @@ class BMC::Serializers::XLSX < BMC::Serializers::Base
11
11
  end
12
12
 
13
13
  def render_file(file_path)
14
- File.open(file_path, "w+b") do |f|
15
- f.write(render_inline)
16
- end
14
+ File.binwrite(file_path, render_inline)
17
15
  end
18
16
 
19
17
  private
@@ -25,14 +23,14 @@ class BMC::Serializers::XLSX < BMC::Serializers::Base
25
23
  end
26
24
 
27
25
  def date_range_styles(row)
28
- row.each_index.select { row[_1].is_a?(Date) }.map do
29
- {range: {rows: :all, columns: _1}, styles: {format_code: "dd/mm/yyyy"}}
26
+ row.each_index.select { row[_1].is_a?(Date) }.map do |col|
27
+ {range: {rows: :all, columns: col}, styles: {format_code: "dd/mm/yyyy"}}
30
28
  end
31
29
  end
32
30
 
33
31
  def time_range_styles(row)
34
- row.each_index.select { row[_1].is_a?(Time) }.map do
35
- {range: {rows: :all, columns: _1}, styles: {format_code: "dd/mm/yyyy hh:mm:ss"}}
32
+ row.each_index.select { row[_1].is_a?(Time) }.map do |col|
33
+ {range: {rows: :all, columns: col}, styles: {format_code: "dd/mm/yyyy hh:mm:ss"}}
36
34
  end
37
35
  end
38
36
  end
@@ -17,7 +17,5 @@ module BMC::ActiveModelCustomErrorMessages
17
17
  end
18
18
  end
19
19
 
20
- if Module.const_defined?("ActiveModel::Error")
21
- ActiveModel::Error.prepend(ForError)
22
- end
20
+ ActiveModel::Error.prepend(ForError)
23
21
  end
data/lib/bmc/config.rb CHANGED
@@ -5,7 +5,7 @@ class << BMC
5
5
  @parent_controller ||= [
6
6
  "ApplicationController",
7
7
  "ActionController::Base",
8
- ].map(&:safe_constantize).compact.first
8
+ ].filter_map(&:safe_constantize).first
9
9
  end
10
10
 
11
11
  attr_writer :parent_job
@@ -14,7 +14,7 @@ class << BMC
14
14
  @parent_job ||= [
15
15
  "ApplicationJob",
16
16
  "ActiveJob::Base",
17
- ].map(&:safe_constantize).compact.first
17
+ ].filter_map(&:safe_constantize).first
18
18
  end
19
19
 
20
20
  attr_writer :parent_mailer
@@ -23,6 +23,6 @@ class << BMC
23
23
  @parent_mailer ||= [
24
24
  "ApplicationMailer",
25
25
  "ActionMailer::Base",
26
- ].map(&:safe_constantize).compact.first
26
+ ].filter_map(&:safe_constantize).first
27
27
  end
28
28
  end
@@ -1,6 +1,6 @@
1
1
  module BMC::FormBackUrl
2
2
  def back_url_tag
3
- tag(:input,
3
+ tag.input(
4
4
  :type => "hidden",
5
5
  :name => "back_url",
6
6
  :value => (params[:back_url].presence || request.referer),
data/lib/bmc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BMC
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.4"
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.3.1
4
+ version: 1.3.4
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: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n