Class: Y2Packager::Widgets::ProductLicenseConfirmation

Inherits:
CWM::CheckBox
  • Object
show all
Defined in:
src/lib/y2packager/widgets/product_license_confirmation.rb

Overview

Widget for product license confirmation

Presents a checkbox to confirm product's license. This widget will update the product's license confirmation status

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product, skip_validation: false) ⇒ ProductLicenseConfirmation

Constructor

Parameters:


33
34
35
36
37
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 33

def initialize(product, skip_validation: false)
  textdomain "packager"
  @product = product
  @skip_validation = skip_validation
end

Instance Attribute Details

#productY2Packager::Product (readonly)

Returns Product

Returns:


26
27
28
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 26

def product
  @product
end

#skip_validationBoolean (readonly)

Returns Skip value validation

Returns:

  • (Boolean)

    Skip value validation


28
29
30
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 28

def skip_validation
  @skip_validation
end

Instance Method Details

#handleObject

Handle value changes

See Also:

  • CWM::AbstractWidget#handle
  • #store

66
67
68
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 66

def handle
  store
end

#initObject

Widget value initializer

See Also:

  • CWM::AbstractWidget#init

58
59
60
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 58

def init
  product.license_confirmed? ? check : uncheck
end

#labelString

Widget label

Returns:

  • (String)

    Translated label

See Also:

  • CWM::AbstractWidget#label

43
44
45
46
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 43

def label
  # license agreement check box label
  _("I &Agree to the License Terms.")
end

#optObject

Widget options

See Also:

  • CWM::AbstractWidget#opt

51
52
53
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 51

def opt
  [:notify]
end

#storeObject

Update product license confirmation status

See Also:

  • CWM::AbstractWidget#store
  • Product#license_confirmation

74
75
76
77
78
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 74

def store
  return if product.license_confirmed? == value
  product.license_confirmation = value
  nil
end

#validateBoolean

Validate value

The value is not valid if license is required but not confirmed. This method shows an error if validation fails.

Returns:

  • (Boolean)

    true if the value is valid; false otherwise

See Also:

  • CWM::AbstractWidget#validate

87
88
89
90
91
92
93
94
# File 'src/lib/y2packager/widgets/product_license_confirmation.rb', line 87

def validate
  if skip_validation || !product.license_confirmation_required? || product.license_confirmed?
    return true
  end

  Yast::Report.Message(_("You must accept the license to install this product"))
  false
end