gridftp ui: limit archive functionality only to moss
[qcg-portal.git] / qcg / templates / qcg / job_new.html
index cac10a6..966c5d2 100644 (file)
     {% include 'filex/source.js.html' %}
 
     <script>
-        $(function() {
+        var filex = filex || {};
+
+        $(function () {
+            'use strict';
+
             var gridftpButton = $('<button/>', {
                 'type': 'button',
                 'class': 'btn btn-default pull-right',
                 'data-target': '#gridftp'
             });
 
-            $('#id_master_file,#id_executable,#id_preprocess_script,#id_postprocess_script').before(function() {
+            function fullPath(path, file) {
+                var res = path + file.get('name');
+
+                if (file.isDir())
+                    res += '/';
+
+                return res;
+            }
+
+            $('#id_master_file,#id_executable,#id_input,#id_preprocess_script,#id_postprocess_script').before(function() {
                 var target = this;
                 return gridftpButton.clone().click(function() {
                     $('#select-btn').off().click(function() {
@@ -32,7 +45,9 @@
                             return;
                         }
 
-                        var file = filex.host + filex.path.full() + '/' + selected[0].get('name');
+                        var file = fullPath(filex.host + '/' + filex.path.full() + '/', selected[0]);
+
+                        target.selectize.clear();
                         target.selectize.addOption({value: file, text: file});
                         target.selectize.addItem(file);
                         target.selectize.refreshItems();
                 });
             }).wrap('<div style="margin-right: 80px"></div>');
 
-            $('#id_input,#id_stage_in').before(function() {
+            $('#id_stage_in').before(function() {
                 var target = this;
                 return gridftpButton.clone().click(function() {
                     $('#select-btn').off().click(function() {
-                        var path = filex.host + filex.path.full() + '/';
+                        var path = filex.host + '/' + filex.path.full() + '/';
 
                         _.each(filex.selectedFiles(), function(item) {
-                            console.log(arguments);
-                            var file = path + item.get('name');
+                            var file = fullPath(path, item);
                             target.selectize.addOption({value: file, text: file});
                             target.selectize.addItem(file);
                         });