sync
[Pman.Admin] / Pman.Tab.AdminTranslations.js
index 1001de3..34de2e9 100644 (file)
@@ -156,14 +156,33 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                    return;
                }
                
+               
+               var steps = [ 
+                      'scanProjectBJS',
+                        'scanPmanBJS',
+                        'scanPmanTemplates',
+                        'scanTables',
+                        'syncLanguage'  
+               ];
+               
+               
                var syncTemplate = function(){
+               
+                   var step = steps.shift();
+                   Roo.MessageBox.updateProgress( (5.0 - steps.length) / 5.0, "Running " + step);
+               
                    new Pman.Request({
-                       url : baseURL + '/Admin/UpdateBjsTemplates',
+                       url : baseURL + '/Admin/UpdateBjsTemplates/' + step,
                        method : 'GET',
-                       mask : 'Processing...',
+                       //mask : 'Processing...',
                        timeout : 9000000,
                        success : function()
                        {
+                          if (steps.length > 0 ) { 
+                               syncTemplate();
+                               return;
+                           }
+                           Roo.MessageBox.hide();
                            _this.treepanel.tree.getRootNode().reload();
                        }
                    });
@@ -186,7 +205,27 @@ 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();
                    return;
                }
@@ -196,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;
+               }
                
                
                
@@ -219,9 +262,8 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                
                
                Pman.Dialog.Image.show({
-                  _url : baseURL + '/Admin/Import/Core_templatestr',
-                  
-               
+                  _url : baseURL + '/Admin/Import/Core_templatestr' 
+                
                }, function() {
                     _this.treepanel.tree.getRootNode().reload();
                });
@@ -252,8 +294,9 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                    csvCols : 'src_id_mdsum,template_id_view_name,template_id_template,src_id_txt,lang,txt',
                    csvTitles : 'Code,Module,Template,Original,Language,Translation',
                    limit : 9999,
-                   sort: 'template_id_view_name,template_id_template,src_id_txt',
-                   dir: 'ASC'
+                   sort: 'template_id_view_name,template_id_template,on_table,on_col,src_id_txt',
+                   dir: 'ASC',
+                   active : 1
                };
                if (!sn ||  sn.id == 'transtree') {
                    Roo.MessageBox.alert("Error", "Select language, module or page");
@@ -265,21 +308,21 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                }
                
                
-               if (sn.id.match(/^table:/)) {
+               if (typeof(sn.id) == 'string' && sn.id.match(/^table:/)) {
                    var sns = sn.id.split(':');
                    p.lang = sns[1];
                    p.on_table = sns[2];
                    p.csvCols = 'src_id_mdsum,on_table,on_id,on_col,src_id_txt,lang,txt';
-                   p.csvTitles = 'Code,Table,Table id,Column,Language,Translation';
+                   p.csvTitles = 'Code,Table,Table id,Column,Original,Language,Translation';
                }
                
-               if (sn.id.match(/^view:/)) {
+               if (typeof(sn.id) == 'string' && sn.id.match(/^view:/)) {
                    var sns = sn.id.split(':');
                    p.lang = sns[1];
                    p.template_id_view_name = sns[2];
                    
                }
-               if (sn.id.match(/^lang:/)) {
+               if (typeof(sn.id) == 'string' &&  sn.id.match(/^lang:/)) {
                    var sns = sn.id.split(':');
                    p.lang = sns[1];