Pman.Dialog.Image.bjs
authoredward <edward@roojs.com>
Mon, 28 Aug 2017 09:40:03 +0000 (17:40 +0800)
committeredward <edward@roojs.com>
Mon, 28 Aug 2017 09:40:03 +0000 (17:40 +0800)
Pman.Dialog.Image.js

Pman.Dialog.Image.bjs
Pman.Dialog.Image.js

index 5f3dbde..ea3b243 100644 (file)
@@ -2,13 +2,16 @@
  "name" : "Pman.Dialog.Image",
  "parent" : "",
  "title" : "",
- "path" : "/home/alan/gitlive/Pman.Core/Pman.Dialog.Image.bjs",
+ "path" : "/home/edward/gitlive/Pman.Core/Pman.Dialog.Image.bjs",
  "permname" : "",
  "modOrder" : "001",
  "strings" : {
   "eb5d45750c7ab13aa8e6bacc80315a30" : "32M",
   "2859a4ae58ae4e25abdfc530f814e42f" : "Upload an Image or File",
+  "1243daf593fa297e07ab03bf06d925af" : "Searching...",
   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
+  "8e16a71b3d8217eb80b39b7d8dec4296" : "Image Type",
+  "dff0c70e4c11953e4e3ee1cf268fb96d" : "Select image type",
   "91412465ea9169dfd901dd5e7c96dd99" : "Upload",
   "ea72bacd2fdfa818907bb9559e6905a1" : "Upload Image or File"
  },
@@ -45,7 +48,7 @@
       {
        "listeners" : {
         "actionfailed" : "function (_self, act)\n{\n   \n   \n    _this.dialog.uploadComplete = true;\n   // _this.dialog.el.unmask();\n    // error msg???\n     _this.dialog.haveProgress = 2; \n    if (act.type == 'submit') {\n        Roo.log(\"Upload error\");\n        Roo.log(act);\n        \n        try {\n            Roo.MessageBox.alert(\"Error\", act.result.errorMsg.split(/\\n/).join('<BR/>'));\n        } catch(e) {\n          //  Roo.log(e);\n            Roo.MessageBox.alert(\"Error\", \"Saving failed = fix errors and try again\");        \n        }\n        return;\n    }\n    \n    // what about load failing..\n    Roo.MessageBox.alert(\"Error\", \"Error loading details\"); \n}",
-        "|actioncomplete" : "function(_self,act)\n{\n    _this.dialog.uploadComplete = true;\n    _this.dialog.haveProgress = 2; \n    Roo.MessageBox.hide(); // force hiding\n    //_this.dialog.el.unmask();\n     \n    if (act.type == 'setdata') { \n        this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';\n        this.el.dom.action = this.url;\n        if (typeof(_this.data.timeout) != 'undefined') {\n            this.timeout = _this.data.timeout;\n        }\n        \n        this.findField('UPLOAD_IDENTIFIER').setValue(\n            (new Date() * 1) + '' + Math.random());\n            \n        return;\n    }\n     \n   \n    if (act.type == 'load') {\n      // should this happen?  \n        _this.data = act.result.data;\n       // _this.loaded();\n        return;\n    }\n    \n    \n    if (act.type == 'submit') { // only submitted here if we are \n        _this.dialog.hide();\n        Roo.log(\"Upload success\");\n        Roo.log(act);\n        //console.log(act);\n        if (_this.callback) {\n            _this.callback.call(this, act.result.data, act.result.extra);\n        }\n        return; \n    }\n \n\n    \n}\n",
+        "|actioncomplete" : "function(_self,act)\n{\n    _this.dialog.uploadComplete = true;\n    _this.dialog.haveProgress = 2; \n    Roo.MessageBox.hide(); // force hiding\n    //_this.dialog.el.unmask();\n     \n    if (act.type == 'setdata') { \n    \n        _this.form.findField('imgtype').hide();\n        \n        if(_this.data._show_image_type){\n            _this.form.findField('imgtype').show();\n        }\n        \n        this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';\n        this.el.dom.action = this.url;\n        if (typeof(_this.data.timeout) != 'undefined') {\n            this.timeout = _this.data.timeout;\n        }\n        \n        this.findField('UPLOAD_IDENTIFIER').setValue(\n            (new Date() * 1) + '' + Math.random());\n            \n        return;\n    }\n     \n   \n    if (act.type == 'load') {\n      // should this happen?  \n        _this.data = act.result.data;\n       // _this.loaded();\n        return;\n    }\n    \n    \n    if (act.type == 'submit') { // only submitted here if we are \n        _this.dialog.hide();\n        Roo.log(\"Upload success\");\n        Roo.log(act);\n        //console.log(act);\n        if (_this.callback) {\n            _this.callback.call(this, act.result.data, act.result.extra);\n        }\n        return; \n    }\n \n\n    \n}\n",
         "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
        },
        "$ url" : "baseURL + '/Roo/Images.php'",
          "name" : "imageUpload"
         },
         {
-         "xtype" : "Hidden",
+         "alwaysQuery" : true,
+         "listWidth" : 400,
+         "triggerAction" : "all",
+         "fieldLabel" : "Image Type",
+         "forceSelection" : true,
+         "selectOnFocus" : true,
+         "pageSize" : 20,
+         "displayField" : "display_name",
+         "emptyText" : "Select image type",
+         "hiddenName" : "imgtype",
+         "minChars" : 2,
+         "valueField" : "id",
+         "xtype" : "ComboBox",
+         "allowBlank" : true,
+         "typeAhead" : true,
+         "width" : 250,
          "$ xns" : "Roo.form",
-         "name" : "ontable"
+         "name" : "imgtype_name",
+         "qtip" : "Select image type",
+         "queryParam" : "query[search]",
+         "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> {name}</div>",
+         "loadingText" : "Searching...",
+         "items" : [
+          {
+           "listeners" : {
+            "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    \n    o.params['etype'] = _this.data.etype;\n    \n    o.params['!id'] = _this.form.findField('id').getValue();\n    // set more here\n}\n"
+           },
+           "xtype" : "Store",
+           "remoteSort" : true,
+           "$ sortInfo" : "{ direction : 'ASC', field: 'name' }",
+           "$ xns" : "Roo.data",
+           "* prop" : "store",
+           "items" : [
+            {
+             "$ url" : "baseURL + '/Roo/Core_enum'",
+             "xtype" : "HttpProxy",
+             "method" : "GET",
+             "$ xns" : "Roo.data",
+             "* prop" : "proxy"
+            },
+            {
+             "id" : "id",
+             "root" : "data",
+             "xtype" : "JsonReader",
+             "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"name\",\"type\":\"string\"}]",
+             "$ xns" : "Roo.data",
+             "* prop" : "reader",
+             "totalProperty" : "total"
+            }
+           ]
+          }
+         ]
         },
         {
          "xtype" : "Hidden",
          "$ xns" : "Roo.form",
-         "name" : "onid"
+         "name" : "ontable"
         },
         {
          "xtype" : "Hidden",
          "$ xns" : "Roo.form",
-         "name" : "id"
+         "name" : "onid"
         },
         {
          "xtype" : "Hidden",
          "$ xns" : "Roo.form",
-         "name" : "imgtype"
+         "name" : "id"
         }
        ]
       }
index 8f1ebac..93c452d 100644 (file)
@@ -9,7 +9,10 @@ Pman.Dialog.Image = {
  _strings : {
   'eb5d45750c7ab13aa8e6bacc80315a30' :"32M",
   '2859a4ae58ae4e25abdfc530f814e42f' :"Upload an Image or File",
+  '1243daf593fa297e07ab03bf06d925af' :"Searching...",
   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
+  '8e16a71b3d8217eb80b39b7d8dec4296' :"Image Type",
+  'dff0c70e4c11953e4e3ee1cf268fb96d' :"Select image type",
   '91412465ea9169dfd901dd5e7c96dd99' :"Upload",
   'ea72bacd2fdfa818907bb9559e6905a1' :"Upload Image or File"
  },
@@ -207,6 +210,13 @@ Pman.Dialog.Image = {
               //_this.dialog.el.unmask();
                
               if (act.type == 'setdata') { 
+              
+                  _this.form.findField('imgtype').hide();
+                  
+                  if(_this.data._show_image_type){
+                      _this.form.findField('imgtype').show();
+                  }
+                  
                   this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';
                   this.el.dom.action = this.url;
                   if (typeof(_this.data.timeout) != 'undefined') {
@@ -304,26 +314,78 @@ Pman.Dialog.Image = {
           '|xns' : 'Roo.form'
          },
          {
-          xtype : 'Hidden',
-          name : 'ontable',
+          xtype : 'ComboBox',
+          allowBlank : true,
+          alwaysQuery : true,
+          displayField : 'display_name',
+          emptyText : _this._strings['dff0c70e4c11953e4e3ee1cf268fb96d'] /* Select image type */,
+          fieldLabel : _this._strings['8e16a71b3d8217eb80b39b7d8dec4296'] /* Image Type */,
+          forceSelection : true,
+          hiddenName : 'imgtype',
+          listWidth : 400,
+          loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+          minChars : 2,
+          name : 'imgtype_name',
+          pageSize : 20,
+          qtip : _this._strings['dff0c70e4c11953e4e3ee1cf268fb96d'] /* Select image type */,
+          queryParam : 'query[search]',
+          selectOnFocus : true,
+          tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> {name}</div>',
+          triggerAction : 'all',
+          typeAhead : true,
+          valueField : 'id',
+          width : 250,
           xns : Roo.form,
-          '|xns' : 'Roo.form'
+          '|xns' : 'Roo.form',
+          store : {
+           xtype : 'Store',
+           remoteSort : true,
+           sortInfo : { direction : 'ASC', field: 'name' },
+           listeners : {
+            beforeload : function (_self, o){
+                 o.params = o.params || {};
+                 
+                 o.params['etype'] = _this.data.etype;
+                 
+                 o.params['!id'] = _this.form.findField('id').getValue();
+                 // set more here
+             }
+           },
+           xns : Roo.data,
+           '|xns' : 'Roo.data',
+           proxy : {
+            xtype : 'HttpProxy',
+            method : 'GET',
+            url : baseURL + '/Roo/Core_enum',
+            xns : Roo.data,
+            '|xns' : 'Roo.data'
+           },
+           reader : {
+            xtype : 'JsonReader',
+            fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
+            id : 'id',
+            root : 'data',
+            totalProperty : 'total',
+            xns : Roo.data,
+            '|xns' : 'Roo.data'
+           }
+          }
          },
          {
           xtype : 'Hidden',
-          name : 'onid',
+          name : 'ontable',
           xns : Roo.form,
           '|xns' : 'Roo.form'
          },
          {
           xtype : 'Hidden',
-          name : 'id',
+          name : 'onid',
           xns : Roo.form,
           '|xns' : 'Roo.form'
          },
          {
           xtype : 'Hidden',
-          name : 'imgtype',
+          name : 'id',
           xns : Roo.form,
           '|xns' : 'Roo.form'
          }