Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | {% extends "base.html" %} |
| 2 | {% load projecttags %} |
| 3 | {% load humanize %} |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 4 | |
| 5 | {% block title %} Create a new project - Toaster {% endblock %} |
| 6 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | {% block pagecontent %} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8 | <div class="row"> |
| 9 | <div class="col-md-12"> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | <div class="page-header"> |
| 11 | <h1>Create a new project</h1> |
| 12 | </div> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | {% if alert %} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 14 | <div class="alert alert-danger" role="alert">{{alert}}</div> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | {% endif %} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | <form method="POST">{% csrf_token %} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 18 | <div class="form-group" id="validate-project-name"> |
| 19 | <label class="control-label">Project name <span class="text-muted">(required)</span></label> |
| 20 | <input type="text" class="form-control" required id="new-project-name" name="projectname"> |
| 21 | </div> |
| 22 | <p class="help-block text-danger" style="display: none;" id="hint-error-project-name">A project with this name exists. Project names must be unique.</p> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | <label class="project-form">Project type:</label> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | {% if releases.count > 0 %} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 26 | <label class="project-form radio" style="padding-left: 35px;"><input id='type-new' type="radio" name="ptype" value="new"/> New project</label> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | {% endif %} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | <label class="project-form radio" style="padding-left: 35px;"><input id='type-import' type="radio" name="ptype" value="import"/> Import command line project</label> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | |
| 30 | {% if releases.count > 0 %} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 31 | <div class="release form-group"> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | {% if releases.count > 1 %} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | <label class="control-label"> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | Release |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | <span class="glyphicon glyphicon-question-sign get-help" title="The version of the build system you want to use for this project"></span> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | </label> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 37 | <select name="projectversion" id="projectversion" class="form-control"> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | {% for release in releases %} |
| 39 | <option value="{{release.id}}" |
| 40 | {%if defaultbranch == release.name %} |
| 41 | selected |
| 42 | {%endif%} |
| 43 | >{{release.description}}</option> |
| 44 | {% endfor %} |
| 45 | </select> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 46 | <div class="row"> |
| 47 | <div class="col-md-4"> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | {% for release in releases %} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 49 | <div class="helptext" id="description-{{release.id}}" style="display: none"> |
| 50 | <span class="help-block">{{release.helptext|safe}}</span> |
| 51 | </div> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | {% endfor %} |
Brad Bishop | 5dd7cbb | 2018-09-05 22:26:40 -0700 | [diff] [blame] | 53 | </div> |
| 54 | </div> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | {% else %} |
| 56 | <input type="hidden" name="projectversion" value="{{releases.0.id}}"/> |
| 57 | {% endif %} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 58 | |
| 59 | <input type="checkbox" class="checkbox-mergeattr" name="mergeattr" value="mergeattr"> Merged Toaster settings (Command line user compatibility) |
| 60 | <span class="glyphicon glyphicon-question-sign get-help" title="Place the Toaster settings into the standard 'local.conf' and 'bblayers.conf' instead of 'toaster_bblayers.conf' and 'toaster.conf'"></span> |
| 61 | |
| 62 | </div> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | {% endif %} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 64 | |
| 65 | <div class="build-import form-group" id="import-project"> |
| 66 | <label class="control-label">Import existing project directory |
| 67 | <span class="glyphicon glyphicon-question-sign get-help" title="Enter a path to an existing build directory, import the existing settings, and create a Toaster Project for it."></span> |
| 68 | </label> |
| 69 | <input style="width: 33%;"type="text" class="form-control" required id="import-project-dir" name="importdir"> |
| 70 | </div> |
| 71 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 72 | <div class="top-air"> |
| 73 | <input type="submit" id="create-project-button" class="btn btn-primary btn-lg" value="Create project"/> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | <span class="help-inline" style="vertical-align:middle;">To create a project, you need to enter a project name</span> |
| 75 | </div> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 76 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | </form> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 78 | </div> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | </div> |
| 80 | |
| 81 | <script type="text/javascript"> |
| 82 | $(document).ready(function () { |
| 83 | // hide the new project button |
| 84 | $("#new-project-button").hide(); |
| 85 | $('.btn-primary').attr('disabled', 'disabled'); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 86 | $('#type-new').attr('checked', 'checked'); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | |
| 88 | // enable submit button when all required fields are populated |
| 89 | $("input#new-project-name").on('input', function() { |
| 90 | if ($("input#new-project-name").val().length > 0 ){ |
| 91 | $('.btn-primary').removeAttr('disabled'); |
| 92 | $(".help-inline").css('visibility','hidden'); |
| 93 | } |
| 94 | else { |
| 95 | $('.btn-primary').attr('disabled', 'disabled'); |
| 96 | $(".help-inline").css('visibility','visible'); |
| 97 | } |
| 98 | }); |
| 99 | |
| 100 | // show relevant help text for the selected release |
| 101 | var selected_release = $('select').val(); |
| 102 | $("#description-" + selected_release).show(); |
| 103 | |
| 104 | |
| 105 | $('select').change(function(){ |
| 106 | var new_release = $('select').val(); |
| 107 | $(".helptext").hide(); |
| 108 | $('#description-' + new_release).fadeIn(); |
| 109 | }); |
| 110 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 111 | libtoaster.makeProjectNameValidation($("#new-project-name"), |
| 112 | $("#hint-error-project-name"), $("#validate-project-name"), |
| 113 | $(".btn-primary")); |
| 114 | |
| 115 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 116 | // Hide the project release when you select an analysis project |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 117 | function projectType() { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 118 | if ($("input[type='radio']:checked").val() == 'new') { |
| 119 | $('.build-import').fadeOut(); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | $('.release').fadeIn(); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 121 | $('#import-project-dir').removeAttr('required'); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | } |
| 123 | else { |
| 124 | $('.release').fadeOut(); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 125 | $('.build-import').fadeIn(); |
| 126 | $('#import-project-dir').attr('required', 'required'); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | projectType(); |
| 130 | |
| 131 | $('input:radio').change(function(){ |
| 132 | projectType(); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 133 | }); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | }); |
| 135 | </script> |
| 136 | |
| 137 | {% endblock %} |