effective_bootstrap 0.13.0 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32a2c9eaed6f8b91548c0b6b418c37e1385ea9f7323b429725849a72c7aa00a4
4
- data.tar.gz: 59f3fc9353fa3630a6dc3e0b5f1e31e75b4e1b9bae511c8ad563d96ebc11f80f
3
+ metadata.gz: ecffafbb096f543759ef66fd919f85dbf96acebd446ba522b4427c831b7b5b55
4
+ data.tar.gz: 9793e72a94792bed35abec120c8346d9c11f170e0323aa06aff49f75650d6d7f
5
5
  SHA512:
6
- metadata.gz: 3eb4e59a05641ce7b555a8265e5d61189235b60bd2200842860c9bd8077c89dd2e500424a89007f07fae42170e1fd9116c89439509061812e2d7d917a3614019
7
- data.tar.gz: 150b453174902f53b00e99fc751220ce583016e9de0a2ce2bb9a7d10a880420045d4d656d3b8967b606b5edcb626b7b8cf0f28e4f369ec6c1472d436f7d5be0c
6
+ metadata.gz: 7394dc15b00b1e4bc79cd4bdffb220fa093b034dd0dc67beea558e4ae87b6e61c4d5fb37c3c9b9e4934811b0bd420c6e0da427445009b33f881d86b5097c79f0
7
+ data.tar.gz: ec4c87b103ebd7f621e6304948daeaa3adcf6078b9df9e71c6da1fba9593c98a6a97b882b3602e8b04cef5859d19d64b33d634c34107d18daed61417e0ed6c74
@@ -70,3 +70,29 @@ div.form-group > label + .btn-group { display: block; }
70
70
 
71
71
  // File Control
72
72
  .form-control-file { border: none !important; }
73
+
74
+ // Radios
75
+ form fieldset.effective-radios {
76
+ margin-top: 0;
77
+ margin-bottom: 0;
78
+ }
79
+
80
+ form fieldset.effective-checks {
81
+ margin-top: 0;
82
+ margin-bottom: 0;
83
+ }
84
+
85
+ form fieldset.effective-radios legend {
86
+ font-size: 1rem;
87
+ font-weight: inherit;
88
+ margin-top: 0.5rem;
89
+ margin-bottom: 1rem;
90
+ }
91
+
92
+ // Checks
93
+ form fieldset.effective-checks > label {
94
+ font-size: 1rem;
95
+ font-weight: inherit;
96
+ margin-top: 0.5rem;
97
+ margin-bottom: 1rem;
98
+ }
@@ -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
@@ -96,6 +96,8 @@ module Effective
96
96
  collection.inject({}) { |h, (k, group)| h[k] = translate(group).map { |obj| [obj.to_s, "#{obj.class.model_name}_#{obj.id}"] }; h }
97
97
  elsif grouped
98
98
  collection.inject({}) { |h, (k, group)| h[k] = translate(group).map { |obj| obj }; h }
99
+ elsif (collection == :boolean || collection == :booleans || collection == :boolean_collection)
100
+ EffectiveBootstrap.boolean_collection
99
101
  else
100
102
  translate(collection).map { |obj| obj }
101
103
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '0.13.2'.freeze
3
3
  end
@@ -11,4 +11,8 @@ module EffectiveBootstrap
11
11
 
12
12
  include EffectiveGem
13
13
 
14
+ def self.boolean_collection
15
+ [['Yes', true], ['No', false]]
16
+ end
17
+
14
18
  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.2
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-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails