Skip to content

Commit

Permalink
Fixed RichText multi-selection alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 24, 2020
1 parent 10a31a1 commit 3e60b60
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions library/cwm/src/lib/cwm/multi_status_selector.rb
Expand Up @@ -125,12 +125,11 @@ 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
ret = "<table>#{item_content}</table>"
# hack: tables are displayed side-by-side in text mode (ugh?),
# add an extra line break in that case
ret << "<br>" if Yast::UI.TextMode
ret
end

content.value = new_value.join
Expand Down Expand Up @@ -397,12 +396,15 @@ 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 extra space in graphical mode
space = Yast::UI.TextMode ? "" : " "
"<tr><td>#{checkbox_input}#{space}</td><td> #{checkbox_label}</td></tr>"
end

# Determines whether running in installation mode
Expand Down Expand Up @@ -436,7 +438,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}</a>"
end
end

Expand All @@ -447,7 +449,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}</a>"
end
end

Expand Down

0 comments on commit 3e60b60

Please sign in to comment.