From fadd5bb2ba471b5ec109896fcecd1d785e45a9a3 Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 27 Jan 2025 09:19:07 +0000 Subject: [PATCH 1/8] fix cancel modal button function re-introduce btn-default style --- app/assets/stylesheets/ndr_ui/index.scss | 6 ++++++ app/helpers/ndr_ui/bootstrap/modal_helper.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/ndr_ui/index.scss b/app/assets/stylesheets/ndr_ui/index.scss index 993f94e..2bc60c1 100644 --- a/app/assets/stylesheets/ndr_ui/index.scss +++ b/app/assets/stylesheets/ndr_ui/index.scss @@ -19,3 +19,9 @@ $bootstrap-icons-font-dir: "."; border:0; } } + +// Bootstrap don't have btn-default anymore +// however, we keep btn-default in codebase/helpers and set global default setting here. +.btn-default { + @extend .btn-outline-secondary; +} diff --git a/app/helpers/ndr_ui/bootstrap/modal_helper.rb b/app/helpers/ndr_ui/bootstrap/modal_helper.rb index 20f2143..789bd2a 100644 --- a/app/helpers/ndr_ui/bootstrap/modal_helper.rb +++ b/app/helpers/ndr_ui/bootstrap/modal_helper.rb @@ -218,7 +218,7 @@ def bootstrap_modal_save_buttons end def bootstrap_modal_button(label) - button_tag(label, class: 'btn btn-default', 'data-bs-dismiss': 'modal') + button_tag(label, type: 'button', class: 'btn btn-default', 'data-bs-dismiss': 'modal') end private From cfc857d4180c1bcc015fda711ada90198b06df8e Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 27 Jan 2025 09:20:39 +0000 Subject: [PATCH 2/8] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 317ff09..15debd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [Unreleased] -* no unreleased changes * +* fix cancel modal button +* re-introdce btn-default style ## 5.0.0 / 2025-01-24 ### Changed From 58accd55ba5071343c9b603ace3a4e17c3b2517a Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 27 Jan 2025 11:11:06 +0000 Subject: [PATCH 3/8] fix bootstrap_tab_nav_tag helper method with required classes --- app/helpers/ndr_ui/bootstrap_helper.rb | 6 +++--- test/helpers/ndr_ui/bootstrap_helper_test.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/ndr_ui/bootstrap_helper.rb b/app/helpers/ndr_ui/bootstrap_helper.rb index dffb8aa..6e3a195 100644 --- a/app/helpers/ndr_ui/bootstrap_helper.rb +++ b/app/helpers/ndr_ui/bootstrap_helper.rb @@ -203,11 +203,11 @@ def bootstrap_icon_spinner(type = :default) # ==== Examples # # <%= bootstrap_tab_nav_tag("Fruits", "#fruits", true) %> - # # =>
  • Fruits
  • + # # => def bootstrap_tab_nav_tag(title, linkto, active = false) content_tag('li', - link_to(title, linkto, 'data-bs-toggle': 'tab'), - active ? { class: 'active' } : {}) + link_to(title, linkto, 'data-bs-toggle': 'tab', class: "nav-link#{active ? ' active' : ''}"), + class: 'nav-item') end # Convenience wrapper for a bootstrap_list_link_to with badge diff --git a/test/helpers/ndr_ui/bootstrap_helper_test.rb b/test/helpers/ndr_ui/bootstrap_helper_test.rb index ddf0a5d..6e6bc56 100644 --- a/test/helpers/ndr_ui/bootstrap_helper_test.rb +++ b/test/helpers/ndr_ui/bootstrap_helper_test.rb @@ -121,11 +121,11 @@ class BootstrapHelperTest < ActionView::TestCase end test 'bootstrap_tab_nav_tag' do - assert_dom_equal '
  • Fruits
  • ', + assert_dom_equal '', bootstrap_tab_nav_tag('Fruits', '#fruits') - assert_dom_equal '
  • Fruits
  • ', + assert_dom_equal '', bootstrap_tab_nav_tag('Fruits', '#fruits', false) - assert_dom_equal '
  • Fruits
  • ', + assert_dom_equal '', bootstrap_tab_nav_tag('Fruits', '#fruits', true) end From 67aa78a92fc301bb48cc8b732c083d11eef7fbd6 Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 27 Jan 2025 15:46:56 +0000 Subject: [PATCH 4/8] allow more padding at the end for bootstrap_list_badge_and_link_to --- app/helpers/ndr_ui/bootstrap_helper.rb | 3 ++- test/helpers/ndr_ui/bootstrap_helper_test.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/ndr_ui/bootstrap_helper.rb b/app/helpers/ndr_ui/bootstrap_helper.rb index 6e3a195..84cd5a2 100644 --- a/app/helpers/ndr_ui/bootstrap_helper.rb +++ b/app/helpers/ndr_ui/bootstrap_helper.rb @@ -212,7 +212,8 @@ def bootstrap_tab_nav_tag(title, linkto, active = false) # Convenience wrapper for a bootstrap_list_link_to with badge def bootstrap_list_badge_and_link_to(type, count, name, path) - html = content_tag(:div, bootstrap_badge_tag(type, count), class: 'float-end') + name + html = content_tag(:div, bootstrap_badge_tag(type, count), class: 'float-end') + + content_tag(:div, name, class: 'pe-5') bootstrap_list_link_to(html, path) end diff --git a/test/helpers/ndr_ui/bootstrap_helper_test.rb b/test/helpers/ndr_ui/bootstrap_helper_test.rb index 6e6bc56..e5f8dc2 100644 --- a/test/helpers/ndr_ui/bootstrap_helper_test.rb +++ b/test/helpers/ndr_ui/bootstrap_helper_test.rb @@ -135,7 +135,7 @@ class BootstrapHelperTest < ActionView::TestCase refute current_page?(inbox_path) html = content_tag(:div, bootstrap_badge_tag(:important, 99), class: 'float-end') - html += 'Inbox' + html += content_tag(:div, 'Inbox', class: 'pe-5') assert_dom_equal content_tag(:li, link_to(html, inbox_path, class: 'dropdown-item')), bootstrap_list_badge_and_link_to(:important, 99, 'Inbox', inbox_path) end From 1f7154eaa03b3ae8e0e63ec23616edfa9bbf0a1d Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Wed, 29 Jan 2025 10:40:49 +0000 Subject: [PATCH 5/8] fix offset class name in line with Bootstrap 5 upgrade --- app/helpers/ndr_ui/bootstrap_helper.rb | 4 ++-- test/helpers/ndr_ui/bootstrap_helper_test.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/ndr_ui/bootstrap_helper.rb b/app/helpers/ndr_ui/bootstrap_helper.rb index 84cd5a2..97ec650 100644 --- a/app/helpers/ndr_ui/bootstrap_helper.rb +++ b/app/helpers/ndr_ui/bootstrap_helper.rb @@ -307,7 +307,7 @@ def bootstrap_form_with(**options, &block) # <%= button_control_group("Apples", class: "some_class") %> # # => #
    - #
    + #
    #
    Apples
    #
    #
    @@ -387,7 +387,7 @@ def bootstrap_progressbar_tag(*args) # def bootstrap_horizontal_form_group(label = nil, ratio = [2, 10], &block) l, r = ratio[0..1].map(&:to_i) - offset = label.nil? ? " col-sm-offset-#{l}" : '' + offset = label.nil? ? " offset-sm-#{l}" : '' # Main content: content = content_tag(:div, class: "col-sm-#{r}" + offset, &block) diff --git a/test/helpers/ndr_ui/bootstrap_helper_test.rb b/test/helpers/ndr_ui/bootstrap_helper_test.rb index e5f8dc2..4893667 100644 --- a/test/helpers/ndr_ui/bootstrap_helper_test.rb +++ b/test/helpers/ndr_ui/bootstrap_helper_test.rb @@ -298,14 +298,14 @@ class BootstrapHelperTest < ActionView::TestCase # TODO: bootstrap_pagination_tag(*args, &block) test 'button_control_group' do - assert_dom_equal '
    ' \ + assert_dom_equal '
    ' \ 'Apples
    ', button_control_group('Apples') html = button_control_group(class: 'some_class') do 'Pears' end - assert_dom_equal '
    ' \ + assert_dom_equal '
    ' \ '
    Pears
    ', html @@ -346,7 +346,7 @@ class BootstrapHelperTest < ActionView::TestCase # Test with no label: actual = bootstrap_horizontal_form_group { 'This is the content' } - expected = '
    ' \ + expected = '
    ' \ 'This is the content
    ' assert_dom_equal expected, actual end From 5012ac2af242baa8ae12ed9bf9bb7b8ba9a3d2ec Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 3 Feb 2025 11:16:38 +0000 Subject: [PATCH 6/8] minor fix about alert tag with close button option. --- app/helpers/ndr_ui/bootstrap_helper.rb | 6 ++--- test/helpers/ndr_ui/bootstrap_helper_test.rb | 24 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/helpers/ndr_ui/bootstrap_helper.rb b/app/helpers/ndr_ui/bootstrap_helper.rb index 97ec650..95c4bf4 100644 --- a/app/helpers/ndr_ui/bootstrap_helper.rb +++ b/app/helpers/ndr_ui/bootstrap_helper.rb @@ -51,8 +51,8 @@ def select_tag(name, option_tags = nil, options = {}) # <%= bootstrap_alert_tag(:info) do %> # Check it out!! # <% end %> - # # =>
    Check it out!!
    + # # =>
    Check it out!! + #
    # # Ids for css and/or javascript are easy to produce: # @@ -79,7 +79,7 @@ def bootstrap_alert_tag(*args, &block) options['class'] = classes.join(' ') if options.delete('dismissible') - message = button_tag('', type: 'button', class: 'btn-close', 'data-bs-dismiss': 'alert') + message + message = message.html_safe + button_tag('', type: 'button', class: 'btn-close', 'data-bs-dismiss': 'alert') end content_tag(:div, message, options) end diff --git a/test/helpers/ndr_ui/bootstrap_helper_test.rb b/test/helpers/ndr_ui/bootstrap_helper_test.rb index 4893667..f0af737 100644 --- a/test/helpers/ndr_ui/bootstrap_helper_test.rb +++ b/test/helpers/ndr_ui/bootstrap_helper_test.rb @@ -8,17 +8,17 @@ module NdrUi # Test bootstrap helpers class BootstrapHelperTest < ActionView::TestCase test 'bootstrap_alert_tag with message parameter' do - assert_dom_equal '
    ' \ + assert_dom_equal '
    Apples' \ '' \ - 'Apples
    ', + '
    ', bootstrap_alert_tag(:danger, 'Apples') - assert_dom_equal '
    ' \ + assert_dom_equal '
    Apples' \ '' \ - 'Apples
    ', + '
    ', bootstrap_alert_tag(:warning, 'Apples') - assert_dom_equal '
    ' \ + assert_dom_equal '
    Apples' \ '' \ - 'Apples
    ', + '
    ', bootstrap_alert_tag(:info, 'Apples') assert_dom_equal '
    ' \ '' \ @@ -28,15 +28,15 @@ class BootstrapHelperTest < ActionView::TestCase '' \ '
    ', bootstrap_alert_tag(:success, '') - assert_dom_equal '
    ' \ + assert_dom_equal '
    Apples' \ '' \ - 'Apples
    ', + '
    ', bootstrap_alert_tag(:warning, 'Apples', dismissible: true) assert_dom_equal '
    Apples
    ', bootstrap_alert_tag(:warning, 'Apples', dismissible: false) - assert_dom_equal '
    ' \ + assert_dom_equal '
    Apples' \ '' \ - 'Apples
    ', + '
    ', bootstrap_alert_tag(:warning, 'Apples', dismissible: true, id: 'apple_123') assert_dom_equal '
    Apples
    ', bootstrap_alert_tag(:warning, 'Apples', dismissible: false, id: 'apple_123') @@ -45,9 +45,9 @@ class BootstrapHelperTest < ActionView::TestCase end test 'bootstrap_alert_tag with message block' do - assert_dom_equal '
    ' \ + assert_dom_equal '
    Pears' \ '' \ - 'Pears
    ', + '
    ', bootstrap_alert_tag(:info) { 'Pears' } assert_dom_equal '
    ' \ From 8992c73705136bed458e73fe481541ae5eb3717f Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 3 Feb 2025 11:22:55 +0000 Subject: [PATCH 7/8] update change log --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15debd6..bf85a02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ## [Unreleased] * fix cancel modal button -* re-introdce btn-default style +* re-introdce `btn-default` style +* fix `bootstrap_tab_nav_tag` helper method with required classes +* allow more padding at the end for `bootstrap_list_badge_and_link_to` +* fix offset class name in line with Bootstrap 5 upgrade +* fix `bootstrap_alert_tag` style with close button option + ## 5.0.0 / 2025-01-24 ### Changed From 2a6ccc0896982c1b22c17021602eaa9ebc8e2794 Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Mon, 3 Feb 2025 11:30:59 +0000 Subject: [PATCH 8/8] rubocop fix --- app/helpers/ndr_ui/bootstrap_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/ndr_ui/bootstrap_helper.rb b/app/helpers/ndr_ui/bootstrap_helper.rb index 95c4bf4..14e5cd1 100644 --- a/app/helpers/ndr_ui/bootstrap_helper.rb +++ b/app/helpers/ndr_ui/bootstrap_helper.rb @@ -212,8 +212,9 @@ def bootstrap_tab_nav_tag(title, linkto, active = false) # Convenience wrapper for a bootstrap_list_link_to with badge def bootstrap_list_badge_and_link_to(type, count, name, path) - html = content_tag(:div, bootstrap_badge_tag(type, count), class: 'float-end') + - content_tag(:div, name, class: 'pe-5') + html = content_tag(:div, bootstrap_badge_tag(type, count), class: 'float-end') + + content_tag(:div, name, class: 'pe-5') + bootstrap_list_link_to(html, path) end