Skip to content

Commit

Permalink
Merge pull request #1954 from antgonza/fix-1268
Browse files Browse the repository at this point in the history
fix #1268
  • Loading branch information
mortonjt committed Sep 28, 2016
2 parents 8f65432 + 4cce0d3 commit a821675
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 643 deletions.
2 changes: 1 addition & 1 deletion qiita_pet/templates/edit_study.html
Expand Up @@ -39,7 +39,7 @@
request = $.ajax({
type: "GET",
url: '{% raw qiita_config.portal_dir %}/check_study/',
data: {study_title: $("#study_title")[0].value {% if study %}, old_study_title: '{{study.title}}'{% end %} }
data: {study_title: $("#study_title")[0].value {% if study %}, old_study_title: "{% raw study.title.replace('"', '\\"') %}"{% end %} }
});
// callback handler that will be called on success
Expand Down
14 changes: 8 additions & 6 deletions qiita_pet/templates/study_base.html
@@ -1,5 +1,7 @@
{% extends sitebase.html %}
{% block head %}
{% set study_title = study_info['study_title'] %}
{% set study_title_msg = study_title.replace('"', '\\"') %}
<link rel="stylesheet" src="{% raw qiita_config.portal_dir %}/static/vendor/css/vis.css" type="text/css">
<script type="text/javascript" src="{% raw qiita_config.portal_dir %}/static/vendor/js/vis.js"></script>
<script type="text/javascript">
Expand Down Expand Up @@ -108,19 +110,19 @@
}

function validate_delete_study_text() {
if ($("#study-alias").val() == "{{study_info['study_title']}}") {
if ($("#study-alias").val() == "{% raw study_title_msg %}") {
$('#delete-study-button').prop('disabled', false);
} else {
$('#delete-study-button').prop('disabled', true);
}
}

function delete_study() {
if($("#study-alias").val() != "{{study_info['study_title']}}") {
if($("#study-alias").val() != "{% raw study_title_msg %}") {
alert("The entered study alias doesn't match the study");
return false;
}
else if(confirm("Are you sure you want to delete {{study_info['study_title']}}?")) {
else if(confirm("Are you sure you want to delete {% raw study_title_msg %}?")) {
$.post('{% raw qiita_config.portal_dir %}/study/delete/', { study_id: {{study_info['study_id']}} })
.done(function ( data ) {
if(data.status == "error") {
Expand Down Expand Up @@ -224,7 +226,7 @@
<!-- Study ID and study alias always on top -->
<div class="row">
<div class="col-md-12" id="study-base-info">
<h2>{{study_info['study_title']}} - ID {{study_info['study_id']}}</h2>
<h2>{% raw study_title %} - ID {{study_info['study_id']}}</h2>
<h3>{{study_info['study_alias']}}</h3>
</div>
</div>
Expand All @@ -239,12 +241,12 @@ <h3>{{study_info['study_alias']}}</h3>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Deleting:<br/></h3><h4>{{study_info['study_title']}}</h4>
<h3>Deleting:<br/></h3><h4>{% raw study_title %}</h4>
</div>
<div class="modal-body">
You will only be able to delete a study that has no data associated with it.<br/>
To continue you need to write the title of the study:<br/>
<input type="text" name="study-alias" id="study-alias" onkeyup="validate_delete_study_text();" size="{{ len(study_info['study_title']) }}">
<input type="text" name="study-alias" id="study-alias" onkeyup="validate_delete_study_text();" size="{{ len(study_title) }}">
<button class="btn btn-danger glyphicon glyphicon-trash" onclick="delete_study();" id="delete-study-button" disabled></button>
</div>
<div class="modal-footer">
Expand Down

0 comments on commit a821675

Please sign in to comment.