Skip to content

Commit

Permalink
display some details in the richtext widget
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 19, 2015
1 parent caed099 commit cbb4b34
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
38 changes: 30 additions & 8 deletions src/lib/registration/ui/migration_selection_dialog.rb
Expand Up @@ -12,6 +12,8 @@
# ------------------------------------------------------------------------------
#

require "cgi/util"

require "yast"

module Registration
Expand Down Expand Up @@ -55,12 +57,15 @@ def run
true
)

continue_buttons = [:next, :back, :cancel, :abort]
ret = Yast::UI.UserInput until continue_buttons.include?(ret)
update_details

store_values if ret == :next
loop do
ret = Yast::UI.UserInput
update_details if ret == :migration_targets
store_values if ret == :next

ret
return ret if [:next, :back, :cancel, :abort].include?(ret)
end
end

private
Expand All @@ -76,8 +81,8 @@ def dialog_content

MinHeight(8,
VWeight(25,
RichText(Opt(:vstretch), "<h3>Migration Products Details</h3>")
)),
RichText(Id(:details), Opt(:vstretch), "")
)),

VSpacing(Yast::UI.TextMode ? 0 : 1),
# TRANSLATORS: check button label
Expand All @@ -90,9 +95,9 @@ def migration_selection_widget
MinHeight(8,
VWeight(25,
# TRANSLATORS: selection box label
SelectionBox(Id(:migration_targets), Opt(:vstretch),
SelectionBox(Id(:migration_targets), Opt(:vstretch, :notify),
_("Possible Migration Targets"), migration_items)
))
))
end

def migration_items
Expand All @@ -105,6 +110,23 @@ def migration_items
end
end

def update_details
log.info "updating details"
selected = Yast::UI.QueryWidget(:migration_targets, :CurrentItem)
return unless selected

# TODO: display some user friendly details
details = migrations[selected].map do |product|
"<li>" + CGI.escapeHTML("#{product.identifier}-#{product.version}-#{product.arch}") +
"</li>"
end

details = "<ul>" + details.join + "</ul>"
details = _("<h3>Migration Products Details</h3>%s") % details

Yast::UI.ChangeWidget(Id(:details), :Value, details)
end

def store_values
selected = Yast::UI.QueryWidget(:migration_targets, :CurrentItem)
self.selected_migration = migrations[selected]
Expand Down
2 changes: 1 addition & 1 deletion test/migration_selection_dialog_test.rb
Expand Up @@ -24,7 +24,7 @@
# user pressed the "Abort" button
expect(Yast::UI).to receive(:UserInput).and_return(:next)
expect(Yast::UI).to receive(:QueryWidget).with(:migration_targets, :CurrentItem)
.and_return(0)
.and_return(0).twice
expect(Yast::UI).to receive(:QueryWidget).with(:manual_repos, :Value).and_return(true)

dialog = subject.new(migration_products)
Expand Down

0 comments on commit cbb4b34

Please sign in to comment.