1. #1
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default Extending dot notation for controllers and views

    Extending dot notation for controllers and views


    Hi team:

    Why isn't it possible to use namespaces to have sub-folders inside controllers and views in order to structure the application?

    controller/Products.js -> 'MyApp.controller.Products OK
    controller/Products/Detail.js - 'MyApp.controller.Products.Detail NOT OK

  2. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    It will work, but your class name 'packages' should be all lowercase: 'MyApp.controller.products..Detail'.

    More information about naming conventions here: http://docs.sencha.com/touch/2-0/#!/guide/class_system
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  3. #3
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default


    Quote Originally Posted by rdougan View Post
    It will work, but your class name 'packages' should be all lowercase: 'MyApp.controller.products..Detail'.

    More information about naming conventions here: http://docs.sencha.com/touch/2-0/#!/guide/class_system
    Yeah, I mean it should work, but not within the Router class where after "redirectTo" gets called, the part where "action.getController()" exists, it returns the last dot-delimited part only.

  4. #4
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    Touch 2.0 beta 1 is more forgiving over what you call your controllers, allowing the dot notation you specify there. If you migrate your app to b1 it should just work, if not I'll keep an eye on this thread.
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  5. #5
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default


    After taking a look, here...

    Code:
    applyRoutes: function(routes) {
            var app    = this instanceof Ext.app.Application ? this : this.getApplication(),
                router = app.getRouter(),
                parts  = this.$className.split('.'),
                url;
    
    
            for (url in routes) {
                router.connect(url, {
                    controller: parts[parts.length - 1],
                    action: routes[url]
                });
            }
    
    
            return routes;
        },
    So the fix/improvement would be something like:

    Code:
    Ext.filter(parts, function(chunk){
        return (!(app.getName() == chunk || 'controller' == chunk));
    });
    parts.join('')
    < not tested.

    ps: Solution could be more elegant

  6. #6
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default


    Quote Originally Posted by edspencer View Post
    Touch 2.0 beta 1 is more forgiving over what you call your controllers, allowing the dot notation you specify there. If you migrate your app to b1 it should just work, if not I'll keep an eye on this thread.
    Excellent then, I didn't see your reply while I was posting...

Thread Participants: 2