Commit 2102dbce authored by Leigh Stoller's avatar Leigh Stoller

Add Cancel edit button as per issue #413. This closes issue #413.

parent 6788d899
......@@ -552,6 +552,27 @@ $(function ()
}
});
/*
* Cancel Edit button.
*/
$('#cancel_edit_button').click(function (e) {
e.preventDefault();
/*
* Bind a handler for the confirm button,
*/
$('#confirm_cancel_edit').click(function (event) {
event.preventDefault();
modified = false;
window.location.reload();
})
sup.ShowModal('#confirm_cancel_edit_modal',
// Delete handler no matter how it hides.
function () {
$('#confirm_cancel_edit').off("click");
});
});
/*
* If the description/instructions textarea are edited, copy
* the text back into the rspec since that is what actually
......@@ -660,6 +681,7 @@ $(function ()
EnableButtons();
modified = false;
DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
if (window.UPDATED) {
initNotifyUpdate();
}
......@@ -764,6 +786,7 @@ $(function ()
if (!initialized) {
modified = false;
DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
}
initialized = true;
}
......@@ -773,6 +796,7 @@ $(function ()
modified = true;
DisableButtons();
EnableButton("profile_submit_button");
EnableButton("cancel_edit_button");
}
}
......@@ -1155,6 +1179,7 @@ $(function ()
else {
EnableButtons();
DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
}
},
true);
......@@ -1176,6 +1201,7 @@ $(function ()
EnableButton("profile_delete_button");
EnableButton("profile_instantiate_button");
EnableButton("profile_submit_button");
EnableButton("cancel_edit_button");
EnableButton("profile_copy_button");
EnableButton("profile_publish_button");
}
......@@ -1184,6 +1210,7 @@ $(function ()
DisableButton("profile_delete_button");
DisableButton("profile_instantiate_button");
DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
DisableButton("profile_copy_button");
DisableButton("profile_publish_button");
}
......
......@@ -709,21 +709,32 @@
<div style="margin-top: 10px;"></div>
<div class='form-group'>
<div class='col-sm-offset-2 col-sm-10'>
<% if (viewing && canmodify) { %>
<button class='btn btn-danger btn-xs pull-right' disabled
id='cancel_edit_button'
style='margin-right: 10px;'
type='submit' name='cancel-edit'>
Cancel
</button>
<% } %>
<% if (!viewing || canmodify) { %>
<button class='btn btn-primary btn-xs pull-right' disabled
id='profile_submit_button'
style='margin-right: 10px;'
style='margin-right: 5px;'
type='submit' name='create'>
<%- button_label %>
</button>
<% } %>
<% if (viewing) { %>
<% if (!disabled && gotrspec) { %>
<a class='btn btn-primary btn-xs pull-right' disabled
id='profile_instantiate_button'
<% if (candelete) { %>
<button class='btn btn-danger btn-xs pull-left' disabled
id='profile_delete_button'
style='margin-right: 10px;'
type='submit' name='create'>Instantiate
</a>
data-toggle='modal'
data-target='#confirm-delete-profile-modal'
type='button' name='delete'>Delete
</button>
<% } %>
<% if (viewing) { %>
<a class='btn btn-primary btn-xs pull-left'
id='profile_copy_button'
style='margin-right: 10px;'
......@@ -759,15 +770,12 @@
Share
</button>
</span>
<% } %>
<% if (candelete) { %>
<button class='btn btn-danger btn-xs pull-left' disabled
id='profile_delete_button'
<% if (!disabled && gotrspec) { %>
<a class='btn btn-primary btn-xs pull-left' disabled
id='profile_instantiate_button'
style='margin-right: 10px;'
data-toggle='modal'
data-target='#confirm-delete-profile-modal'
type='button' name='delete'>Delete
</button>
type='submit' name='create'>Instantiate
</a>
<% } %>
<% if (withpublishing && canpublish) { %>
<span class='pull-right'
......@@ -794,6 +802,20 @@
</div>
</div>
</div>
<!-- Confirm cancel edit -->
<div id='confirm_cancel_edit_modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center><h4>Confirm to Discard Changes</h4>
<button class='btn btn-danger btn-sm'
id='confirm_cancel_edit'>Confirm</a></center>
</div>
</div>
</div>
</div>
<!-- Confirm Tour Reuse -->
<div id='reuse_tour_modal' class='modal fade'
data-keyboard='false' data-backdrop='static'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment