1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    69
    Vote Rating
    0
    mboreback is on a distinguished road

      0  

    Default Role base load of application component, is there a best practise fr this

    Role base load of application component, is there a best practise fr this


    I am transforming my application to a native extjs application and like to here if there is any best practise for role based load of application components like view and stores.

    At the moment I am considering to just disable components and stores not to be used for a role, by loading user credential as first thing and disable the components user should not have access to, but I am not sure that this is the best solution.

    Any hints for this.

  2. #2
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,260
    Vote Rating
    79
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    If your authorization schema is not too complex you can lauch different ViewPort, for example:

    Code:
    launch: function() {
    Ext.Ajax.request({
    	url : "./rest/datos/firmado",
    	method : "GET",
    	success : function(r) {
    		if (r.responseText == "0") {
    			// Suscriptor normal
    			Ext.create("AG.view.PrincipalNormal");
    		} else if (r.responseText == "1") {
    			// Suscriptor Moviclub
    			Ext.create("AG.view.PrincipalMoviclub");
    		} else {
    			DataUtils.startPage();
    		}
    	},
    	failure : function(){
    		DataUtils.startPage();
    	}
    });
    }
    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    69
    Vote Rating
    0
    mboreback is on a distinguished road

      0  

    Default


    One of my projects app.js file looks like below code, Some of the stores and some f the view should only be vissible to some people.
    Is it possible to dynamicaly add some of the store items and view items in the arrays below, and they should then be dynamicaly loaded.

    Any hints for doing this?


    Code:
    /*
     * File: app.js
     *
     * This file was generated by Sencha Designer version 2.0.0.
     * http://www.sencha.com/products/designer/
     *
     * This file requires use of the Sencha Touch 2.0.x library, under independent license.
     * License of Sencha Designer does not include license for Sencha Touch 2.0.x. For more
     * details see http://www.sencha.com/license or contact license@sencha.com.
     *
     * This file will be auto-generated each and everytime you save your project.
     *
     * Do NOT hand edit this file.
     */
    
    
    Ext.Loader.setConfig({
        enabled: true
    });
    
    
    Ext.application({
        viewport: {
            autoMaximize: true
        },
    
    
        stores: [
            'AliasStore',
            'TimeStore',
            'MaterialsStore',
            'UserStore'
        ],
        views: [
            'ManPanel',
            'TimeReport',
            'ProjectDetails',
            'ProjectNav',
            'SendWo',
            'MaterialsReport',
            'ProjectListPanel'
        ],
        icon: 'img/logo32.png',
        name: 'MyLogo',
    
    
        launch: function() {
    
    
            Ext.create('MyApp.view.ManPanel', {fullscreen: true});
        }
    
    
    });

  4. #4
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,260
    Vote Rating
    79
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    Nope.

    Thats the reason I have a different view for different role.

    Of course nothing stops yoo to build manually in the launch method the config object of your main view, for example (bare bones):

    launch: function() {
    var items = [];
    if (condition) {
    items.push({xtype: "someviewalias"});
    }
    ...
    Ext.create("viewport", {...
    items: items
    });
    }

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    69
    Vote Rating
    0
    mboreback is on a distinguished road

      0  

    Default


    This looks like a good solution, it is then possible to after a login add objects dynamicaly from a datastore
    But to make this workl, the load of this has to be done after the first login view has commitet and in the success function.
    Is that possible to force the application at that point to load the addional views and stores for this authorization group

Thread Participants: 1