diff --git a/library/cwm/src/lib/cwm/multi_status_selector.rb b/library/cwm/src/lib/cwm/multi_status_selector.rb index 829df5ea3..e0857d22a 100644 --- a/library/cwm/src/lib/cwm/multi_status_selector.rb +++ b/library/cwm/src/lib/cwm/multi_status_selector.rb @@ -121,6 +121,21 @@ def contents HBox(content) end + # Updates the content based on items list + def refresh + new_value = items.map do |item| + item_content = item.to_richtext + + if Yast::UI.TextMode + "#{item_content}
" + else + "

#{item_content}

" + end + end + + content.value = new_value.join + end + # @macro seeAbstractWidget def handle(event) if event["ID"].to_s.include?(Item.event_id) @@ -173,11 +188,6 @@ def find_item(needle) items.find { |i| i.id.to_s == needle.to_s } end - # Updates the content based on items list - def refresh - content.value = items.map(&:to_richtext).join("
") - end - # Convenience widget to keep the content updated # # @return [ContentArea] @@ -210,6 +220,8 @@ def keep_scroll? class Item extend Yast::I18n + textdomain "base" + # Map to icons used in GUI to represent all the known statuses in both scenarios, during # installation (`inst` mode) and in a running system (`normal` mode). # @@ -261,8 +273,6 @@ class Item LABEL_EVENT_ID = "#{EVENT_ID}label".freeze private_constant :LABEL_EVENT_ID - textdomain "cwm" - # @!method id # The item id # @return [#to_s] diff --git a/library/cwm/test/multi_status_selector_test.rb b/library/cwm/test/multi_status_selector_test.rb index d141351c5..509d2f615 100644 --- a/library/cwm/test/multi_status_selector_test.rb +++ b/library/cwm/test/multi_status_selector_test.rb @@ -62,9 +62,48 @@ def initialize(id, status, enabled) let(:first_item) { { id: 1, status: :selected, enabled: false } } let(:second_item) { { id: 2, status: :unselected, enabled: true } } let(:items) { [first_item, second_item] } + let(:content) { subject.contents.nested_find { |i| i.is_a?(CWM::RichText) } } include_examples "CWM::CustomWidget" + describe "#refresh" do + before do + allow(Yast::UI).to receive(:TextMode).and_return(text_mode) + end + + context "when running in text mode" do + let(:text_mode) { true } + + it "includes
tags" do + expect(content).to receive(:value=).with(/
/) + + subject.refresh + end + + it "does not include

tags" do + expect(content).to_not receive(:value=).with(/

/) + + subject.refresh + end + end + + context "when not running in text mode" do + let(:text_mode) { false } + + it "includes

tags" do + expect(content).to receive(:value=).with(/

/) + + subject.refresh + end + + it "does not include
tags" do + expect(content).to_not receive(:value=).with(/
/) + + subject.refresh + end + end + end + describe "#init" do it "renders all items" do expect(subject.items).to all(receive(:to_richtext)) diff --git a/package/yast2.changes b/package/yast2.changes index d7ee7ba44..6b83323ad 100644 --- a/package/yast2.changes +++ b/package/yast2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Mar 13 01:54:58 UTC 2020 - David Diaz + +- CWM::MultiStatusSelector minor improvements (related to + bsc#1157780). +- 4.2.73 + ------------------------------------------------------------------- Thu Mar 12 09:14:16 UTC 2020 - David Diaz diff --git a/package/yast2.spec b/package/yast2.spec index a5b8c490a..62ff51411 100644 --- a/package/yast2.spec +++ b/package/yast2.spec @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.2.72 +Version: 4.2.73 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only