Fix #7175 - refine translation code
authorAlan <alan@roojs.com>
Mon, 28 Mar 2022 04:19:57 +0000 (12:19 +0800)
committerAlan <alan@roojs.com>
Mon, 28 Mar 2022 04:19:57 +0000 (12:19 +0800)
Pman.Tab.AdminTranslations.bjs
Pman.Tab.AdminTranslations.js

index fa44582..02c3c65 100644 (file)
@@ -85,7 +85,7 @@
           },
           {
            "listeners" : {
-            "click" : "function (_self, e)\n{\n    var tree = _this.treepanel.tree;\n    Roo.log(tree);\n    var sn  = tree.getSelectionModel().getSelectedNode();\n\n    if (!sn) {\n        Roo.MessageBox.alert(\"Error\", \"Select a node\");\n        return;\n    }\n    \n    \n    var steps = [ \n           'scanProjectBJS',\n             'scanPmanBJS',\n             'scanPmanTemplates',\n             'scanTables',\n             'syncLanguage'  \n    ];\n    \n    \n    var syncTemplate = function(){\n    \n        var step = steps.shift();\n        Roo.MessageBox.updateProgress( (5.0 - steps.length) / 5.0, \"Running \" + step);\n    \n        new Pman.Request({\n            url : baseURL + '/Admin/UpdateBjsTemplates/' + step,\n            method : 'GET',\n            //mask : 'Processing...',\n            timeout : 9000000,\n            success : function()\n            {\n               if (steps.length > 0 ) { \n                    syncTemplate();\n                    return;\n                }\n                Roo.MessageBox.hide();\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    \n    };\n    \n    \n    var syncLanguage = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Core_templatestr',\n            method : 'POST',\n            mask : 'Processing...',\n            params : {\n                _rescan : sn.attributes.id.split(':')[1]\n            }, \n            success : function()\n            {\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    };\n    \n    if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){\n        Roo.MessageBox.progress(\"Syncing templates\", \"Starting\");\n        syncTemplate();\n        return;\n    }\n    \n    if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){\n        syncLanguage();\n        return;\n    }\n    \n    \n    \n    \n    \n}"
+            "click" : "function (_self, e)\n{\n    var tree = _this.treepanel.tree;\n    Roo.log(tree);\n    var sn  = tree.getSelectionModel().getSelectedNode();\n\n    if (!sn) {\n        Roo.MessageBox.alert(\"Error\", \"Select a node\");\n        return;\n    }\n    \n    \n    var steps = [ \n           'scanProjectBJS',\n             'scanPmanBJS',\n             'scanPmanTemplates',\n             'scanTables',\n             'syncLanguage'  \n    ];\n    \n    \n    var syncTemplate = function(){\n    \n        var step = steps.shift();\n        Roo.MessageBox.updateProgress( (5.0 - steps.length) / 5.0, \"Running \" + step);\n    \n        new Pman.Request({\n            url : baseURL + '/Admin/UpdateBjsTemplates/' + step,\n            method : 'GET',\n            //mask : 'Processing...',\n            timeout : 9000000,\n            success : function()\n            {\n               if (steps.length > 0 ) { \n                    syncTemplate();\n                    return;\n                }\n                Roo.MessageBox.hide();\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    \n    };\n    \n    \n    var syncLanguage = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Core_templatestr',\n            method : 'POST',\n            mask : 'Processing...',\n            params : {\n                _rescan : sn.attributes.id.split(':')[1]\n            }, \n            success : function()\n            {\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    };\n    \n   var syncSingleTemplate = function(id){\n        new Pman.Request({\n            url : baseURL + '/Roo/Core_template',\n            method : 'POST',\n            mask : 'Processing...',\n            params : {\n                id : id,\n                _rescan : 1\n            }, \n            success : function()\n            {\n               (function() {\n                    _this.grid.footer.onClick('first');\n                }).defer(100);\n            }\n        });\n    };\n    \n    \n    if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){\n        Roo.MessageBox.progress(\"Syncing templates\", \"Starting\");\n        syncTemplate();\n        return;\n    }\n    \n    if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){\n        syncLanguage();\n        return;\n    }\n    \n     if(typeof(sn.attributes.id) != 'undefined' && sn.attributes.id * 1> 0){\n        syncSingleTemplate(sn.attributes.id);\n        return;\n    }\n    \n    \n    \n    \n}"
            },
            "text" : "Rescan",
            "xtype" : "Button",
index e66f55c..724d43e 100644 (file)
@@ -205,6 +205,25 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                    });
                };
                
+              var syncSingleTemplate = function(id){
+                   new Pman.Request({
+                       url : baseURL + '/Roo/Core_template',
+                       method : 'POST',
+                       mask : 'Processing...',
+                       params : {
+                           id : id,
+                           _rescan : 1
+                       }, 
+                       success : function()
+                       {
+                          (function() {
+                               _this.grid.footer.onClick('first');
+                           }).defer(100);
+                       }
+                   });
+               };
+               
+               
                if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){
                    Roo.MessageBox.progress("Syncing templates", "Starting");
                    syncTemplate();
@@ -216,6 +235,10 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                    return;
                }
                
+                if(typeof(sn.attributes.id) != 'undefined' && sn.attributes.id * 1> 0){
+                   syncSingleTemplate(sn.attributes.id);
+                   return;
+               }