Class: Installation::Widgets::ProductSelector
- Inherits:
-
CWM::RadioButtons
- Object
- CWM::RadioButtons
- Installation::Widgets::ProductSelector
- Includes:
- Yast::Logger
- Defined in:
- src/lib/installation/widgets/product_selector.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
Instance Method Summary collapse
- #hspacing ⇒ Object
- #init ⇒ Object
-
#initialize(products, skip_validation: false) ⇒ ProductSelector
constructor
A new instance of ProductSelector.
-
#item_id(prod) ⇒ String
unique widget ID for the product.
- #label ⇒ Object
-
#offline_product_selected? ⇒ Boolean
has been an offline installation product selected?.
-
#registered? ⇒ Boolean
Determine whether the system is registered.
-
#skip_validation? ⇒ Boolean
Determine whether the validation should be skipped.
- #store ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(products, skip_validation: false) ⇒ ProductSelector
Returns a new instance of ProductSelector.
42 43 44 45 46 47 48 |
# File 'src/lib/installation/widgets/product_selector.rb', line 42 def initialize(products, skip_validation: false) super() @products = products @items = products.sort(&Y2Packager::PRODUCT_SORTER).map { |p| [item_id(p), p.label] } @skip_validation = skip_validation textdomain "installation" end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
37 38 39 |
# File 'src/lib/installation/widgets/product_selector.rb', line 37 def items @items end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
38 39 40 |
# File 'src/lib/installation/widgets/product_selector.rb', line 38 def product @product end |
#products ⇒ Object (readonly)
Returns the value of attribute products.
37 38 39 |
# File 'src/lib/installation/widgets/product_selector.rb', line 37 def products @products end |
Instance Method Details
#hspacing ⇒ Object
50 51 52 |
# File 'src/lib/installation/widgets/product_selector.rb', line 50 def hspacing 1 end |
#init ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'src/lib/installation/widgets/product_selector.rb', line 58 def init selected = products.find(&:selected?) # disable changing the base product after registering it, in the offline # installation we cannot easily change the base product repository disable if registered? || offline_product_selected? return unless selected self.value = item_id(selected) end |
#item_id(prod) ⇒ String
unique widget ID for the product
108 109 110 111 112 |
# File 'src/lib/installation/widgets/product_selector.rb', line 108 def item_id(prod) return prod.dir if prod.respond_to?(:dir) "#{prod.name}-#{prod.version}-#{prod.arch}" end |
#label ⇒ Object
54 55 56 |
# File 'src/lib/installation/widgets/product_selector.rb', line 54 def label _("Product to Install") end |
#offline_product_selected? ⇒ Boolean
has been an offline installation product selected?
102 103 104 |
# File 'src/lib/installation/widgets/product_selector.rb', line 102 def offline_product_selected? Y2Packager::MediumType.offline? && products.any?(&:selected?) end |
#registered? ⇒ Boolean
Determine whether the system is registered
93 94 95 96 97 98 |
# File 'src/lib/installation/widgets/product_selector.rb', line 93 def registered? require "registration/registration" Registration::Registration.is_registered? rescue LoadError false end |
#skip_validation? ⇒ Boolean
Determine whether the validation should be skipped
88 89 90 |
# File 'src/lib/installation/widgets/product_selector.rb', line 88 def skip_validation? @skip_validation end |
#store ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'src/lib/installation/widgets/product_selector.rb', line 68 def store log.info "Selected product: #{value}" @product = products.find { |p| item_id(p) == value } log.info "Found product: #{@product}" return unless @product @product.select unless @product.selected? end |
#validate ⇒ Object
78 79 80 81 82 83 |
# File 'src/lib/installation/widgets/product_selector.rb', line 78 def validate return true if value || skip_validation? Yast::Popup.Error(_("Please select a product to install.")) false end |