|
184 | 184 | form.submit(); |
185 | 185 | } |
186 | 186 |
|
| 187 | +function delete_study() { |
| 188 | + if ($("#study-alias").val() != "{{study_alias}}") { |
| 189 | + alert("The added name doesn't match the study alias"); |
| 190 | + return false; |
| 191 | + } |
| 192 | + var form = $("<form>") |
| 193 | + .attr("action", window.location.href) |
| 194 | + .attr("method", "post") |
| 195 | + .append($("<input>") |
| 196 | + .attr("type", "hidden") |
| 197 | + .attr("name", "study_id") |
| 198 | + .attr("value", {{study.id}})) |
| 199 | + .append($("<input>") |
| 200 | + .attr("type", "hidden") |
| 201 | + .attr("name", "action") |
| 202 | + .attr("value", "delete_study")); |
| 203 | + $("body").append(form); |
| 204 | + form.submit(); |
| 205 | +} |
| 206 | + |
187 | 207 | function delete_sample_template() { |
188 | 208 | sample_template_id = {{study.sample_template}}; |
189 | 209 | if (confirm('Are you sure you want to delete sample template ID: ' + sample_template_id + '?')) { |
@@ -548,6 +568,7 @@ <h2><i>{{study_alias}}</i></h2> |
548 | 568 | <a class="btn btn-default glyphicon glyphicon-edit" href="/study/edit/{{study.id}}" title="Edit the study information" style="margin:5px; word-spacing: -10px;"> Edit</a> |
549 | 569 | {% end %} |
550 | 570 | <a href="/study/upload/{{study.id}}" class="btn btn-default glyphicon glyphicon-upload" title="Upload study files" style="margin:5px; word-spacing: -10px;"> Upload</a> |
| 571 | + <a class="btn btn-danger glyphicon glyphicon-trash" data-toggle="modal" data-target="#delete-study"></a> |
551 | 572 | </td> |
552 | 573 | </tr> |
553 | 574 | </table> |
@@ -580,4 +601,21 @@ <h2><i>{{study_alias}}</i></h2> |
580 | 601 | {% end %} |
581 | 602 | </div> |
582 | 603 |
|
| 604 | + |
| 605 | +<div class="modal fade delete-study" tabindex="-1" role="dialog" id="delete-study"> |
| 606 | + <div class="modal-dialog modal-sm"> |
| 607 | + <div class="modal-content"> |
| 608 | + <div class="modal-header"> |
| 609 | + <h3>Deleting:<br/></h3><h4>{{study_title}}</h4> |
| 610 | + You will only be able to delete a study that has no data associated with it. |
| 611 | + </div> |
| 612 | + <div class="modal-body"> |
| 613 | + To continue you need to write the alias name of the study: |
| 614 | + <input type="text" name="study-alias" id="study-alias"> |
| 615 | + <a class="btn btn-danger glyphicon glyphicon-trash" onclick="delete_study()"></a> |
| 616 | + </div> |
| 617 | + </div> |
| 618 | + </div> |
| 619 | +</div> |
| 620 | + |
583 | 621 | {% end %} |
0 commit comments