Class: Marty::SimpleApp

Inherits:
Netzke::Base
  • Object
show all
Defined in:
app/components/marty/simple_app.rb

Overview

Basis for a Ext.container.Viewport-based one-page application.

Features:

  • dynamic loading of components

  • browser history support (press the “Back”-button to go to the previously loaded component)

  • AJAX activity indicator

Extending SimpleApp

You may want to extend SimpleApp to provide a custom layout. Make sure you create three regions with predefined itemId’s that will be used by SimpleApp. You can use the following methods defined by SimpleApp: main_panel_config, status_bar_config, and menu_bar_config, e.g.:

class MySimpleApp < Netzke::Basepack::SimpleApp

  def configuration
    super.merge(
      :items => [my_custom_navigation_config, main_panel_config, menu_bar_config, status_bar_config]
    )
  end

  def my_custom_navigation_config
    {
      :item_id => 'navigation',
      :region => :east,
      :width => 200
    }
  end

  ...
end

The JS side of the component will have those regions referenced as this.mainPanel, this.statusBar, and this.menuBar.

Direct Known Subclasses

AuthApp

Instance Method Summary collapse

Instance Method Details

#configure(c) ⇒ Object



39
40
41
42
# File 'app/components/marty/simple_app.rb', line 39

def configure(c)
  super
  c.items = [main_panel_config, menu_bar_config, status_bar_config]
end

#js_component_htmlObject

Html required for Ext.History to work



89
90
91
92
93
94
95
96
# File 'app/components/marty/simple_app.rb', line 89

def js_component_html
  super << %Q{
<form id="history-form" class="x-hidden">
<input type="hidden" id="x-history-field" />
<iframe id="x-history-frame"></iframe>
</form>
  }
end

#js_component_renderObject

In Ext 4.1 calling ‘render` on a viewport causes an error



45
46
47
# File 'app/components/marty/simple_app.rb', line 45

def js_component_render
  ""
end

#main_panel_config(overrides = {}) ⇒ Object

Config for the main panel, which will contain dynamically loaded components.



55
56
57
58
59
60
61
# File 'app/components/marty/simple_app.rb', line 55

def main_panel_config(overrides = {})
  {
    :itemId => 'main_panel',
    :region => 'center',
    :layout => 'fit'
  }.merge(overrides)
end

Override for custom menu



50
51
52
# File 'app/components/marty/simple_app.rb', line 50

def menu
  []
end

Config for the menu bar



78
79
80
81
82
83
84
85
86
# File 'app/components/marty/simple_app.rb', line 78

def menu_bar_config(overrides = {})
  {
    :itemId => 'menu_bar',
    :xtype => 'toolbar',
    :region => 'north',
    :height => 28,
    :items => menu
  }.merge(overrides)
end

#status_bar_config(overrides = {}) ⇒ Object

Config for the status bar



64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/components/marty/simple_app.rb', line 64

def status_bar_config(overrides = {})
  {
    :itemId => 'status_bar',
    :xtype => 'statusbar',
    :region => 'south',
    :height => 22,
    :statusAlign => 'right',
    :busyText => 'Busy...',
    :default_text => "Ready",
    :default_icon_cls => ""
  }.merge(overrides)
end