Class: Marty::SimpleApp

Inherits:
Netzke::Base 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

Methods inherited from Netzke::Base

#root_sess

Instance Method Details

#configure(c) ⇒ Object



54
55
56
57
# File 'app/components/marty/simple_app.rb', line 54

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



103
104
105
106
107
108
109
110
# File 'app/components/marty/simple_app.rb', line 103

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



60
61
62
# File 'app/components/marty/simple_app.rb', line 60

def js_component_render
  ''
end

#main_panel_config(overrides = {}) ⇒ Object

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



70
71
72
73
74
75
76
# File 'app/components/marty/simple_app.rb', line 70

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

Override for custom menu



65
66
67
# File 'app/components/marty/simple_app.rb', line 65

def menu
  []
end

Config for the menu bar



92
93
94
95
96
97
98
99
100
# File 'app/components/marty/simple_app.rb', line 92

def menu_bar_config(overrides = {})
  {
    itemId: 'menu_bar',
    layout: { overflow_handler: 'Menu' },
    xtype: 'toolbar',
    region: 'north',
    items: menu
  }.merge(overrides)
end

#status_bar_config(overrides = {}) ⇒ Object

Config for the status bar



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

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