Module: OMF::Web::Tab
- Defined in:
- lib/omf_web.rb,
lib/omf-web/UNUSED/tab.rb,
lib/omf-web/UNUSED/tab/abstract_service.rb
Defined Under Namespace
Modules: Code, Graph, Log, TabbedWidgets, TwoColumn
Classes: AbstractService
Constant Summary
collapse
- @@available_tabs =
{}
- @@selected_tabs =
{}
Class Method Summary
collapse
Class Method Details
.available_tabs ⇒ Object
Return an array of available tabs. The array is ordered in declared tab priority
73
74
75
76
77
|
# File 'lib/omf-web/UNUSED/tab.rb', line 73
def self.available_tabs()
@@available_tabs.values.sort do |a, b|
(a[:priority] || 1000) <=> (b[:priority] || 1000)
end
end
|
.create_tab(name) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/omf-web/UNUSED/tab.rb', line 26
def self.create_tab(name)
unless td = @@available_tabs[name.to_sym]
raise "Can't create unknown tab '#{name}'"
end
unless tklass = td[:class]
unless type = td[:type]
raise "Can't find 'type' definition for tab '#{name}"
end
unless pt = @@available_tabs[type.to_sym]
raise "Unknown tab type '#{type}':()#{@@available_tabs.keys.inspect}"
end
unless tklass = pt[:class]
raise "Don't know which class to use for tab '#{name}/#{type}'"
end
end
tklass.new(name, td[:topts] || {})
end
|
.default_tabs ⇒ Object
Return an array of tabs wiht their ‘:def_enabled’ set to true. The array is ordered in declared tab priority
62
63
64
65
66
67
68
|
# File 'lib/omf-web/UNUSED/tab.rb', line 62
def self.default_tabs()
@@available_tabs.values.select do |t|
t[:def_enabled]
end.sort do |a, b|
(a[:priority] || 1000) <=> (b[:priority] || 1000)
end
end
|
.description_for(name) ⇒ Object
13
14
15
|
# File 'lib/omf-web/UNUSED/tab.rb', line 13
def self.description_for(name)
@@available_tabs[name]
end
|
.register_tab(tab_info) ⇒ Object
7
8
9
10
11
|
# File 'lib/omf-web/UNUSED/tab.rb', line 7
def self.register_tab(tab_info)
id = tab_info[:id] = tab_info[:id].to_sym
@@available_tabs[id] = tab_info
MObject.debug(:web, "Registered tab '#{id}'")
end
|
.selected_tabs(select_also = []) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/omf-web/UNUSED/tab.rb', line 45
def self.selected_tabs(select_also = [])
select_also.each {|tab_id| use_tab(tab_id) }
if @@selected_tabs.empty?
selected = default_tabs()
else
selected = @@selected_tabs.values
end
selected.sort do |a, b|
(a[:priority] || 1000) <=> (b[:priority] || 1000)
end
end
|
.use_tab(tab_id) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/omf-web/UNUSED/tab.rb', line 17
def self.use_tab(tab_id)
tab_id = tab_id.to_sym
unless tab = @@available_tabs[tab_id]
raise "Unknown tab '#{tab_id}'. Need to registered first"
end
MObject.debug 'web:tab', "Use tab '#{tab_id}'"
@@selected_tabs[tab_id] = tab
end
|