Let the legacy interface do the right thing when embedded in the web client
authorMike Rylander <mrylander@gmail.com>
Mon, 8 Aug 2016 18:10:32 +0000 (14:10 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 18 Aug 2016 19:34:22 +0000 (15:34 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/reports/oils_rpt_folder_window.js
Open-ILS/web/reports/oils_rpt_param_editor.js
Open-ILS/web/reports/oils_rpt_utils.js

index 42a53d5..0fb78db 100644 (file)
@@ -1,6 +1,9 @@
 dojo.requireLocalization("openils.reports", "reports");
 
 var rpt_strings = dojo.i18n.getLocalization("openils.reports", "reports");
+var NG_NEW_TEMPLATE_INTERFACE = '/eg/staff/reporter/template/new';
+var NG_CLONE_TEMPLATE_INTERFACE = '/eg/staff/reporter/template/clone';
+var NG_CLONE_LEGACY_TEMPLATE_INTERFACE = '/eg/staff/reporter/legacy/template/clone';
 var OILS_TEMPLATE_INTERFACE = 'xul/template_builder.xul';
 var OILS_LEGACY_TEMPLATE_INTERFACE = 'oils_rpt_builder.xhtml';
 
@@ -104,7 +107,11 @@ oilsRptFolderWindow.prototype.drawEditActions = function() {
                var s = location.search+'';
                s = s.replace(/\&folder=\d+/g,'');
                s = s.replace(/\&ct=\d+/g,'');
-               goTo( OILS_TEMPLATE_INTERFACE+s+'&folder='+obj.folderNode.folder.id());
+               if (window.IAMBROWSER) {
+            window.top.location.href = NG_NEW_TEMPLATE_INTERFACE+'/'+obj.folderNode.folder.id();
+        } else {
+            goTo( OILS_TEMPLATE_INTERFACE+s+'&folder='+obj.folderNode.folder.id());
+        }
        }
 
 
@@ -294,11 +301,21 @@ oilsRptFolderWindow.prototype.cloneTemplate = function(template) {
                        s = s.replace(/\&folder=\d+/g,'');
                        s = s.replace(/\&ct=\d+/g,'');
             version = JSON2js(template.data()).version;
-            if(version && version >= 2) {
-                _debug('entering new template building interface with template version ' + version);
-                           goTo(OILS_TEMPLATE_INTERFACE+s+'&folder='+folderid+'&ct='+template.id());
+            if(version && version >= 5) {
+                           window.top.location.href = NG_CLONE_TEMPLATE_INTERFACE+'/'+folderid+'/'+template.id();
+            } else if(version && version >= 2) {
+                       if (window.IAMBROWSER) {
+                               window.top.location.href = NG_CLONE_LEGACY_TEMPLATE_INTERFACE+'/'+folderid+'/'+template.id();
+                } else {
+                    _debug('entering new template building interface with template version ' + version);
+                           goTo(OILS_TEMPLATE_INTERFACE+s+'&folder='+folderid+'&ct='+template.id());
+                }
             } else {
-                           goTo(OILS_LEGACY_TEMPLATE_INTERFACE+s+'&folder='+folderid+'&ct='+template.id());
+                       if (window.IAMBROWSER) {
+                               window.top.location.href = NG_CLONE_LEGACY_TEMPLATE_INTERFACE+'/'+folderid+'/'+template.id();
+                } else {
+                           goTo(OILS_LEGACY_TEMPLATE_INTERFACE+s+'&folder='+folderid+'&ct='+template.id());
+                }
             }
                }
        );
index e66a986..e44a02d 100644 (file)
@@ -38,7 +38,8 @@ oilsRptParamEditor.prototype.draw = function() {
                var par = params[p];
                var row = oilsRptParamEditor.row.cloneNode(true);
                this.tbody.appendChild(row);
-               $n(row, 'column').appendChild(text(oilsRptMakeLabel(par.path)));
+               var clabel = oilsRptMakeLabel(par.path) || par.label || par.alias;
+               $n(row, 'column').appendChild(text(clabel));
 
         if (par.field_doc) {
                    $n(row, 'column').appendChild(
index d7017ec..2caed79 100644 (file)
@@ -90,6 +90,9 @@ function oilsRptPathRel(path) {
 
 /* creates a label "path" based on the column path */
 function oilsRptMakeLabel(path) {
+    if (!path) return path;
+    if (path.indexOf(' ') > -1) return path
+
        var parts = path.split(/-/);
        var str = '';
        for( var i = 0; i < parts.length; i++ ) {