bmc 1.2.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/app/helpers/bmc/button_helper.rb +7 -2
- data/app/helpers/bmc/font_awesome_helper.rb +14 -53
- data/app/helpers/bmc/link_helper.rb +1 -1
- data/app/helpers/bmc/text_helper.rb +2 -2
- data/app/sorters/bmc/sorter.rb +22 -0
- data/app/views/bmc/search/_form_bs3.html.slim +2 -2
- data/app/views/bmc/search/_form_bs4.html.slim +2 -2
- data/app/views/bmc/search/_form_bs5.html.slim +2 -2
- 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: 660ccd7de1adf652c91f76ddc091f158c1b844d1a5a2a1006ca801c91a54ab79
|
4
|
+
data.tar.gz: 7786e6fd7de7161c0fbd9cb61b1f8200f9e48d65c59296cad7cde39234bb0bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 714fafade0b2d5fcb2ab9689445c9e327075107ccd5397bdf218ad85108af4e05aa0dd484ff7d68d932d833ce29f3b68b6cf21b27913a61de3c9ee3f54f802d4
|
7
|
+
data.tar.gz: 599dde15b80d1e30103de30e33e0070aa9c3023845d33303d464d6a2967a9c43b9abccd2a11d5a20de965879ee6d459905d3c2a6eac6b4b9773fdd3260aba65b
|
data/CHANGELOG.md
CHANGED
@@ -22,11 +22,12 @@ 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
|
28
29
|
|
29
|
-
content =
|
30
|
+
content = fa_s(icon).concat(" ").concat(tag.span(text, class: "text"))
|
30
31
|
|
31
32
|
if method != :get
|
32
33
|
options[:method] = method
|
@@ -50,7 +51,11 @@ module BMC::ButtonHelper
|
|
50
51
|
options.deep_merge!(data: {confirm: confirm})
|
51
52
|
end
|
52
53
|
|
53
|
-
|
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)
|
@@ -1,15 +1,23 @@
|
|
1
1
|
module BMC::FontAwesomeHelper
|
2
|
-
def
|
3
|
-
id
|
2
|
+
def fa_s(id, **options)
|
3
|
+
_bmc_fa_icon(id, fa_style: "fas", **options)
|
4
|
+
end
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def fa_r(id, **options)
|
7
|
+
_bmc_fa_icon(id, fa_style: "far", **options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def fa_b(id, **options)
|
11
|
+
_bmc_fa_icon(id, fa_style: "fab", **options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def _bmc_fa_icon(id, fa_style: nil, size: nil, spin: false, **options)
|
15
|
+
id = id.to_s.tr("_", "-").to_sym
|
8
16
|
|
9
17
|
css_classes = options.delete(:class).to_s.split
|
10
18
|
css_classes << "icon"
|
11
19
|
css_classes << "fa-#{id}"
|
12
|
-
css_classes <<
|
20
|
+
css_classes << fa_style
|
13
21
|
css_classes << "fa-#{size}" if size
|
14
22
|
css_classes << "fa-spin" if spin
|
15
23
|
|
@@ -17,51 +25,4 @@ module BMC::FontAwesomeHelper
|
|
17
25
|
|
18
26
|
tag.span(**attributes)
|
19
27
|
end
|
20
|
-
|
21
|
-
class << self
|
22
|
-
def database
|
23
|
-
@database ||= YAML.safe_load(database_yml).deep_symbolize_keys
|
24
|
-
end
|
25
|
-
|
26
|
-
def database_path
|
27
|
-
Rails.root.join("tmp", "fa_database_#{version}.yml")
|
28
|
-
end
|
29
|
-
|
30
|
-
def database_yml
|
31
|
-
download_database! unless File.size?(database_path)
|
32
|
-
File.read(database_path)
|
33
|
-
end
|
34
|
-
|
35
|
-
def database_url
|
36
|
-
short_version = version.split(".")[0, 3].join(".") # 1.20.14.2 => 1.20.14
|
37
|
-
url = "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/#{short_version}/metadata/icons.yml"
|
38
|
-
|
39
|
-
if Gem::Version.new(short_version) < Gem::Version.new("5.6.0")
|
40
|
-
url = url.gsub("/metadata", "/advanced-options/metadata")
|
41
|
-
end
|
42
|
-
|
43
|
-
url
|
44
|
-
end
|
45
|
-
|
46
|
-
def download_database!
|
47
|
-
require "open-uri"
|
48
|
-
data = URI.parse(database_url).open.read
|
49
|
-
File.write(database_path, data)
|
50
|
-
end
|
51
|
-
|
52
|
-
def version
|
53
|
-
require "font_awesome/sass/version"
|
54
|
-
FontAwesome::Sass::VERSION
|
55
|
-
end
|
56
|
-
|
57
|
-
def default_fa_style_for_id(id)
|
58
|
-
return if version.start_with?("4")
|
59
|
-
|
60
|
-
if version.start_with?("5")
|
61
|
-
return BMC::FontAwesomeHelper.database.dig(id, :styles).to_a.first
|
62
|
-
end
|
63
|
-
|
64
|
-
raise "invalid font-awesome-sass version"
|
65
|
-
end
|
66
|
-
end # class << self
|
67
28
|
end
|
@@ -54,8 +54,8 @@ module BMC::TextHelper
|
|
54
54
|
def boolean_icon(bool)
|
55
55
|
return if bool.nil?
|
56
56
|
|
57
|
-
return
|
58
|
-
return
|
57
|
+
return fa_s(:check, style: "color: green") if bool == true
|
58
|
+
return fa_s(:times, style: "color: red") if bool == false
|
59
59
|
|
60
60
|
raise "#{bool} is not a boolean"
|
61
61
|
end
|
data/app/sorters/bmc/sorter.rb
CHANGED
@@ -23,4 +23,26 @@ class BMC::Sorter
|
|
23
23
|
def self.call(...)
|
24
24
|
new(...).call
|
25
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def inverted_direction
|
30
|
+
{asc: :desc, desc: :asc}[direction]
|
31
|
+
end
|
32
|
+
|
33
|
+
def joins(...)
|
34
|
+
@collection = @collection.joins(...)
|
35
|
+
end
|
36
|
+
|
37
|
+
def left_joins(...)
|
38
|
+
@collection = @collection.left_joins(...)
|
39
|
+
end
|
40
|
+
|
41
|
+
def by_column(c = column)
|
42
|
+
{c => direction}
|
43
|
+
end
|
44
|
+
|
45
|
+
def by_lower(c = column)
|
46
|
+
Arel.sql "LOWER(#{c}) #{direction}"
|
47
|
+
end
|
26
48
|
end
|
@@ -5,5 +5,5 @@ form.search.bs4 method="get" action=action
|
|
5
5
|
.input-group.search
|
6
6
|
input.form-control.form-control-sm type="text" name="q" placeholder=ta(:search) value=params[:q]
|
7
7
|
span.input-group-append
|
8
|
-
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" =
|
9
|
-
button.btn.btn-sm.bg-light.border.search-submit type="submit" =
|
8
|
+
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" = fa_s(:times)
|
9
|
+
button.btn.btn-sm.bg-light.border.search-submit type="submit" = fa_s(:search)
|
@@ -4,5 +4,5 @@ form.search.bs5.mb-3 method="get" action=action
|
|
4
4
|
|
5
5
|
.input-group.search
|
6
6
|
input.form-control.form-control-sm type="text" name="q" placeholder=ta(:search) value=params[:q]
|
7
|
-
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" =
|
8
|
-
button.btn.btn-sm.bg-light.border.search-submit type="submit" =
|
7
|
+
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" = fa_s(:times)
|
8
|
+
button.btn.btn-sm.bg-light.border.search-submit type="submit" = fa_s(:search)
|
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.2
|
4
|
+
version: 1.3.2
|
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-
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
|
-
rubygems_version: 3.3.
|
231
|
+
rubygems_version: 3.3.7
|
232
232
|
signing_key:
|
233
233
|
specification_version: 4
|
234
234
|
summary: BMC
|