1. #21
    Ext User
    Join Date
    Sep 2009
    Posts
    1
    Vote Rating
    0
    quorak is on a distinguished road

      0  

    Default


    Quote Originally Posted by ttsuchi View Post
    Thanks for the gem! I'm starting to take a look at the gem today. One thing I noticed it is that it doesn't support namespaced controllers yet... (Well, I'm sure there're lots of things that's not supported yet, but this was the first roadblock I encountered.) I want to use it under my "/admin/*" URL, and so want to invoke Admin::SomeController instead.
    Any chance to make this a feature?
    I think this setup is quite likely as extjs is great for admin interfaces!

    best

  2. #22
    Ext User
    Join Date
    Mar 2008
    Posts
    2
    Vote Rating
    0
    kampnerj is on a distinguished road

      0  

    Default formHandler?

    formHandler?


    Is this going to support the formHandler option at some point soon?

  3. #23
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Philadelphia, PA
    Posts
    15
    Vote Rating
    0
    plaak is on a distinguished road

      0  

    Exclamation FYI

    FYI


    Not quite sure I know why this is happening now...

    This gem is causing non-direct requests on actions I am not using with direct but which share a controller to get intercepted somehow and strip the params hash to zero. At first it seemed that setting direct_actions for just those specific direct actions fixed the problem...but apparently not. I have sort of fixed this by directly patching lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb and commenting out the delete call in the params.each loop...

    I presume the point of this function of clearing out params on a Direct request is to ensure it is pristine when the values are provided to the controller.... but I'm not quite sure why it's doing this for non-direct requests or if I have something mis-configured somehow???
    Last edited by plaak; 14 Jan 2010 at 10:25 PM. Reason: Ugg...

  4. #24
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    Quote Originally Posted by edspencer View Post
    Or, you could monkey patch it

    PHP Code:
    (function() {
      var 
    originalGetCallData Ext.direct.RemotingProvider.prototype.getCallData;
      
      
    Ext.override(Ext.direct.RemotingProvider, {
        
    getCallData: function(t) {
          var 
    defaults originalGetCallData.apply(thisarguments);
          
          return 
    Ext.apply(defaults, {
            
    authenticity_token'<%= form_authenticity_token %>'
          
    });
        }
      })
    })(); 
    The main reason for doing it this way is the override won't break if some important property is added or removed from the returned object in the original getCallData function, we just decorate it instead.

    I find this pattern coming up most times I override... perhaps we should have a build in function for it - something like:

    PHP Code:
    Ext.decorate(Ext.direct.RemotingProvider'getCallData', {
      
    authenticity_token'<%= form_authenticity_token %>'
    }); 
    Which does the same as my first example, and is powered by:

    PHP Code:
    /**
     * @param {Function} klass The constructor function of the class to override (e.g. Ext.direct.RemotingProvider)
     * @param {String} property The name of the property the function to override is tied to on the klass' prototype
     * @param {Object} config An object that is Ext.apply'd to the usual return value of the function before returning
     */
    Ext.decorate = function(klasspropertyconfig) {
      var 
    original klass.prototype[property];
          
    override = {};
      
      
    override[property] = function() {
        var 
    value original.apply(thisarguments);
        
        return 
    Ext.apply(valueconfig);
      };
      
      
    Ext.override(klassoverride);

    One could probably use Ext's Function methods to do the same job.
    That is pretty specific. We can create another Ext Function prototype that is similar to createSequence, but will receive the return value from the preceding function and return the result of the sequenced function, and then we can "decorate" accordingly but still have a nice generically usable Ext Function method.

    Note, the name is arbitrary :-)

    PHP Code:
    Function.prototype.createFullSequence = function(fcnscope){
        var 
    method this;
        return !
    Ext.isFunction(fcn) ?
            
    this :
            function(){
                var 
    retval method.apply(this || windowarguments);
                return 
    fcn.apply(scope || this || window, [retval].concat(arguments));
            };
    }; 
    We can now decorate:

    PHP Code:
      Ext.override(Ext.direct.RemotingProvider, {
        
    getCallDataExt.direct.RemotingProvider.prototype.getCallData.createFullSequence(function(defaults){
          return 
    Ext.apply(defaults, {
            
    authenticity_token'<%= form_authenticity_token %>'
          
    });
        })
      }); 

  5. #25
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    Quote Originally Posted by plaak View Post
    Not quite sure I know why this is happening now...

    This gem is causing non-direct requests on actions I am not using with direct but which share a controller to get intercepted somehow and strip the params hash to zero. At first it seemed that setting direct_actions for just those specific direct actions fixed the problem...but apparently not. I have sort of fixed this by directly patching lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb and commenting out the delete call in the params.each loop...

    I presume the point of this function of clearing out params on a Direct request is to ensure it is pristine when the values are provided to the controller.... but I'm not quite sure why it's doing this for non-direct requests or if I have something mis-configured somehow???
    The mixin module doesn't check to see if the current action for that controller is one specified as a direct_action. The solution to the issue is to put a condition on the :extjs_direct_prepare_request before_filter that makes sure the currently requested action is one located in the extjs_direct_actions collection.

    Should be an easy patch. If I didn't have to run now I would patch it real quick myself :-) I'll check back here tonight and if no one's posted a patch then I will do so for sure.

    Edit: This makes me wonder (as I'm not an avid Ext.Direct user yet) what happens on Ext.Direct file uploads...is the file located in the "data" parameter, or what? If it's not in the "data" parameter then the file is surely stripped out of the params. I'll be messing with this later, although I wouldn't have ended up using Ext.Direct to post a file anyways :-)

  6. #26
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    Ok, here's my untested and unverified patch of direct_controller.rb, so that it first makes sure that the action that's about to run is an extjs_direct_action before preparing the direct request.

    PHP Code:
    --- direct_controller.rb    2010-01-14 23:52:46.733031060 -0500
    +++ direct_controller.fixed.rb    2010-01-15 21:39:26.564751681 -0500
    @@ -3,+3,@@
         
    def self.included(base)
           
    base.class_eval do
             
    cattr_accessor :extjs_direct_actions
    -        before_filter :extjs_direct_prepare_request
    +        before_filter do |controller|
    +          
    controller.extjs_direct_prepare_request if controller.extjs_direct_action?
    +        
    end
     
             
    # include the Helper @see helpers/direct_controller_helper.rb
             
    helper Helper
    @@ -18,+20,10 @@
           
    end
         end
     
    +    def extjs_direct_action?
    +      
    self.extjs_direct_actions.any? { |aa[:name].to_s == params[:action] }
    +    
    end
    +
         
    def extjs_direct_prepare_request
             
    #TODO just populate params with the XRequest data. 
    Edit: I'd be happy to maintain the rails extjs direct adapter if I were given SVN access, w/ prior approvals of checkins of course. Chris Scott I'll contact you personally, or I'll have Aaron Conran reach you

  7. #27
    Ext JS Premium Member
    Join Date
    Feb 2010
    Location
    Melbourne, Australia
    Posts
    9
    Vote Rating
    0
    markmansour is on a distinguished road

      0  

    Default


    I believe the code is available on github.

    http://github.com/extjs/direct

    You can fork the project, make your own changes, check them back into your own repository, and then the maintainer (Chris) can 'pull' the changes back in.

    Mark
    --
    Mark Mansour
    Founder, Agile Bench
    http://agilebench.com/

  8. #28
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    380
    Vote Rating
    0
    christocracy is on a distinguished road

      0  

    Default


    Anyone interested in Direct for Rails should check out active-direct.
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $120USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

  9. #29
    Ext User
    Join Date
    Feb 2010
    Posts
    1
    Vote Rating
    0
    x1am is on a distinguished road

      0  

    Default rails active-direct

    rails active-direct


    I've installed rails active-direct plugin, though can't get it running properly.
    This is what I get on firebug:
    >>> App.models.Customer.all();
    POST http://localhost:3000/direct_router 200 OK 17ms jquery...4618017 (5090)
    JSON
    Code:
    [{
    "result":[{
      "customer:{
        "name":"test1",
        "comment":"",
        "created_at":"2010-02-01T07:47:34Z",
        "updated_at":"2010-02-04T10:27:31Z",
        "id":3
      }
    },{
      "customer":{
        "name":"test2...",
        "comment":"comment here",
        "created_at":"2010-02-03T07:48:38Z",
        "updated_at":"2010-02-04T10:27:20Z",
        "id":6
      }
    }],
    "method":"all",
    "action":"Customer",
    "tid":4,
    "type":"rpc"
    }
    ]
    though function returns nothing, and store never gets loaded with following code
    Code:
    <script>
    var store = new Ext.data.DirectStore({
        storeId:'customers',
        api: {read: App.models.Customer.all},
        autoLoad: true,
        fields: [ 'name','comment']
    });
    </script>
    could anyone please advise on how to use this router correctly?

  10. #30
    Sencha User
    Join Date
    Jan 2008
    Location
    Romania
    Posts
    23
    Vote Rating
    0
    chriss is on a distinguished road

      0  

    Default


    Quote Originally Posted by quorak View Post
    Any chance to make this a feature?
    I think this setup is quite likely as extjs is great for admin interfaces!

    best
    I had the same problem, and here is what i did

    override some ext.direct methods

    Code:
    Ext.override(Ext.direct.RemotingProvider,{
    
    
         doCall : function(c, m, args){
            var data = null, hs = args[m.len], scope = args[m.len+1];
    
            if(m.len !== 0){
                data = args.slice(0, m.len);
            }
    
            var t = new Ext.Direct.Transaction({
                provider: this,
                args: args,
                action: c,
                method: m.name,
                namespace: m.namespace,
                data: data,
                cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs
            });
    
            if(this.fireEvent('beforecall', this, t) !== false){
                Ext.Direct.addTransaction(t);
                this.queueTransaction(t);
                this.fireEvent('call', this, t);
            }
        },
    
        doForm : function(c, m, form, callback, scope){
            var t = new Ext.Direct.Transaction({
                provider: this,
                action: c,
                method: m.name,
                namespace: m.namespace,
                args:[form, callback, scope],
                cb: scope && Ext.isFunction(callback) ? callback.createDelegate(scope) : callback,
                isForm: true
            });
    
            if(this.fireEvent('beforecall', this, t) !== false){
                Ext.Direct.addTransaction(t);
                var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',
                    params = {
                        extTID: t.tid,
                        extAction: c,
                        extMethod: m.name,
                        extType: 'rpc',
                        extUpload: String(isUpload)
                    };
                
                // change made from typeof callback check to callback.params
                // to support addl param passing in DirectSubmit EAC 6/2
                Ext.apply(t, {
                    form: Ext.getDom(form),
                    isUpload: isUpload,
                    params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params
                });
                this.fireEvent('call', this, t);
                this.processForm(t);
            }
        },
    
        
        getCallData: function(t){
    
            console.log(t)
            return {
                action: t.action,
                method: t.method,
                data: t.data,
                type: 'rpc',
                tid: t.tid,
                namespace: t.namespace || ''
            };
        }
        
    })
    modify Rails::ExtJS:irect::RemotingProvider call method, so now contains this

    Code:
    controller = req.delete("action").strip.downcase
    action =  req.delete("method").strip.downcase
    ns = req.delete("namespace").strip.downcase
    controller = [ns, controller].join("/") if !ns.blank?
    And now i can define my provider like this

    Code:
    Ext.Direct.addProvider({
        type:"remoting",
        url:"/direct",
        actions:{
            "main":[{
                "name":"load", 
                "len":1,
                'namespace':'ruby_namespace'
            }]
        },
        "namespace":"js_namespace"
    })

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar