Results 1 to 5 of 5

Thread: Model namespace and class folder structure

  1. #1
    Sencha User
    Join Date
    Mar 2016
    Posts
    39
    Answers
    1

    Default Model namespace and class folder structure

    Hello!

    I have this model folder structure:
    Code:
    - app       
        - model                                        
            - employees                                
                - Employees.js                                                                   
            - dictionaries              
                - positions
                    - Positions.js                              
        - Base.js
    So I have 'MyApp.model.dictionaries.positions.Positions' and 'MyApp.model.employees.Employees' class names.

    Base.js content:
    PHP Code:
    Ext.define('MyApp.model.Base', {    
        
    extend'Ext.data.Model',
        
    schema: {        
            namespace: 
    'MyApp.model'
        }
    }); 
    So my entityName of both class becomes 'dictionaries.positions.Positions' and 'employees.Employees'. How can I change them to simple 'Positions' and 'Employees' etc without setting entityName property in each file?

    Also if I add some lines to schema section, my api url becomes broken:
    PHP Code:
    proxy: {
        
    type'api',
        
    urlMyApp.Global.getApiUrl() + 'api/v1/{entityName:uncapitalize}'        

    Maybe I can also use regex here to get name after the last dot? How?

  2. #2
    Sencha User
    Join Date
    Mar 2016
    Posts
    39
    Answers
    1

    Default

    I found some info in docs:
    http://docs.sencha.com/extjs/6.2.0/m...ng-conventions

    Looks like I need to use custom Namer:
    http://docs.sencha.com/extjs/6.2.0/c...ema.Namer.html

    But I found no examples in docs...

  3. #3
    Sencha User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,748
    Answers
    55

    Default

    Have you tried just setting the entityName (http://docs.sencha.com/extjs/6.2.0/c...rty-entityName) property on the model class?

    The Namer is useful for generating entity names from class names (and other names as well), but if you supply your own name that should be used instead of the namer's algorithm.
    Don Griffin

    "Use the source, Luke!"

  4. #4
    Sencha User
    Join Date
    Mar 2016
    Posts
    39
    Answers
    1

    Default

    Quote Originally Posted by dongryphon View Post
    Have you tried just setting the entityName (http://docs.sencha.com/extjs/6.2.0/c...rty-entityName) property on the model class?
    Yes, I use it now.
    But my question was about additional things that I can do with value in base model class in `{}` (RegEx, for example), without setting entityName in every model class.

    Quote Originally Posted by dongryphon View Post
    The Namer is useful for generating entity names from class names (and other names as well), but if you supply your own name that should be used instead of the namer's algorithm.
    I didn't find any example how to use Namer. I want to set entity names automatically after the last dot of my class names (employees0.Employees -> employees).

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759

    Default

    In this case I think you would need to override the schema getEntityName method. It seems as though the namer doesn't provide an a method to do this by default, possibly because the current name generation depends on the namespace.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Similar Threads

  1. Replies: 13
    Last Post: 13 Apr 2016, 7:55 AM
  2. Replies: 1
    Last Post: 30 Apr 2014, 6:17 PM
  3. [INFOREQ] 4.1 custom folder structure bug
    By mehran in forum Ext:Bugs
    Replies: 2
    Last Post: 8 May 2012, 1:15 AM
  4. MVC-Application Folder's Structure
    By rsqw in forum Ext: Discussion
    Replies: 4
    Last Post: 30 Nov 2011, 12:41 PM
  5. MVC in EXTJS4, folder structure?
    By koke in forum Ext: Discussion
    Replies: 6
    Last Post: 20 Nov 2011, 1:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •