1 {% extends "layout.html" %}
5 <script src="{{ STATIC_URL }}js/jquery-ui.js"></script>
6 <script src="{{ STATIC_URL }}js/jquery-ui-combobox.js"></script>
7 <link rel='stylesheet' type='text/css' href="{{ STATIC_URL }}css/jquery-ui.css">
8 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.ui.combobox.css">
11 <div class="col-md-12">
12 <ul class="nav nav-tabs nav-section">
13 <li class="active"><a href="#new">Create new Project</a></li>
14 <li><a href="#existing">Join existing Project</a></li>
22 <div class="col-md-12">
24 {% for error in errors %}
32 <div class="container tab-content">
34 <div class="tab-pane active" id="new">
36 <div class="col-md-12">
37 <h3>Create a new Project</h3>
43 <div class="col-md-12">
44 <form role="form" method="post" action="/portal/project_request">
46 <div class="form-group">
47 <input type="text" name="project_name" value="" style="width:380px;" placeholder="Name" required>
49 <div class="form-group">
50 <select id="org_name" name="authority_name" class="form-control" style="width:380px" value="{{ organization }}" required>
52 {% for authority in authorities %}
53 {% if authority.name %}
54 <option value="{{ authority.authority_hrn }}" {% if authority.authority_hrn == authority_hrn %}selected{% endif %}>{{authority.name}}</option>
56 <option value="{{ authority.authority_hrn }}" {% if authority.authority_hrn == authority_hrn %}selected{% endif %}>{{authority.authority_hrn}}</option>
64 <div class="form-group">
65 <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Description" style="width:380px" title="Purpose of your project (informative)" required="required"></textarea>
67 <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Send Request</button>
74 <div class="tab-pane" id="existing">
76 <div class="col-md-6">
77 <h3>Join an existing Project</h3>
79 <div class="col-md-6">
80 <h3>List of projects you are part of</h3>
84 <div class="col-md-6">
85 <form role="form" method="post" action="/portal/project_request">
87 <div id="project_loading" style="display:inline;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading projects" /></div>
88 <select id="projects" name="project_name" style="display:none;"></select> <div style="display:none;" id="projects_button"><input type="submit" id="join" name="join" value="Join" class="btn"/></div>
91 <div class="col-md-6">
92 <table class="table project-list">
93 {% for pending in pending_projects %}
94 <tr><td>(PENDING) {{ pending.project_name }}</td><td>{{ pending.authority_hrn }}</td><td>{{ pending.created|date:"d/m/Y" }}</td></tr>
96 {% for pending in pending_join_projects %}
97 <tr><td>(PENDING JOIN) {{ pending.project_name }}</td><td> </td><td>{{ pending.created|date:"d/m/Y" }}</td></tr>
107 $(document).ready(function() {
108 var myprojects = JSON.parse(localStorage.getItem('projects'));
109 console.log(myprojects);
111 $.each(myprojects, function (i, val){
113 $('.project-list').append('<tr><td>'+ val +'</td></tr>');
116 $('.project-list').html('<tr><td>no projetcs</td></tr>');
119 $('.nav-tabs a').click(function (e) {
123 $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS{{ root_authority_hrn }}' }}, function( data ) {
126 project_row = "<option value=''> - </option>";
127 projects.push(project_row);
129 $.each( data, function( key, val ) {
130 if(val.authority_hrn.split('.').length > 2){
131 if($.inArray(val.authority_hrn, myprojects)==-1){
132 project_row = "<option value='"+val.authority_hrn+"'>"+val.authority_hrn+"</option>";
133 projects.push(project_row);
137 $("#projects").show();
138 $("#projects_button").css('margin-left', '50px');
139 $("#projects_button").css('display', 'inline-block');
140 $("#project_loading").hide();
141 $("#projects").html(projects.join( "" ));
142 $("#projects").combobox();
146 $("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
147 var jsonData = JSON.parse(data);
148 $(this).attr("value", jsonData[0]['parent_authority']);
150 $("#authority_hrn").val("{{authority_name}}");
151 var availableTags = [
153 {% for authority in authorities %}
154 {% if authority.name %}
155 {value:"{{ authority.name }}",label:"{{authority.name}}"},
156 // to show only full name
158 {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
162 {value:"",label:"No authority found !!!"}
166 availableTags.sort(function(a,b){
167 var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase();
176 $( "#authority_hrn" ).autocomplete({
177 source: availableTags,
179 select: function( event, ui ) {console.log(jQuery(this));}
182 $("#submit_pi").click(function() {
183 localStorage.clear();
185 // auto-complete the form
186 jQuery("#org_name").combobox();