This duplicates another bug already reported in our system: TOUCH-1826
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    16
    Vote Rating
    0
    widged is on a distinguished road

      0  

    Default [b1] Custom Paths to views not working

    [b1] Custom Paths to views not working


    pr4 had broken the custom path functionality (bug report)

    Beta 1 appears to load controllers from a custom path but not views.

    In the main app controller

    Code:
    views : [ 'AppName.path.to.customView' ]
    Attempts to load the view from:
    Code:
    appFolder/view/AppName/path/to/customView.js
    When the custom path is assumed to point at :
    Code:
    appFolder/path/to/customView.js

  2. #2
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    21
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    16
    Vote Rating
    0
    widged is on a distinguished road

      0  

    Default


    Could you also check consistency in the logic.

    In this reply, it was stated

    The basic rule is if the string you specify contains a period (".") we will treat it as a fully qualified class name and just load it as normal. If it doesn't contain a period we'll add the app namespace for you automatically as before.
    If you look at applyControllers, the expected check is found

    Code:
    if (!name.match('\\.')) {
       controllers[i] = appName + '.controller.' + name;
    }
    But if you look at getController, you don't find that check:

    Code:
    if (name instanceof Ext.app.Controller) {
        return name;
    }
    
    
    if (instances[name]) {
        return instances[name];
    } else {
        topLevelName = format("{0}.controller.{1}", appName, name);
        profileName  = format("{0}.controller.{1}.{2}", appName, profileName, name);
    
    
        return instances[profileName] || instances[topLevelName];
    }
    How can you get a reference to a specific listed in the requires property, for instance to to call a function of that controller within the init block (of the loading container). Using controllers[i]? Not an option that would help with maintainable code.

    And then in loadControllerDependencies, the pr4 strict way of referencing
    Code:
    Ext.each(proto.models, function(modelName) {
        classes.push(format('{0}.model.{1}', name, modelName));
    }, this);
    
    
    Ext.each(proto.views, function(viewName) {
        classes.push(format('{0}.view.{1}', name, viewName));
    }, this);
    
    
    Ext.each(proto.stores, function(storeName) {
        classes.push(format('{0}.store.{1}', name, storeName));
        this.setStores(this.getStores().concat([storeName]));
    }, this);

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

      0  

    Default


    This changed for b2 to make it more forgiving of what you pass it. I have a pretty exhaustive test case that is passing - looks like this:

    Code:
    Ext.application({
        name: 'MyApp',
        
        controllers: [
            'LocallyQualified',
            'MyApp.controller.FullyQualified',
            'MyApp.controller.deeply.Nested',
            'CustomNS.controller.Custom',
            'deeply.LocallyQualified'
        ],
        
        stores: [
            'LocallyQualified',
            'MyApp.store.FullyQualified',
            'MyApp.store.deeply.Nested',
            'CustomNS.store.Custom',
            'deeply.LocallyQualified'
        ],
        
        models: [
            'LocallyQualified',
            'MyApp.model.FullyQualified',
            'MyApp.model.deeply.Nested',
            'CustomNS.model.Custom',
            'deeply.LocallyQualified'
        ],
        
        views: [
            'LocallyQualified',
            'MyApp.view.FullyQualified',
            'MyApp.view.deeply.Nested',
            'CustomNS.view.Custom',
            'deeply.LocallyQualified'
        ],
        
        profiles: [
            'Phone',
            'MyApp.profile.Tablet',
            'CustomNS.profile.Custom',
            'deeply.LocallyQualified'
        ],
        
        launch: function() {
            var controllers = this.getControllerInstances(),
                stores = this.getStores(),
                errors = [];
            
            var expectedControllers = [
                'MyApp.controller.FullyQualified',
                'MyApp.controller.LocallyQualified',
                'MyApp.controller.deeply.Nested',
                'CustomNS.controller.Custom',
                'MyApp.controller.deeply.LocallyQualified'
            ];
            
            var expectedStores = [
                'MyApp.store.LocallyQualified',
                'MyApp.store.FullyQualified',
                'MyApp.store.deeply.Nested',
                'CustomNS.store.Custom',
                'MyApp.store.deeply.LocallyQualified'
            ];
            
            var expectedModels = [
                'MyApp.model.LocallyQualified',
                'MyApp.model.FullyQualified',
                'MyApp.model.deeply.Nested',
                'CustomNS.model.Custom',
                'MyApp.model.deeply.LocallyQualified'
            ];
            
            var expectedViews = [
                'MyApp.view.LocallyQualified',
                'MyApp.view.FullyQualified',
                'MyApp.view.deeply.Nested',
                'CustomNS.view.Custom',
                'MyApp.view.deeply.LocallyQualified'
            ];
            
            var expectedProfiles = [
                'MyApp.profile.Phone',
                'MyApp.profile.Tablet',
                'CustomNS.profile.Custom',
                'MyApp.profile.deeply.LocallyQualified'
            ];
            
            Ext.each(expectedControllers, function(name) {
                if (!controllers[name]) {
                    errors.push(name + " should have been loaded but was not");
                }
            }, this);
            
            Ext.each(expectedStores, function(name, index) {
                if (!(stores[index] instanceof Ext.ClassManager.classes[name])) {
                    errors.push("Expected " + name + " to be ready");
                }
            }, this);
            
            Ext.each(expectedModels, function(name) {
                if (!Ext.ClassManager.classes[name]) {
                    errors.push("Expected Model " + name + " to be defined");
                }
            }, this);
            
            Ext.each(expectedViews, function(name) {
                if (!Ext.ClassManager.classes[name]) {
                    errors.push("Expected View " + name + " to be defined");
                }
            }, this);
            
            Ext.each(expectedProfiles, function(name) {
                if (!Ext.ClassManager.classes[name]) {
                    errors.push("Expected Profile " + name + " to be defined");
                }
            }, this);
            
            if (errors.length) {
                Ext.each(errors, function(e) {
                    console.error(e);
                });
            } else {
                console.log('Everything seemed to load ok');
            }
            
            this.dispatch({
                controller: 'FullyQualified',
                action: 'someFunction',
                args: ['arg1', 'arg2']
            });
        }
    });
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

Thread Participants: 2