Module: Netzke::BasicApp::ClassMethods

Included in:
Netzke::BasicApp
Defined in:
lib/netzke/basic_app.rb

Instance Method Summary collapse

Instance Method Details

#configObject

Global BasicApp configuration



21
22
23
24
25
# File 'lib/netzke/basic_app.rb', line 21

def config
  set_default_config({
    :logout_url => "/logout" # default logout url
  })
end

#js_base_classObject



16
17
18
# File 'lib/netzke/basic_app.rb', line 16

def js_base_class
  "Ext.Viewport"
end

#js_extend_propertiesObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/netzke/basic_app.rb', line 60

def js_extend_properties
  {
    :layout => 'border',

    :panels => js_panels,
    
    :init_component => <<-END_OF_JAVASCRIPT.l,
    
    :host_menu => <<-END_OF_JAVASCRIPT.l,

    :unhost_menu => <<-END_OF_JAVASCRIPT.l,

    :logout => <<-END_OF_JAVASCRIPT.l,
      function(){
        window.location = "#{config[:logout_url]}"
      }
    END_OF_JAVASCRIPT

    # Event handler for history change
    :process_history => <<-END_OF_JAVASCRIPT.l,
    
    :instantiate_aggregatee => <<-END_OF_JAVASCRIPT.l,
      function(config){
        this.findById('main-panel').instantiateChild(config);
      }
    END_OF_JAVASCRIPT
    
    # Loads widget by name
    :app_load_widget => <<-END_OF_JAVASCRIPT.l,
      function(name){
        Ext.History.add(name);
      }
    END_OF_JAVASCRIPT

    # Loads widget by action
    :load_widget_by_action => <<-END_OF_JAVASCRIPT.l,
      function(action){
        this.appLoadWidget(action.widget || action.name);
      }
    END_OF_JAVASCRIPT
    
    # Masquerade selector window
    :show_masquerade_selector => <<-END_OF_JAVASCRIPT.l
      function(){
        var w = new Ext.Window({
  				title: 'Masquerade as',
  				modal: true,
  				width: Ext.lib.Dom.getViewWidth() * 0.6,
          height: Ext.lib.Dom.getViewHeight() * 0.6,
          layout: 'fit',
  	      closeAction :'destroy',
          buttons: [{
            text: 'Select',
            handler : function(){
              if (role = w.getWidget().masquerade.role) {
                Ext.Msg.confirm("Masquerading as a role", "Individual preferences for all users with this role will get overwritten as you make changes. Continue?", function(btn){
                  if (btn === 'yes') {
                    w.close();
                  }
                });
              } else {
                w.close();
              }
            },
            scope:this
          },{
            text:'As World',
            handler:function(){
              Ext.Msg.confirm("Masquerading as World", "Caution! All settings that you will modify will be ovewritten for all roles and all users. Are you sure you know what you're doing?", function(btn){
                if (btn === "yes") {
                  this.masquerade = {world:true};
                  w.close();
                }
              }, this);
            },
            scope:this
          },{
            text:'No masquerading',
            handler:function(){
              this.masquerade = {};
              w.close();
            },
            scope:this
          },{
            text:'Cansel',
            handler:function(){
              w.hide();
            },
            scope:this
          }],
          listeners : {close: {fn: function(){
            this.masqueradeAs(this.masquerade || w.getWidget().masquerade || {});
          }, scope: this}}
  			});

  			w.show(null, function(){
  			  this.loadAggregatee({id:"masqueradeSelector", container:w.id})
  			}, this);

      }
    END_OF_JAVASCRIPT
  }
end

#js_panelsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/netzke/basic_app.rb', line 27

def js_panels
  # In status bar we want to show what we are masquerading as
  if session[:masq_user]
    user = User.find(session[:masq_user])
    masq = %Q{user "#{user.}"}
  elsif session[:masq_role]
    role = Role.find(session[:masq_role])
    masq = %Q{role "#{role.name}"}
  elsif session[:masq_world]
    masq = %Q{World}
  end
          
  [{
    :id => 'main-panel',
    :region => 'center',
    :layout => 'fit'
  },{
    :id => 'main-toolbar',
    :xtype => 'toolbar',
    :region => 'north',
    :height => 25
    # :items => ["-"]
  },{
    :id => 'main-statusbar',
    :xtype => 'statusbar',
    :region => 'south',
    :statusAlign => 'right',
    :busyText => 'Busy...',
    :default_text => masq.nil? ? "Ready #{"(config mode)" if session[:config_mode]}" : "Masquerading as #{masq}",
    :default_icon_cls => ""
  }]
end