effective_bootstrap 0.11.22 → 0.12.0
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/app/helpers/effective_bootstrap_helper.rb +22 -2
- data/lib/effective_bootstrap/version.rb +1 -1
- 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: d704ce4e1eb946de08651ae3d5ab12c3fba6e7fcb420d0d0148626a023598a16
|
4
|
+
data.tar.gz: 2934e7fce86b41479c10a4b1a831a6dbab493836ea84b64327ebe2bd257bc2f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d6919a5026511bddc02029dfc25f1ad6336f648d1dd34ebc50bca7779f220703ed14655157f0b46acbe5840185a84fc085c104f1ebbdb8d250314ccdc3020f
|
7
|
+
data.tar.gz: 35423d971df78886a1d7887b001e6c6d4bafd5ae62ef9bcab4c51f96b14f942f60589645802df20e4a85da17e2d847ca6cdecf3f348941e48d77672c0bd0ff03
|
@@ -72,7 +72,7 @@ module EffectiveBootstrapHelper
|
|
72
72
|
end
|
73
73
|
|
74
74
|
header = opts.delete(:header)
|
75
|
-
title = opts.delete(:title) || value
|
75
|
+
title = opts.delete(:title) || effective_bootstrap_human_name(value)
|
76
76
|
|
77
77
|
content_tag(:div, merge_class_key(opts, 'card mb-4')) do
|
78
78
|
header = content_tag(:div, header, class: 'card-header') if header.present?
|
@@ -311,7 +311,13 @@ module EffectiveBootstrapHelper
|
|
311
311
|
# = nav_link_to 'Account Settings', user_settings_path
|
312
312
|
# = nav_divider
|
313
313
|
# = nav_link_to 'Sign In', new_user_session_path, method: :delete
|
314
|
-
|
314
|
+
#
|
315
|
+
# If you pass a class, it will authorize and display that class if you have :index access
|
316
|
+
def nav_link_to(resource, path, opts = {})
|
317
|
+
return if resource.kind_of?(Class) && !EffectiveResources.authorized?(self, :index, resource)
|
318
|
+
|
319
|
+
label = effective_bootstrap_human_name(resource, plural: true, prefer_model_name: true)
|
320
|
+
|
315
321
|
if @_nav_mode == :dropdown # We insert dropdown-items
|
316
322
|
return link_to(label, path, merge_class_key(opts, 'dropdown-item'))
|
317
323
|
end
|
@@ -564,6 +570,8 @@ module EffectiveBootstrapHelper
|
|
564
570
|
NUMBERS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
565
571
|
|
566
572
|
def tab(label, options = {}, &block)
|
573
|
+
label = effective_bootstrap_human_name(label, prefer_model_name: true)
|
574
|
+
|
567
575
|
(@_tab_labels.push(label) and return) if @_tab_mode == :validate
|
568
576
|
|
569
577
|
controls = options.delete(:controls) || label.to_s.parameterize.gsub('_', '-')
|
@@ -622,6 +630,18 @@ module EffectiveBootstrapHelper
|
|
622
630
|
end
|
623
631
|
end
|
624
632
|
|
633
|
+
def effective_bootstrap_human_name(resource, plural: false, prefer_model_name: false)
|
634
|
+
return resource.to_s unless resource.respond_to?(:model_name)
|
635
|
+
|
636
|
+
if resource.kind_of?(ActiveRecord::Relation) || plural
|
637
|
+
ets(resource)
|
638
|
+
elsif resource.kind_of?(Class) || prefer_model_name
|
639
|
+
et(resource)
|
640
|
+
else
|
641
|
+
resource.to_s
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
625
645
|
def effective_bootstrap_unique_id
|
626
646
|
# Set the first unique value
|
627
647
|
@_effective_bootstrap_unique_id ||= Time.zone.now.to_i
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
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: 2023-
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|