Sha256: 330ac30844ca383481650c86879259c50ce66391413b720f4750849ee49abf20

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

module Netzke
  class MasqueradeSelector < TabPanel

    def items
      @items ||= [{
          :name              => "roles",
          :active            => true,
          :class_name => "GridPanel",
          :model   => 'Role',
          :columns           => [:id, :name],
          :ext_config => {
            :header        => false,
            :bbar => ['search']
          }
        },{
          :name                 => "users",
          :preloaded            => true,
          :class_name    => "GridPanel",
          :model      => 'User',
          :ext_config           => {
            :header        => false,
            :rows_per_page => 10,
            :bbar => ['search']
          },
          :columns => [:id, :login]
      }]
    end

    def self.js_properties
      {
        :after_constructor => <<-END_OF_JAVASCRIPT.l,
          function(){
            this.items.each(function(tab){
              tab.on('add', function(ct, cmp){
                cmp.on('rowclick', this.rowclickHandler, this);
              }, this);
            }, this);
          }
        END_OF_JAVASCRIPT

        :rowclick_handler => <<-END_OF_JAVASCRIPT.l
          function(grid, rowIndex, e){
            var mode = grid.id.split("__").pop();
            var normMode = mode === 'users' ? 'user' : 'role';
            this.masquerade = {};
            this.masquerade[normMode] = grid.store.getAt(rowIndex).get('id');
          }
        END_OF_JAVASCRIPT
      }
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netzke-basepack-0.6.3 lib/netzke/masquerade_selector.rb
netzke-basepack-0.6.2 lib/netzke/masquerade_selector.rb
netzke-basepack-0.6.1 lib/netzke/masquerade_selector.rb