sync
[Pman.Admin] / Pman.Dialog.AdminEnumMerge.js
index 254f966..0e6f68e 100644 (file)
@@ -8,11 +8,13 @@ Pman.Dialog.AdminEnumMerge = {
 
  _strings : {
   '0b3e4317865feb6f0224397600b7cafc' :"Merge Core Enum",
-  'cfcd208495d565ef66e7dff9f98764da' :"0",
-  'c4ca4238a0b923820dcc509a6f75849b' :"1",
+  '03e956f1dca2b4d525df03cb1899cb6f' :"Merge with",
   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
   'e0aa021e21dddbd6d8cecec71e9cf564' :"OK"
  },
+ _named_strings : {
+  'merge_display_name_fieldLabel' : '03e956f1dca2b4d525df03cb1899cb6f' /* Merge with */ 
+ },
 
  dialog : false,
  callback:  false,
@@ -38,94 +40,91 @@ Pman.Dialog.AdminEnumMerge = {
  {
    var _this = this;
    this.dialog = Roo.factory({
-    center : {
-     '|xns' : 'Roo',
-     titlebar : false,
-     xns : Roo,
-     xtype : 'LayoutRegion'
-    },
-    '|xns' : 'Roo',
+    xtype : 'LayoutDialog',
     background : true,
     closable : false,
     collapsible : false,
     height : 150,
     modal : true,
     resizable : false,
-    title : _this._strings['0b3e4317865feb6f0224397600b7cafc'],
+    title : _this._strings['0b3e4317865feb6f0224397600b7cafc'] /* Merge Core Enum */,
     width : 400,
+    listeners : {
+     show : function (_self)
+      {
+          _this.merge.focus();
+      }
+    },
     xns : Roo,
-    xtype : 'LayoutDialog',
+    '|xns' : 'Roo',
+    center : {
+     xtype : 'LayoutRegion',
+     titlebar : false,
+     xns : Roo,
+     '|xns' : 'Roo'
+    },
     buttons : [
-      {
-       '|xns' : 'Roo',
-       text : _this._strings['ea4788705e6873b424c65e91c2846b19'],
-       xns : Roo,
-       xtype : 'Button',
-       listeners : {
-        click : function() {
-             _this.form.reset();
-             _this.dialog.hide();
-         }
-       }
+     {
+      xtype : 'Button',
+      text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
+      listeners : {
+       click : function() {
+            _this.form.reset();
+            _this.dialog.hide();
+        }
       },
-{
-       '|xns' : 'Roo',
-       text : _this._strings['e0aa021e21dddbd6d8cecec71e9cf564'],
-       xns : Roo,
-       xtype : 'Button',
-       listeners : {
-        click : function() {
-         
-             var name =     _this.form.findField('name').getValue();
-             name = name.toUpperCase().replace(/[^A-Z]+/g, '');
-             if (!name.length) {
-                 Roo.MessageBox.alert("Error","Please fill in a valid name");
-                 return;
-             }
-             _this.form.findField('name').setValue(name);
-          
-             _this.form.doAction('submit');
-             
-         }
-       }
-      }
+      xns : Roo,
+      '|xns' : 'Roo'
+     },
+     {
+      xtype : 'Button',
+      text : _this._strings['e0aa021e21dddbd6d8cecec71e9cf564'] /* OK */,
+      listeners : {
+       click : function() 
+        {
+            if(typeof(_this.data._confirm) != 'undefined' && _this.data._confirm * 1 == 1){
+                Roo.MessageBox.confirm(
+                    "Confirm", 
+                    "Are you sure '" + _this.data.display_name + "' Merge with '" + _this.form.findField('_merge_id').getRawValue() + "'", 
+                    function(res) {
+                        if(res != 'yes') {
+                            return;
+                        }
+                        
+                        _this.form.doAction('submit');
+                        return;
+                    }
+                );
+                
+                return;
+            }
+            _this.form.doAction('submit');
+            
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo'
+     }
     ],
-    items : [
+    items  : [
      {
-      '|xns' : 'Roo',
+      xtype : 'ContentPanel',
       background : true,
       fitToFrame : true,
       region : 'center',
       xns : Roo,
-      xtype : 'ContentPanel',
-      items : [
+      '|xns' : 'Roo',
+      items  : [
        {
-        '|xns' : 'Roo.form',
+        xtype : 'Form',
         method : 'POST',
         style : 'margin: 5px',
         url : baseURL + '/Roo/core_enum.php',
-        xns : Roo.form,
-        xtype : 'Form',
         listeners : {
          actioncomplete : function (_self, action)
           {
             if (action.type == 'setdata') {
           
-                  if((typeof(_this.data.etype) == 'undefined') || !_this.data.etype.length){
-                      Roo.MessageBox.alert('Error', 'Missing etype');
-                      _this.dialog.hide();
-                      return;
-                  }
-                  
-                  if(typeof(_this.data.title) != 'undefined' && _this.data.title.length){
-                      _this.dialog.setTitle(_this.data.title);
-                  }
-            
-                  if(_this.data.id){
-                      _this.dialog.el.mask("Loading");
-                      this.load({ method: 'GET', params: { '_id' : _this.data.id }}); 
-                  }
-                 
                  return;
               }
               if (action.type == 'load') {
@@ -147,74 +146,90 @@ Pman.Dialog.AdminEnumMerge = {
              _this.form = form;
           }
         },
-        items : [
-         {
-          '|xns' : 'Roo.form',
-          actionMode : 'fieldEl',
-          allowBlank : false,
-          fieldLabel : 'Name',
-          hidden : true,
-          name : 'name',
-          width : 200,
-          xns : Roo.form,
-          xtype : 'TextField'
-         },
+        xns : Roo.form,
+        '|xns' : 'Roo.form',
+        items  : [
          {
-          '|xns' : 'Roo.form',
+          xtype : 'ComboBox',
           allowBlank : false,
-          fieldLabel : 'Display Name',
-          name : 'display_name',
-          width : 200,
-          xns : Roo.form,
-          xtype : 'TextField',
+          alwaysQuery : true,
+          displayField : 'display_name',
+          editable : true,
+          fieldLabel : _this._strings['03e956f1dca2b4d525df03cb1899cb6f'] /* Merge with */,
+          forceSelection : true,
+          hiddenName : '_merge_id',
+          listWidth : 250,
+          minChars : 2,
+          name : 'merge_display_name',
+          pageSize : 50,
+          queryParam : 'query[search]',
+          selectOnFocus : true,
+          tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
+          triggerAction : 'all',
+          valueField : 'id',
+          width : 250,
           listeners : {
-           keyup : function (_self, e)
+           render : function (_self)
             {
-                _this.form.findField('name').setValue(this.getValue().replace(/[^a-z0-9]/ig, '').toUpperCase());
-                
+                _this.merge = this;
             }
-          }
-         },
-         {
-          '|xns' : 'Roo.form',
-          actionMode : 'fieldEl',
-          checked : true,
-          fieldLabel : 'Active',
-          hidden : true,
-          inputValue : 1,
-          name : 'active',
-          value : 1,
-          valueOff : 0,
-          xns : Roo.form,
-          xtype : 'Checkbox'
-         },
-         {
-          '|xns' : 'Roo.form',
-          name : 'etype',
+          },
           xns : Roo.form,
-          xtype : 'Hidden'
-         },
-         {
           '|xns' : 'Roo.form',
-          name : 'seqid',
-          value : 0,
-          xns : Roo.form,
-          xtype : 'Hidden'
+          store : {
+           xtype : 'Store',
+           remoteSort : true,
+           sortInfo : { direction : 'ASC', field: 'display_name' },
+           listeners : {
+            beforeload : function (_self, o){
+                 o.params = o.params || {};
+                 
+                 o.params.active = 1;
+                 o.params.etype = _this.data.etype;
+                 o.params['!id'] = _this.data.id;
+                 
+             }
+           },
+           xns : Roo.data,
+           '|xns' : 'Roo.data',
+           proxy : {
+            xtype : 'HttpProxy',
+            method : 'GET',
+            url : baseURL + '/Roo/Core_enum.php',
+            xns : Roo.data,
+            '|xns' : 'Roo.data'
+           },
+           reader : {
+            xtype : 'JsonReader',
+            fields : [
+                {
+                    "name":"id",
+                    "type":"int"
+                },
+                {
+                    "name":"display_name",
+                    "type":"string"
+                }
+            ],
+            id : 'id',
+            root : 'data',
+            totalProperty : 'total',
+            xns : Roo.data,
+            '|xns' : 'Roo.data'
+           }
+          }
          },
          {
-          '|xns' : 'Roo.form',
+          xtype : 'Hidden',
           name : 'id',
           xns : Roo.form,
-          xtype : 'Hidden'
+          '|xns' : 'Roo.form'
          }
         ]
-
        }
       ]
-
      }
     ]
-
    });
  }
 };