Skip to content

Commit

Permalink
Move <ask> widgets to its own namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 10, 2021
1 parent cddab26 commit 939c603
Show file tree
Hide file tree
Showing 17 changed files with 1,047 additions and 778 deletions.
4 changes: 2 additions & 2 deletions src/lib/autoinstall/ask/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "autoinstall/widgets/ask_dialog"
require "autoinstall/widgets/ask/dialog"
require "autoinstall/ask/profile_reader"
require "autoinstall/autoinst_profile/ask_list_section"
require "autoinstall/script_runner"
Expand Down Expand Up @@ -98,7 +98,7 @@ def ask_list
# @param dialog [Y2Autoinstall::Ask::Dialog] Ask dialog specification
# @return [Symbol] :next or :back
def run_dialog(dialog)
ask_dialog = Y2Autoinstall::Widgets::AskDialog.new(
ask_dialog = Y2Autoinstall::Widgets::Ask::Dialog.new(
dialog, disable_back_button: first?
)
ask_dialog.run
Expand Down
64 changes: 64 additions & 0 deletions src/lib/autoinstall/widgets/ask/check_box.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) [2021] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "yast"
require "cwm"
require "autoinstall/widgets/ask/field"

module Y2Autoinstall
module Widgets
module Ask
# CheckBox widget for <ask> questions
#
# @see Dialog
class CheckBox < CWM::CheckBox
include Field

# @param question [Y2Autoinstall::Ask::Question] Question to represent
def initialize(question)
textdomain "autoinst"
@question = question
end

# @macro seeAbstractWidget
def opt
[:notify]
end

# @macro seeAbstractWidget
def init
if !@question.value.nil?
self.value = @question.value
return
end

if @question.default_value_script
default_from_script = run_script(@question.default_value_script)
end

self.value = if default_from_script.nil?
@question.default == "true"
else
default_from_script == "true"
end
end
end
end
end
end
53 changes: 53 additions & 0 deletions src/lib/autoinstall/widgets/ask/combo_box.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) [2021] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "yast"
require "cwm"
require "autoinstall/widgets/ask/field"

module Y2Autoinstall
module Widgets
module Ask
# Combo Box widget for <ask> questions
#
# @see Dialog
class ComboBox < CWM::ComboBox
include Field

# @param question [Y2Autoinstall::Ask::Question] Question to represent
def initialize(question)
@question = question
end

# @macro seeAbstractWidget
def opt
[:notify, :immediate]
end

# @macro seeComboBox
def items
@question.options.map do |option|
label = option.label || option.value
[option.value, label]
end
end
end
end
end
end

0 comments on commit 939c603

Please sign in to comment.