daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Baseline.lib.WindowView = Ext.extend(Baseline.lib.BaseView, {
  2.   registered_forms: [],
  3.  
  4.   loadFormData: function(form) {
  5.     var params = form.getForm().getValues();
  6.     if (form.child_forms !== undefined) {
  7.       Ext.iterate(form.child_forms, function(key, value) {
  8.         if (Ext.isArray(value)) {
  9.           var array_params = [];
  10.           Ext.each(value, function(form) {
  11.             array_params.push(this.loadFormData(form));
  12.           }, this);
  13.           params[key] = array_params;
  14.         } else {
  15.           var form_params = value.getForm().getValues();
  16.           if (value.child_forms !== undefined) {
  17.             Ext.apply(form_params, this.loadFormData(form.child_forms));
  18.           }
  19.           params[key] = form_params;
  20.         }
  21.       }, this);
  22.     }
  23.  
  24.     return params;
  25.   },
  26.  
  27.   setFormData: function(data) {
  28.     Ext.each(this.registered_forms, function(registered_form) {
  29.       if(data[registered_form.params_key]){
  30.         registered_form.getForm().setValues(data[registered_form.params_key]);
  31.       }
  32.     }, this);
  33.   },
  34.  
  35.   getParams : function() {
  36.     var params = {};
  37.     Ext.each(this.registered_forms, function(registered_form) {
  38.       var params_key = registered_form.params_key || 'object';
  39.       params[params_key] = this.loadFormData(registered_form);
  40.     }, this);
  41.     return params;
  42.   },
  43.  
  44.   readOnly : function() {
  45.     var fields = this.view.findBy(function(f) {
  46.       if(f.isXType('field') && !f.isXType('radio')){
  47.         return true;
  48.       }
  49.     });
  50.     Ext.each(fields, function(f){
  51.       f.disable();
  52.     })
  53.   },
  54.  
  55.   register : function(form) {
  56.     this.registered_forms.push(form);
  57.   },
  58.  
  59.   /** controller view **/
  60.   index: function() {
  61.     if (!Baseline.Layout.card.items.containsKey(this.ae_id)) {
  62.       var panel = ActiveExt.get(this.ae_id).panel;
  63.       Baseline.Layout.addAndSetActivePanel(panel);
  64.     } else {
  65.       Baseline.Layout.setActivePanel(this.ae_id);
  66.     }
  67.   }
  68.  
  69. })
RAW Paste Data
Top