Skip to content

Commit

Permalink
Merge pull request #1035 from yast/multi_status_alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 25, 2020
2 parents 10a31a1 + 97526b0 commit 28d5454
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
22 changes: 11 additions & 11 deletions library/cwm/src/lib/cwm/multi_status_selector.rb
Expand Up @@ -125,15 +125,13 @@ def contents
def refresh
new_value = items.map do |item|
item_content = item.to_richtext

if Yast::UI.TextMode
"#{item_content}<br>"
else
"<p>#{item_content}</p>"
end
# HACK: tables rows are displayed side-by-side in text mode (ugh?),
# add an extra line break in that case
item_content << "<br>" if Yast::UI.TextMode
item_content
end

content.value = new_value.join
content.value = "<table>#{new_value.join}</table>"
end

# @macro seeAbstractWidget
Expand Down Expand Up @@ -397,12 +395,14 @@ def auto_select!

# Returns richtext representation for the item
#
# Basically, an string containing two <a> or <span> tags, depending on the #enabled? method.
# Basically a string containing a table row with two <a> or <span> tags,
# depending on the #enabled? method.
# One for the check box input and another for the label.
#
# @return [String] the item richtext representation
def to_richtext
"#{checkbox_input} #{checkbox_label}"
# add some small space (&nbsp;) between the icon and the label
"<tr><td>#{checkbox_input}&nbsp;</td><td>#{checkbox_label}</td></tr>"
end

# Determines whether running in installation mode
Expand Down Expand Up @@ -436,7 +436,7 @@ def checkbox_input
if enabled?
"<a href=\"#{id}#{INPUT_EVENT_ID}\" style=\"#{text_style}\">#{icon}</a>"
else
"<span style\"#{text_style}\">#{icon}</a>"
"<span style=\"#{text_style}\">#{icon}</span>"
end
end

Expand All @@ -447,7 +447,7 @@ def checkbox_label
if enabled?
"<a href=\"#{id}#{LABEL_EVENT_ID}\" style=\"#{text_style}\">#{label}</a>"
else
"<span style\"#{text_style}\">#{label}</a>"
"<span style=\"#{text_style}\">#{label}</span>"
end
end

Expand Down
10 changes: 2 additions & 8 deletions library/cwm/test/multi_status_selector_test.rb
Expand Up @@ -79,19 +79,13 @@ def initialize(id, status, enabled)

subject.refresh
end

it "does not include <p> tags" do
expect(content).to_not receive(:value=).with(/<p>/)

subject.refresh
end
end

context "when not running in text mode" do
let(:text_mode) { false }

it "includes <p> tags" do
expect(content).to receive(:value=).with(/<p>/)
it "includes <table> tags" do
expect(content).to receive(:value=).with(/<table>/)

subject.refresh
end
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Mar 24 16:40:09 UTC 2020 - Ladislav Slezák <lslezak@suse.cz>

- Fixed alignment in the multi selection CWM widget
(part of bsc#1167523)
- 4.2.77

-------------------------------------------------------------------
Mon Mar 23 11:15:56 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.2.76
Version: 4.2.77
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit 28d5454

Please sign in to comment.