master file as form field
[qcg-portal.git] / qcg / templates / qcg / job_new.html
index 6ed34c4..eb3d973 100644 (file)
@@ -9,8 +9,28 @@
     <script src="{% static 'qcg/selectize/selectize.min.js' %}"></script>
     <script src="{% static 'qcg/formset/jquery.formset.js' %}"></script>
 
+    {% include 'filex/source.js.html' %}
+
     <script>
         $(function() {
+            $('#id_master_file,#id_executable,#id_input,#id_stage_in,#id_preprocess_script,#id_postprocess_script').before(function() {
+                var target = this;
+                return $('<button/>', {
+                    'type': 'button',
+                    'class': 'btn btn-default pull-right',
+                    'text': 'Wybierz',
+                    'data-toggle': 'modal',
+                    'data-target': '#gridftp'
+                }).click(function() {
+                    filex.once('selected:file', function(file) {
+                        target.selectize.addOption({value: file, text: file});
+                        target.selectize.addItem(file);
+                        target.selectize.refreshItems();
+                        $('#gridftp').modal('hide');
+                    });
+                });
+            }).wrap('<div style="margin-right: 80px"></div>');
+
             $('#id_application').selectize();
             $('#id_arguments,#id_properties,#id_native').selectize({
                 plugins: ['remove_button'],
@@ -29,7 +49,7 @@
                     }
                 }
             });
-            $('#id_modules, #id_hosts').selectize({
+            $('#id_modules,#id_hosts,#id_master_file,#id_executable,#id_input,#id_stage_in,#id_preprocess_script,#id_postprocess_script').selectize({
                 plugins: ['remove_button']
             });
 
                 $('form .collapse').collapse('toggle');
                 $(this).find('span').text(this.text == "Pokaż zaawansowane" ? "Ukryj zaawansowane" : "Pokaż zaawansowane");
             });
-
-            $('#new-env').click(function(e) {
-                e.preventDefault();
-                $('#env-modal').modal('show');
-            });
-
-            $('#env-form').submit(function(e) {
-                e.preventDefault();
-                $('#env-modal').modal('hide');
-
-                $('#id_environment')[0].selectize.createItem($('#id_env_name').val() + '=' + $('#id_env_value').val());
-            });
         });
     </script>
 {% endblock %}
         <div class="tab-content">
             <fieldset id="basic" class="tab-pane active" role="tabpanel">
                 {% bootstrap_field form.application layout="horizontal" %}
-                <div class="row" style="margin-top: -15px; margin-bottom: 15px">
-                    <div class="col-sm-offset-3 col-md-offset-4 col-sm-9 col-md-6">
-                        {# TODO grid ftp #}
-                        <a id="add-main-file" href="#">wybierz plik główny &raquo;</a>
-                    </div>
-                </div>
-
+                {% bootstrap_field form.master_file layout="horizontal" %}
                 {% bootstrap_field form.executable layout="horizontal" form_group_class="form-group collapse" %}
                 {% bootstrap_field form.script layout="horizontal" form_group_class="form-group collapse" %}
                 {% bootstrap_field form.arguments layout="horizontal" %}
         </div>
     </form>
 
+    <div id="gridftp" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
+        <div class="modal-dialog modal-lg">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                    <h4 class="modal-title" id="modal-label">Wybierz plik</h4>
+                </div>
+                <div class="modal-body">
+                    {% include 'filex/source.html' %}
+                </div>
+            </div>
+        </div>
+    </div>
+
 {% endblock %}