effective_bootstrap 0.13.0 → 0.13.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: 32a2c9eaed6f8b91548c0b6b418c37e1385ea9f7323b429725849a72c7aa00a4
4
- data.tar.gz: 59f3fc9353fa3630a6dc3e0b5f1e31e75b4e1b9bae511c8ad563d96ebc11f80f
3
+ metadata.gz: 18aa82bffaabfcab3bd340de2d1125a8a6111e5a09d9ddb921abf06fac1bc99e
4
+ data.tar.gz: 95f1b53bfa7e32dcd5c49a769b5e58c824becf5ce098a50ce61c874e37e7a31c
5
5
  SHA512:
6
- metadata.gz: 3eb4e59a05641ce7b555a8265e5d61189235b60bd2200842860c9bd8077c89dd2e500424a89007f07fae42170e1fd9116c89439509061812e2d7d917a3614019
7
- data.tar.gz: 150b453174902f53b00e99fc751220ce583016e9de0a2ce2bb9a7d10a880420045d4d656d3b8967b606b5edcb626b7b8cf0f28e4f369ec6c1472d436f7d5be0c
6
+ metadata.gz: 0750f84d089f5c28d599ba92ab2c9b957c83d3e28abc02b5bc727317954152278b303581597e0b2ba1f1b9284ec0b0b840b67854485c58dc8e3354119be5fa69
7
+ data.tar.gz: 1849f908e4a40614cc24f27465b12185d49584d982fa243cf1e9e681ac19df68b88ec67b3d8cf5271a203a6f50c6c43ebeb6108d26d6bfb661119dc60f9449e9
@@ -64,15 +64,17 @@ module EffectiveBootstrapHelper
64
64
  # = card('title do')
65
65
  # %p Stuff
66
66
  # = card('Stuff', header: 'header title')
67
- def card(value = nil, opts = {}, &block)
67
+ def card(resource = nil, opts = {}, &block)
68
68
  raise('expected a block') unless block_given?
69
69
 
70
- if value.kind_of?(Hash)
71
- opts = value; value = nil
70
+ if resource.kind_of?(Hash)
71
+ opts = resource; resource = nil
72
72
  end
73
73
 
74
+ return if resource.kind_of?(Class) && !EffectiveResources.authorized?(self, :index, resource)
75
+
74
76
  header = opts.delete(:header)
75
- title = opts.delete(:title) || effective_bootstrap_human_name(value)
77
+ title = opts.delete(:title) || opts.delete(:label) || effective_bootstrap_human_name(resource, plural: (opts.key?(:plural) ? opts.delete(:plural) : true))
76
78
 
77
79
  content_tag(:div, merge_class_key(opts, 'card mb-4')) do
78
80
  header = content_tag(:div, header, class: 'card-header') if header.present?
@@ -316,7 +318,7 @@ module EffectiveBootstrapHelper
316
318
  def nav_link_to(resource, path, opts = {})
317
319
  return if resource.kind_of?(Class) && !EffectiveResources.authorized?(self, :index, resource)
318
320
 
319
- label = opts.delete(:label) || effective_bootstrap_human_name(resource, plural: true, prefer_model_name: true)
321
+ label = opts.delete(:label) || effective_bootstrap_human_name(resource, plural: (opts.key?(:plural) ? opts.delete(:plural) : true), prefer_model_name: true)
320
322
 
321
323
  if @_nav_mode == :dropdown # We insert dropdown-items
322
324
  return link_to(label, path, merge_class_key(opts, 'dropdown-item'))
@@ -596,12 +598,13 @@ module EffectiveBootstrapHelper
596
598
 
597
599
  NUMBERS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
598
600
 
599
- def tab(label, options = {}, &block)
600
- label = effective_bootstrap_human_name(label, prefer_model_name: true)
601
+ def tab(resource, opts = {}, &block)
602
+ return if resource.kind_of?(Class) && !EffectiveResources.authorized?(self, :index, resource)
603
+ label = opts.delete(:label) || effective_bootstrap_human_name(resource, plural: (opts.key?(:plural) ? opts.delete(:plural) : true), prefer_model_name: true)
601
604
 
602
605
  (@_tab_labels.push(label) and return) if @_tab_mode == :validate
603
606
 
604
- controls = options.delete(:controls) || label.to_s.parameterize.gsub('_', '-')
607
+ controls = opts.delete(:controls) || label.to_s.parameterize.gsub('_', '-')
605
608
  controls = "item-#{controls}" if NUMBERS.include?(controls[0]) # Can't start with a number
606
609
  controls = controls[1..-1] if controls[0] == '#'
607
610
  controls = "#{controls}-#{@_tab_unique}" if @_tab_unique
@@ -617,7 +620,7 @@ module EffectiveBootstrapHelper
617
620
  content_tag(:a, label, id: ('tab-' + controls), class: ['nav-link', ('active' if active)].compact.join(' '), href: '#' + controls, 'aria-controls': controls, 'aria-selected': active.to_s, 'data-toggle': 'tab', role: 'tab')
618
621
  end
619
622
  else # Inserting the content into the tab itself
620
- classes = ['tab-pane', 'fade', ('show active' if active), options[:class].presence].compact.join(' ')
623
+ classes = ['tab-pane', 'fade', ('show active' if active), opts[:class].presence].compact.join(' ')
621
624
  content_tag(:div, id: controls, class: classes, role: 'tabpanel', 'aria-labelledby': ('tab-' + controls), 'data-tab-label': label) do
622
625
  yield
623
626
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '0.13.1'.freeze
3
3
  end
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.13.0
4
+ version: 0.13.1
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-03-31 00:00:00.000000000 Z
11
+ date: 2023-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails