Skip to content

Commit

Permalink
WIP 5
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Feb 21, 2020
1 parent 0d95240 commit aa9e006
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 33 deletions.
6 changes: 5 additions & 1 deletion src/lib/registration/controllers/addons_selection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ def restore_selection
Addon.selected.replace(previous_selected_addons)
end

def details_options
def detail_options
{
placeholder: _("Select an extension or a module to show details here")
}
end

def master_options
{}
end

def include_filter?
!development_addons.empty?
end
Expand Down
6 changes: 5 additions & 1 deletion src/lib/registration/controllers/base_selection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def filter=(_enabled)
raise "Not implemented yet"
end

def details_options
def master_options
{}
end

def detail_options
{}
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/lib/registration/widgets/item_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
module Registration
module Widgets
class ItemDetails < CWM::RichText
def initialize(placeholder: "")
@placeholder = placeholder
def initialize(placeholder: nil)
@placeholder = placeholder || ""
end

def init
Expand Down
66 changes: 37 additions & 29 deletions src/lib/registration/widgets/master_detail_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class MasterDetailSelector < CWM::CustomWidget
include Yast::Logger
include Yast::UIShortcuts

DEFAULT_MASTER_VWEIGHT = 60
private_constant :DEFAULT_MASTER_VWEIGHT

DEFAULT_DETAIL_VWEIGHT = 40
private_constant :DEFAULT_DETAIL_VWEIGHT

def initialize(controller)
textdomain "registration"

Expand All @@ -46,8 +52,8 @@ def initialize(controller)
def contents
VBox(
filter,
checkbox_list_widget,
item_details
master_content,
detail_content
)
end

Expand Down Expand Up @@ -91,44 +97,46 @@ def handle(event)

attr_reader :controller

def filter
return Empty() unless controller.include_filter?

Left(
CheckBox(Id(:filter), Opt(:notify), controller.filter_label)
)
end

def master_content
vweight = controller.master_options.fetch(:vweight, DEFAULT_MASTER_VWEIGHT)

VWeight(
vweight,
checkbox_list_widget
)
end

def detail_content
vweight = controller.detail_options.fetch(:vweight, DEFAULT_DETAIL_VWEIGHT)

VWeight(
vweight,
item_details_widget
)
end

# Returns the widget to hold the selection list
#
# @return [Widgets::CheckboxList]
def checkbox_list_widget
@checkbox_list_widget ||= CheckboxList.new(initial_content: checkbox_list_items)
@checkbox_list_widget ||=
CheckboxList.new(initial_content: checkbox_list_items)
end

# Returns the widget to display an item details
#
# @return [Widgets::ItemDetails]
def item_details_widget
@item_details_widget ||=
begin
placeholder = controller.details_options.fetch(:placeholder, "")

ItemDetails.new(placeholder: placeholder)
end
end

def filter
return Empty() unless controller.include_filter?

Left(
CheckBox(Id(:filter), Opt(:notify), controller.filter_label)
)
end

def item_details
vweight = controller.details_options.fetch(:vweight, 25)
min_height = controller.details_options.fetch(:min_height, 8)

MinHeight(
min_height,
VWeight(
vweight,
item_details_widget
)
)
ItemDetails.new(placeholder: controller.detail_options[:placeholder])
end

def checkbox_list_items
Expand Down

0 comments on commit aa9e006

Please sign in to comment.