partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

model.js.twig (2343B)


      1 Ext.define('{{ className }}', {
      2     extend: '{{ parentClass }}',
      3     alias: 'schema.{{ className }}',
      4 
      5     idProperty: "@id",
      6     fields: [
      7         {% for field in fields %}
      8         { name: '{{ field.name|raw }}'{% if field.type%}, type: '{{ field.type }}'{% endif %}{% if field.nullable%}, allowNull: true{% endif %}{% if not field.persist %}, persist: false{% endif %}{% if field.validators %}, validators: {{ field.validators|raw }}{% endif %}}{% if not loop.last %},{% endif %}
      9 
     10         {% endfor %}
     11         {% if associations.MANY_TO_ONE|length > 0 %}
     12             ,
     13             {% for association in associations.MANY_TO_ONE %}
     14                 { name: '{{ association.name }}',
     15                 reference: '{{ association.target }}',
     16             allowBlank: {% if association.nullable %}true{% else %}false{% endif %}
     17         {% if association.byReference %},byReference: true{% endif %}
     18                 }{% if not loop.last %},{% endif %}
     19 
     20             {% endfor %}
     21         {% endif %}
     22         {% if associations.ONE_TO_ONE|length > 0 %}
     23             ,
     24             {% for association in associations.ONE_TO_ONE %}
     25                 { name: '{{ association.name }}',
     26                 reference: '{{ association.target }}'
     27                 }{% if not loop.last %},{% endif %}
     28 
     29             {% endfor %}
     30         {% endif %}
     31 
     32     ],
     33 
     34     {% if associations.ONE_TO_MANY|length > 0 %}
     35     hasMany: [
     36     {% for association in associations.ONE_TO_MANY %}
     37         {
     38         name: '{{ association.name }}',
     39         associationKey: '{{ association.name }}',
     40         model: '{{ association.target }}'
     41         }{% if not loop.last %},{% endif %}
     42 
     43     {% endfor %}
     44     ],
     45     {% endif %}
     46 
     47     {% if associations.MANY_TO_MANY|length > 0 %}
     48     manyToMany: {
     49     {% for association in associations.MANY_TO_MANY %}
     50         {{ association.name }}: {
     51             type: '{{ association.target }}',
     52             role: '{{ association.name }}',
     53             field: '@id',
     54             right: true
     55         } {% if not loop.last %},{% endif %}
     56     {% endfor %}
     57     },
     58     {% endif %}
     59 
     60     proxy: {
     61         type: "Hydra",
     62         url: '{% if uri == "" %}undefined:{{ className }}{% else %}{{ uri|raw }}{% endif %}'
     63         {% if ignoreIds == true %}
     64         , ignoreIds: true
     65         {% endif %}
     66     }
     67 });
     68 
     69 PartKeepr.Data.Store.ModelStore.addModel('{{ className }}', '');