|
184 | 184 | form.submit(); |
185 | 185 | } |
186 | 186 |
|
| 187 | +function validate_delete_study_text() { |
| 188 | + if ($("#study-alias").val() == "{{study_alias}}") { |
| 189 | + $('#delete-study-button').prop('disabled', false); |
| 190 | + } else { |
| 191 | + $('#delete-study-button').prop('disabled', true); |
| 192 | + } |
| 193 | +} |
| 194 | + |
187 | 195 | function delete_study() { |
188 | 196 | if ($("#study-alias").val() != "{{study_alias}}") { |
189 | 197 | alert("The added name doesn't match the study alias"); |
190 | 198 | return false; |
191 | 199 | } |
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(); |
| 200 | + if (confirm('Are you sure you want to delete "{{study_title}}"?')) { |
| 201 | + var form = $("<form>") |
| 202 | + .attr("action", window.location.href) |
| 203 | + .attr("method", "post") |
| 204 | + .append($("<input>") |
| 205 | + .attr("type", "hidden") |
| 206 | + .attr("name", "study_id") |
| 207 | + .attr("value", {{study.id}})) |
| 208 | + .append($("<input>") |
| 209 | + .attr("type", "hidden") |
| 210 | + .attr("name", "action") |
| 211 | + .attr("value", "delete_study")); |
| 212 | + $("body").append(form); |
| 213 | + form.submit(); |
| 214 | + } |
205 | 215 | } |
206 | 216 |
|
207 | 217 | function delete_sample_template() { |
@@ -568,7 +578,7 @@ <h2><i>{{study_alias}}</i></h2> |
568 | 578 | <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> |
569 | 579 | {% end %} |
570 | 580 | <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> |
| 581 | + <a class="btn btn-danger glyphicon glyphicon-trash" style="display: inline-block;" data-toggle="modal" data-target="#delete-study"> Delete-study</a> |
572 | 582 | </td> |
573 | 583 | </tr> |
574 | 584 | </table> |
@@ -606,13 +616,16 @@ <h2><i>{{study_alias}}</i></h2> |
606 | 616 | <div class="modal-dialog modal-sm"> |
607 | 617 | <div class="modal-content"> |
608 | 618 | <div class="modal-header"> |
| 619 | + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
609 | 620 | <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 | 621 | </div> |
612 | 622 | <div class="modal-body"> |
| 623 | + You will only be able to delete a study that has no data associated with it. |
| 624 | + </div> |
| 625 | + <div class="modal-footer"> |
613 | 626 | 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> |
| 627 | + <input type="text" name="study-alias" id="study-alias" onkeyup="validate_delete_study_text();"> |
| 628 | + <button class="btn btn-danger glyphicon glyphicon-trash" onclick="delete_study();" id="delete-study-button" disabled></button> |
616 | 629 | </div> |
617 | 630 | </div> |
618 | 631 | </div> |
|
0 commit comments