Class: Aidp::Harness::UI::Navigation::SubMenu
- Inherits:
-
MainMenu
show all
- Defined in:
- lib/aidp/harness/ui/navigation/submenu.rb
Overview
Specialized submenu for drill-down functionality
Defined Under Namespace
Classes: InvalidSubMenuError, SubMenuError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from MainMenu
#add_menu_item, #add_menu_items, #at_root?, #can_navigate_back?, #clear_navigation_history, #current_path, #current_section, #display_breadcrumb, #display_menu, #display_navigation_help, #get_breadcrumb_path, #get_navigation_history, #get_user_input, #go_back, #menu_depth, #navigate_back, #navigate_to, #navigate_to_root, #navigate_to_submenu, #navigation_depth, #select_option, #show_menu
Constructor Details
#initialize(title, parent_menu = nil, ui_components = {}) ⇒ SubMenu
Returns a new instance of SubMenu.
15
16
17
18
19
20
21
22
23
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 15
def initialize(title, = nil, ui_components = {})
super(ui_components)
@title = title
=
@ui_components = ui_components
= []
@drill_down_enabled = true
@max_depth = 5
end
|
Instance Attribute Details
#drill_down_enabled ⇒ Object
Returns the value of attribute drill_down_enabled.
26
27
28
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 26
def drill_down_enabled
@drill_down_enabled
end
|
#max_depth ⇒ Object
Returns the value of attribute max_depth.
26
27
28
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 26
def max_depth
@max_depth
end
|
Returns the value of attribute parent_menu.
25
26
27
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 25
def
end
|
#title ⇒ Object
Returns the value of attribute title.
25
26
27
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 25
def title
@title
end
|
Instance Method Details
28
29
30
31
32
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 28
def (item)
(item)
<< item
(item)
end
|
34
35
36
37
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 34
def (items)
(items)
items.each { |item| (item) }
end
|
49
50
51
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 49
def
@drill_down_enabled && .any? && within_depth_limit?
end
|
81
82
83
84
85
86
87
88
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 81
def (title)
validate_title(title)
raise , "Maximum depth reached" unless within_depth_limit?
= .new(title, self, @ui_components)
.max_depth = @max_depth
end
|
#get_full_path ⇒ Object
75
76
77
78
79
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 75
def get_full_path
parent_path = get_parent_path
parent_path << @title
parent_path
end
|
#get_parent_path ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 61
def get_parent_path
return [] unless has_parent?
path = [@title]
current_parent =
while current_parent&.
path.unshift(current_parent.title)
current_parent = current_parent.
end
path
end
|
#has_parent? ⇒ Boolean
57
58
59
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 57
def has_parent?
!.nil?
end
|
#navigate_to_parent ⇒ Object
90
91
92
93
94
95
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 90
def navigate_to_parent
return false unless has_parent?
.(.title)
true
end
|
39
40
41
42
43
44
45
46
47
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 39
def
return unless
handle_submenu_interaction
rescue => e
raise , "Failed to show submenu: #{e.message}"
end
|
#within_depth_limit? ⇒ Boolean
53
54
55
|
# File 'lib/aidp/harness/ui/navigation/submenu.rb', line 53
def within_depth_limit?
@current_level < @max_depth
end
|