effective_bootstrap 1.22.1 → 1.22.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: 67309075b096a201f87cb46e5eb5a232320b9eb30f3d627f842d5a1a9d574a6b
4
- data.tar.gz: 690e7121600303eb322ac8ae6f2f3dcf5cc1a5914e205b6dd5a2a97466075326
3
+ metadata.gz: 72dd156fce6da5b624d7ef6e666198def54c289676f1aaf024aea4c11eae7f8f
4
+ data.tar.gz: 3f6518cd35b2a1dd28159dcaad798631572b6fd4607e252d79990c468d693e7c
5
5
  SHA512:
6
- metadata.gz: b86b1ee80275ce1bae0d8c1ab00856ab5d379fe1be90e7bdcdf7d9ec82f3d8ef7de6819cb660a27f3bbb25ed552be29ea0601d5df702e39f5ccff4140ff310f7
7
- data.tar.gz: 65727df86bf8f294d377fda450f6404a18a0ab654fcccc0cd1369ef278e9fe3d6e17374e6c14cf41148bd6a42512d1412ec4a5d21f7b3406f39e00889bc8db1f
6
+ metadata.gz: ba618d917a6a0a312b40bd93d86ebd28e9022adf7d1cd530a75e6956de1e2cd72010e2f1631654963f1b8675d7f144c574efbe062ad0ad1d239d8d7839262665
7
+ data.tar.gz: 32e42a810c099983bfc764bc3d25d94a9c6dfba62c4966d5eeef84140cb84c3a02bb8a2d4a1f1429d7f6faa585300ccba158437b2d6fa2be1f0fb122c935209d
@@ -64,13 +64,17 @@ module EffectiveBootstrapHelper
64
64
  # = card('title do')
65
65
  # %p Stuff
66
66
  # = card('Stuff', header: 'header title')
67
+ # = card(partial: 'lares/dashboard')
67
68
  def card(resource = nil, opts = {}, &block)
68
- raise('expected a block') unless block_given?
69
-
70
69
  if resource.kind_of?(Hash)
71
70
  opts = resource; resource = nil
72
71
  end
73
72
 
73
+ partial = opts.delete(:partial)
74
+ locals = opts.delete(:locals) || {}
75
+
76
+ raise('expected a block or a partial') unless block_given? || partial.present?
77
+
74
78
  return if resource.kind_of?(Class) && !EffectiveResources.authorized?(self, :index, resource)
75
79
 
76
80
  header = opts.delete(:header)
@@ -80,10 +84,12 @@ module EffectiveBootstrapHelper
80
84
  header = content_tag(:div, header, class: 'card-header') if header.present?
81
85
 
82
86
  body = content_tag(:div, class: 'card-body') do
87
+ content = (partial.present? ? render(partial, locals) : capture(&block))
88
+
83
89
  if title.present?
84
- content_tag(:h5, title, class: 'card-title') + capture(&block)
90
+ content_tag(:h5, title, class: 'card-title') + content
85
91
  else
86
- capture(&block)
92
+ content
87
93
  end
88
94
  end
89
95
 
@@ -91,6 +97,12 @@ module EffectiveBootstrapHelper
91
97
  end
92
98
  end
93
99
 
100
+ # A card_dashboard card that renders one dashboard partial
101
+ # = dashboard_card('effective/polls/dashboard')
102
+ def dashboard_card(partial, opts = {})
103
+ card(merge_class_key(opts, 'card-dashboard').merge(partial: partial))
104
+ end
105
+
94
106
  def clipboard_copy(text, opts = {})
95
107
  opts[:label] ||= 'Copy to Clipboard'
96
108
  opts[:class] ||= 'btn btn-secondary'
@@ -375,10 +387,7 @@ module EffectiveBootstrapHelper
375
387
 
376
388
  return ''.html_safe if content.blank?
377
389
 
378
- if sort && !content.include?('dropdown-divider')
379
- lines = content.gsub("\n", '').split("</a>").reject(&:blank?).map { |line| line + "</a>" }
380
- content = lines.sort_by { |line| line.match(/<a[^>]*>([^<]*)<\/a>/)[1] || '' }.join("</a>\n")
381
- end
390
+ content = effective_bootstrap_sort_dropdown_content(content) if sort
382
391
 
383
392
  content_tag(:li, class: 'nav-item dropdown') do
384
393
  content_tag(:a, class: 'nav-link dropdown-toggle', href: '#', id: id, role: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) do
@@ -739,6 +748,24 @@ module EffectiveBootstrapHelper
739
748
  end
740
749
  end
741
750
 
751
+ # Sorts the dropdown items of a nav_dropdown(sort: true) alphabetically by their label
752
+ # Each nav_divider starts a new section, and every section is sorted on its own, so the
753
+ # dividers keep grouping the menu just as they were written
754
+ # Any section with more than dropdown items in it is left exactly as-is
755
+ def effective_bootstrap_sort_dropdown_content(content)
756
+ divider = nav_divider
757
+
758
+ sections = content.split(divider).map do |section|
759
+ links = section.scan(/<a\b[^>]*>.*?<\/a>/m)
760
+ remaining = links.inject(section) { |result, link| result.sub(link, '') }
761
+
762
+ next section if remaining.present?
763
+ links.sort_by { |link| link.gsub(/<[^>]*>/, '').strip.downcase }.join("\n")
764
+ end
765
+
766
+ sections.join("\n#{divider}\n").html_safe
767
+ end
768
+
742
769
  def effective_bootstrap_unique_id
743
770
  # Set the first unique value
744
771
  @_effective_bootstrap_unique_id ||= Time.zone.now.to_i
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.22.1'.freeze
2
+ VERSION = '1.22.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.1
4
+ version: 1.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-04-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -745,7 +744,6 @@ homepage: https://github.com/code-and-effect/effective_bootstrap
745
744
  licenses:
746
745
  - MIT
747
746
  metadata: {}
748
- post_install_message:
749
747
  rdoc_options: []
750
748
  require_paths:
751
749
  - lib
@@ -760,8 +758,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
760
758
  - !ruby/object:Gem::Version
761
759
  version: '0'
762
760
  requirements: []
763
- rubygems_version: 3.5.6
764
- signing_key:
761
+ rubygems_version: 4.0.17
765
762
  specification_version: 4
766
763
  summary: Everything you need to get set up with bootstrap 4.
767
764
  test_files: []