Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am using a pretty naive implementation... I'm sure it could be made more robust, but I've been hacking at this for 5 hours or so now.</p> <pre><code>Ext.define('MyApp.override.Application', { override : 'Ext.app.Application', onProfilesLoaded: function() { var profiles = this.getProfiles(), length = profiles.length, instances = [], requires = this.gatherDependencies(), current, i, profileDeps; for (i = 0; i &lt; length; i++) { var instance = Ext.create(profiles[i], { application: this }); /* * Note that we actually require all of the dependencies for all Profiles - this is so that we can produce * a single build file that will work on all defined Profiles. Although the other classes will be loaded, * the correct Profile will still be identified and the other classes ignored. While this feels somewhat * inefficient, the majority of the bulk of an application is likely to be the framework itself. The bigger * the app though, the bigger the effect of this inefficiency so ideally we will create a way to create and * load Profile-specific builds in a future release. * CMK - PSHAW! */ if (instance.isActive() &amp;&amp; !current) { console.log('Profile active: ' + instance.getName()); current = instance; profileDeps = instance.getDependencies(); requires = requires.concat(profileDeps.all); var ns = instance.getNamespace(); this.setCurrentProfile(current); // Merge Controllers, Models, Stores, and Views this.setControllers(this.getControllers().concat(profileDeps.controller)); this.setModels(this.getModels().concat(profileDeps.model)); this.setStores(this.getStores().concat(profileDeps.store)); this.setViews(this.getViews().concat(profileDeps.view)); // Remove the view ref and requires for default views, when a profile specific one exists Ext.each(profileDeps.view, function(className) { if (className.indexOf('view.' + ns + '.') !== -1) { // Requires var index = requires.indexOf(className.replace('view.' + ns, 'view')); if (index !== -1) { requires.splice(index, 1); } // Views index = this.getViews().indexOf(className.replace('view.' + ns, 'view')); if (index !== -1) { this.getViews().splice(index, 1); } } }, this); instances[0] = instance; break; } } this.setProfileInstances(instances); Ext.require(requires, this.loadControllerDependencies, this); } }); </code></pre> <p>Put this before your Ext.application, and it replaces the profile loader... This one strips out default views with the same name as one in the active profile namespace.</p> <p>It requires that you define an xtype for the views that match, then even your refs in controllers will work...</p> <p>I need to continue testing with this, but it looks promising so far.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload