PHP8
[Pman.BAdmin] / Pman.Dialog.BAdminImageManager.bjs
index f2d4be1..890ca82 100644 (file)
@@ -8,6 +8,7 @@
  "strings" : {
   "ef797d5638c2e1c6b6225b2247541ea5" : "Upload Image or File:",
   "d9787032e54a7facd5c7b1db2ae61c7b" : "Image Manager",
+  "53ab4599d0106e32d015649175a70d7b" : "<i class=\"fa fa-filter\"></i> Filter",
   "37c1097cf82226d511586ecd99ed97cf" : "search for image",
   "cdb6b6bab1fd18b9dbfe3fb84a5d34ae" : "<i class=\"fa fa-search\"></i>",
   "5350277f16d9998c57fa7e1d17be2a76" : "<i class=\"fa fa-upload\"></i> Upload Image",
   "708ea0e601087e73c4764d5086e3ea3c" : "File Name:",
   "e0a53da57dd79cca5d3b6a7c42e463ef" : "File Type:",
   "3f986fa4066f6bded1376eb69de18da2" : "File Size:",
+  "179d4ab94c43ccb7cd6d2b3d82c7fe1f" : "Show images for this email",
   "d3d2e617335f08df83599665eef8a418" : "Close",
   "84378f54966381befd040dafbdc221d6" : "<i class=\"fa fa-plus\"></i> Add into the email",
   "361bacb1a72a350ee34e2f31a6a91dab" : "Alignment:",
-  "f48f7c7bccb5e29c83d87984c49ad8d4" : "Show image for this email",
+  "2cd3a1900dd0060540b418b2a60f6eec" : "Show all images",
   "ed807858fcb68abdd180481f1fcba5c5" : "<i class=\"fa fa-trash\"></i> Delete",
   "031fa343a28d221a25d2bcd942437174" : "Alternate Text:",
   "48ccf48dcf2218a413ce473262f21a0c" : "Width: ",
     "resize" : "function (_self)\n{\n    if (_this.dialog && _this.container && _this.toolbar) {\n        \n        _this.document_container.el.setHeight(\n            _this.dialog.bodyEl.getHeight() -\n            _this.dialog.headerEl.getHeight() -\n            _this.toolbar.el.dom.offsetHeight -\n            _this.dialog.footerEl.getHeight()\n        );\n        \n    }\n}"
    },
    "String cls" : "modal-body-enable-overflow-y pman-badmin-image-manager",
-   "string haveProgress" : false,
-   "xtype" : "Modal",
    "Boolean fitwindow" : true,
-   "string uploadComplete" : false,
-   "$ string uploadProgress" : "function()\n{\n    Roo.log('uploadProgress');\n    \n    var dlg = this;\n    if (!dlg.haveProgress) {\n        Roo.MessageBox.progress(\"Uploading\", \"Uploading\");\n    }\n    \n    if (dlg.haveProgress == 2) {\n        // it's been closed elsewhere..\n        return;\n    }\n    if (dlg.uploadComplete) {\n        Roo.MessageBox.hide();\n        return;\n    }\n    \n    dlg.haveProgress = 1;\n    \n    var uid = _this.form.findField('UPLOAD_IDENTIFIER').getValue();\n    \n    new Pman.Request({\n        url : baseURL + '/Core/UploadProgress.php',\n        params: {\n            id : uid\n            \n        },\n        method: 'GET',\n        success : function(res){\n            var data = res.data;\n            if (dlg.haveProgress == 2) {\n                return;\n            }\n            \n            if (dlg.uploadComplete) {\n                Roo.MessageBox.hide();\n                return;\n            }\n                \n            if (data){\n                Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,\n                    Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'\n                );\n            } else {\n                Roo.MessageBox.updateProgress(1,\n                    \"Upload Complete - processing\"\n                );\n                return;\n            }\n            dlg.uploadProgress.defer(2000,dlg);\n        },\n        failure: function(data) {\n        }\n    })\n    \n}\n",
+   "xtype" : "Modal",
    "$ xns" : "Roo.bootstrap",
    "String title" : "Image Manager",
    "items" : [
      "$ xns" : "Roo.bootstrap",
      "items" : [
       {
+       "listeners" : {
+        "render" : "function (_self)\n{\n    _this.masonryBlock = this;\n}"
+       },
+       "Number md" : 12,
        "xtype" : "Column",
        "$ xns" : "Roo.bootstrap",
-       "Number sm" : 8,
        "items" : [
         {
          "listeners" : {
-          "actionfailed" : "function (_self, action)\n{\n    _this.dialog.uploadComplete = true;\n    \n     _this.dialog.haveProgress = 2;\n     \n    if (action.type == 'submit') {\n        Roo.log(\"Upload error\");\n        Roo.log(action);\n        \n        try {\n            \n            Roo.MessageBox.alert(\"Error\", action.result.errorMsg.split(/\\n/).join('<BR/>'));\n            \n        } catch(e) {\n            \n            Roo.MessageBox.alert(\"Error\", \"Saving failed = fix errors and try again\");\n        }\n        return;\n    }\n    \n    Roo.MessageBox.alert(\"Error\", \"Error loading details\"); \n}",
-          "actioncomplete" : "function(_self,action)\n{\n    _this.dialog.uploadComplete = true;\n    \n    _this.dialog.haveProgress = 2;\n    \n    Roo.MessageBox.hide();\n     \n    if (action.type == 'setdata') { \n        \n        this.url = _this.data._url ? baseURL + _this.data._url : baseURL + '/Roo/Images.php';\n        \n        this.el.dom.action = this.url;\n        \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        _this.masonry.load();\n        \n        return;\n    }\n     \n   \n    if (action.type == 'load') {\n        \n        _this.data = action.result.data;\n        \n        return;\n    }\n    \n    \n    if (action.type == 'submit') { // only submitted here if we are \n        \n        _this.masonry.load();\n        \n        return; \n    }\n \n\n    \n}\n",
+          "actionfailed" : "function (_self, action)\n{\n    if (action.type == 'submit') {\n        Roo.log(\"Upload error\");\n        Roo.log(action);\n        \n        try {\n            \n            Roo.MessageBox.alert(\"Error\", action.result.errorMsg.split(/\\n/).join('<BR/>'));\n            \n        } catch(e) {\n            \n            Roo.MessageBox.alert(\"Error\", \"Saving failed = fix errors and try again\");\n        }\n        return;\n    }\n    \n    Roo.MessageBox.alert(\"Error\", \"Error loading details\"); \n}",
+          "actioncomplete" : "function(_self,action)\n{\n    if (action.type == 'setdata') { \n        \n        _this.showType = 'public';\n        \n        this.url = _this.data._url ? baseURL + _this.data._url : baseURL + '/Roo/Images.php';\n        \n        this.el.dom.action = this.url;\n        \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        _this.masonry.load();\n        \n        return;\n    }\n     \n   \n    if (action.type == 'load') {\n        \n        _this.data = action.result.data;\n        \n        return;\n    }\n    \n    \n    if (action.type == 'submit') { // only submitted here if we are \n        \n        _this.masonry.load();\n        \n        return; \n    }\n \n\n    \n}\n",
           "render" : "function (_self)\n{\n    _this.form = this;\n    \n}"
          },
+         "style" : "display: none;",
          "xtype" : "Form",
          "Number timeout" : 300,
-         "style" : "display: none;",
          "$ xns" : "Roo.bootstrap",
          "Boolean fileUpload" : true,
          "String method" : "POST",
@@ -91,7 +93,7 @@
          "items" : [
           {
            "listeners" : {
-            "render" : "function (_self)\n{\n    _this.uploadDL = this;\n    \n    _this.uploadDL.inputEl().on(\"change\",function(){\n        \n        _this.form.findField('onid').setValue(_this.showTypeBtn.isActive() ? _this.data.onid : 0);\n        _this.form.doAction('submit');\n        \n        //_this.dialog.uploadProgress.defer(1000, _this.dialog);\n    });\n    \n    \n}"
+            "render" : "function (_self)\n{\n    _this.uploadDL = this;\n    \n    _this.uploadDL.inputEl().on(\"change\",function(){\n        \n        _this.form.findField('onid').setValue((_this.showType == 'private') ? _this.data.onid : 0);\n        _this.form.doAction('submit');\n    });\n    \n    \n}"
            },
            "String name" : "imageUpload",
            "xtype" : "Input",
          "listeners" : {
           "render" : "function (_self)\n{\n    _this.container = this;\n    \n}"
          },
+         "String cls" : "col-md-12",
          "xtype" : "Container",
          "$ xns" : "Roo.bootstrap",
          "items" : [
              "Number md" : 8,
              "xtype" : "Column",
              "$ xns" : "Roo.bootstrap",
+             "Number sm" : 12,
              "items" : [
               {
-               "listeners" : {
-                "toggle" : "function (b, e, pressed)\n{\n    _this.showTypeBtn.setText(!pressed ? 'Show all images' : 'Show image for this email');\n    \n    _this.masonry.load();\n}",
-                "render" : "function (_self)\n{\n    _this.showTypeBtn = this;\n}"
-               },
-               "bool pressed" : false,
                "xtype" : "Button",
                "$ xns" : "Roo.bootstrap",
-               "String html" : "Show image for this email",
-               "String style" : "float:left;"
+               "String html" : "<i class=\"fa fa-filter\"></i> Filter",
+               "items" : [
+                {
+                 "xtype" : "Menu",
+                 "$ xns" : "Roo.bootstrap",
+                 "* prop" : "menu",
+                 "items" : [
+                  {
+                   "listeners" : {
+                    "click" : "function (_self, e)\n{\n    _this.showType = 'private';\n    \n    _this.masonry.load();\n}"
+                   },
+                   "Boolean preventDefault" : true,
+                   "xtype" : "MenuItem",
+                   "$ xns" : "Roo.bootstrap",
+                   "Boolean isContainer" : false,
+                   "String html" : "Show images for this email"
+                  },
+                  {
+                   "listeners" : {
+                    "click" : "function (_self, e)\n{\n    _this.showType = 'public';\n    \n    _this.masonry.load();\n}"
+                   },
+                   "Boolean preventDefault" : true,
+                   "xtype" : "MenuItem",
+                   "$ xns" : "Roo.bootstrap",
+                   "Boolean isContainer" : false,
+                   "String html" : "Show all images"
+                  }
+                 ]
+                }
+               ]
               },
               {
                "listeners" : {
                "xtype" : "Input",
                "string placeholder" : "search for image",
                "$ xns" : "Roo.bootstrap",
-               "String style" : "float:left; width: 300px; margin-left: 15px;",
+               "String style" : "width: 200px; margin-left: 15px;display: inline-block; margin-bottom: 0px; vertical-align: middle;",
                "items" : [
                 {
                  "listeners" : {
              "String cls" : "text-right",
              "xtype" : "Column",
              "$ xns" : "Roo.bootstrap",
+             "Number sm" : 12,
              "items" : [
               {
                "listeners" : {
                 "click" : "function (_self, e)\n{\n    var id = _this.data.onid;\n    \n    if(id*1 < 1){\n        Roo.MessageBox.alert('Error', 'Please save the email template first');\n        return;\n    }\n    \n    _this.uploadDL.inputEl().dom.click();\n}"
                },
+               "String size" : "sm",
                "xtype" : "Button",
                "$ xns" : "Roo.bootstrap",
                "String html" : "<i class=\"fa fa-upload\"></i> Upload Image",
                 "render" : "function (_self)\n{\n    _this.deleteBtn = this;\n    \n    this.hide();\n}",
                 "click" : "function (_self, e)\n{\n    if (_this.masonry.getSelected().length > 1) {\n        Roo.bootstrap.MessageBox.alert('Cannot delete the images !','Please select one image only');\n        return;\n    }\n    \n    if (_this.masonry.getSelected().length < 1) {\n        Roo.bootstrap.MessageBox.alert('Cannot delete any image!', 'Please select an image');\n        return;\n    }\n    \n    Roo.bootstrap.MessageBox.confirm(\"Confirm\", \"Are sure you want to delete this image?\", function (v){\n        if (v != 'yes') {\n            return;\n        }\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/Images.php',\n            method: 'POST',\n            params : {\n                _delete : Roo.bootstrap.MasonryBrick.get(_this.masonry.getSelected()[0]).imageObj.id\n            },\n            success : function()\n            {\n//                _this.masonry.removeBrick(_this.masonry.getSelected()[0]);\n                _this.masonry.load();\n            }\n        });\n    });\n}"
                },
+               "String size" : "sm",
                "String weight" : "default",
                "xtype" : "Button",
                "$ xns" : "Roo.bootstrap",
                 "render" : "function (_self)\n{\n    _this.masonry = this;\n    \n}"
                },
                "Boolean isLayoutInstant" : false,
-               "| function load" : "function() \n{\n    _this.setting_form.reset();\n    _this.detail_form.reset();\n    \n    _this.setting_form.hide();\n    _this.detail_form.hide();\n    \n    _this.masonry.clearAll();\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/Images',\n        method: 'GET',\n        params: {\n            ontable : 'core_email',\n            onid : _this.showTypeBtn.isActive() ? _this.data.onid : 0,\n            'search[filename]' : _this.searchBox.getValue()\n        },\n        success: function(ret) {\n            \n            if(!ret.data.length){\n                return;\n            }\n            \n            Roo.each(ret.data, function(r){\n                \n                _this.masonry.addBrick({\n                    size: 'md',\n                    boxWidth: 150,\n                    cls: 'coba-image-mgmt-masonry-brick',\n                    active: false,\n                    activeClass: 'active',\n                    preventDefault: true,\n                    bgimage : baseURL + '/Images/' + r.id + '/' + r.filename,\n                    imageObj: r,\n                    listeners : {\n                        click : function (_self)\n                        {\n                            _this.setting_form.reset();\n                            _this.detail_form.reset();\n                            \n                            _this.setting_form.hide();\n                            _this.detail_form.hide();\n                                \n                            if(!this.isSelected()){\n                                return;\n                            }\n                            \n                            if(_this.masonry.getSelected().length == 1){\n                                _this.deleteBtn.show();\n                            }\n                            \n                            new Pman.Request({\n                                url: baseURL + '/Roo/Images.php',\n                                method : 'GET',\n                                params : {\n                                    _id: _self.imageObj.id\n                                }, \n                                success : function(rr) {\n                                    \n                                    _this.setting_form.show();\n                                    _this.detail_form.show();\n                                    \n                                    _this.detail_form.setValues(rr.data);\n                                    _this.setting_form.setValues(rr.data);\n                                    \n                                    _this.setting_form.findField('align').setValue(\"left\");\n                                    \n                                    _self.imageObj = rr.data;\n                                }\n                            });\n                            \n                        }\n                     }\n                })\n                \n            });\n            \n            _this.masonry.initial();\n            \n         },\n         \n         failure: function(res) {\n             Roo.log('cannot read Coba/Roo/Images');\n         }\n     });\n}",
+               "| function load" : "function() \n{\n    _this.setting_form.reset();\n    _this.detail_form.reset();\n    \n    _this.setting_form.hide();\n    _this.detail_form.hide();\n    \n    _this.masonry.clearAll();\n    \n    var params = {\n        ontable : 'core_email',\n        'search[filename]' : _this.searchBox.getValue()\n    };\n    \n    if(_this.showType == 'private'){\n        params.onid = _this.data.onid;\n    }\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/Images',\n        method: 'GET',\n        params: params,\n        success: function(ret) {\n            \n            if(!ret.data.length){\n                return;\n            }\n            \n            Roo.each(ret.data, function(r){\n                \n                _this.masonry.addBrick({\n                    size: 'md',\n                    boxWidth: 150,\n                    cls: 'coba-image-mgmt-masonry-brick',\n                    active: false,\n                    activeClass: 'active',\n                    preventDefault: true,\n                    bgimage : baseURL + '/Images/' + r.id + '/' + r.filename.replace('%', '-'),\n                    imageObj: r,\n                    listeners : {\n                        click : function (_self)\n                        {\n                            _this.setting_form.reset();\n                            _this.detail_form.reset();\n                            \n                            _this.setting_form.hide();\n                            _this.detail_form.hide();\n                            \n                            _this.deleteBtn.hide();\n                            \n                            _this.masonryBlock.el.removeClass(['col-md-12','col-md-8']).addClass('col-md-12');\n                            \n                            if(!this.isSelected()){\n                                return;\n                            }\n                            \n                            _this.masonryBlock.el.removeClass(['col-md-12','col-md-8']).addClass('col-md-8');\n                            \n                            if(_this.masonry.getSelected().length == 1){\n                                _this.deleteBtn.show();\n                            }\n                            \n                            new Pman.Request({\n                                url: baseURL + '/Roo/Images.php',\n                                method : 'GET',\n                                params : {\n                                    _id: _self.imageObj.id\n                                }, \n                                success : function(rr) {\n                                    \n                                    _this.setting_form.show();\n                                    _this.detail_form.show();\n                                    \n                                    _this.detail_form.setValues(rr.data);\n                                    _this.setting_form.setValues(rr.data);\n                                    \n                                    _this.setting_form.findField('align').setValue(\"left\");\n                                    \n                                    _self.imageObj = rr.data;\n                                }\n                            });\n                            \n                        }\n                     }\n                })\n                \n            });\n            \n            _this.masonry.initial();\n            \n         },\n         \n         failure: function(res) {\n             Roo.log('cannot read Coba/Roo/Images');\n         }\n     });\n}",
                "Number boxWidth" : 250,
                "xtype" : "LayoutMasonry",
                "$ xns" : "Roo.bootstrap",
        ]
       },
       {
+       "Number md" : 4,
        "xtype" : "Column",
        "$ xns" : "Roo.bootstrap",
-       "Number sm" : 4,
        "items" : [
         {
          "xtype" : "Row",
                    "items" : [
                     {
                      "String name" : "filename",
-                     "xtype" : "Input",
                      "style" : "padding: 0;",
+                     "xtype" : "Input",
                      "string fieldLabel" : "File Name:",
                      "cls" : "row-style",
                      "Boolean disabled" : true,