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 () ...@@ -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 * If the description/instructions textarea are edited, copy
* the text back into the rspec since that is what actually * the text back into the rspec since that is what actually
...@@ -660,6 +681,7 @@ $(function () ...@@ -660,6 +681,7 @@ $(function ()
EnableButtons(); EnableButtons();
modified = false; modified = false;
DisableButton("profile_submit_button"); DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
if (window.UPDATED) { if (window.UPDATED) {
initNotifyUpdate(); initNotifyUpdate();
} }
...@@ -764,6 +786,7 @@ $(function () ...@@ -764,6 +786,7 @@ $(function ()
if (!initialized) { if (!initialized) {
modified = false; modified = false;
DisableButton("profile_submit_button"); DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
} }
initialized = true; initialized = true;
} }
...@@ -773,6 +796,7 @@ $(function () ...@@ -773,6 +796,7 @@ $(function ()
modified = true; modified = true;
DisableButtons(); DisableButtons();
EnableButton("profile_submit_button"); EnableButton("profile_submit_button");
EnableButton("cancel_edit_button");
} }
} }
...@@ -1155,6 +1179,7 @@ $(function () ...@@ -1155,6 +1179,7 @@ $(function ()
else { else {
EnableButtons(); EnableButtons();
DisableButton("profile_submit_button"); DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
} }
}, },
true); true);
...@@ -1176,6 +1201,7 @@ $(function () ...@@ -1176,6 +1201,7 @@ $(function ()
EnableButton("profile_delete_button"); EnableButton("profile_delete_button");
EnableButton("profile_instantiate_button"); EnableButton("profile_instantiate_button");
EnableButton("profile_submit_button"); EnableButton("profile_submit_button");
EnableButton("cancel_edit_button");
EnableButton("profile_copy_button"); EnableButton("profile_copy_button");
EnableButton("profile_publish_button"); EnableButton("profile_publish_button");
} }
...@@ -1184,6 +1210,7 @@ $(function () ...@@ -1184,6 +1210,7 @@ $(function ()
DisableButton("profile_delete_button"); DisableButton("profile_delete_button");
DisableButton("profile_instantiate_button"); DisableButton("profile_instantiate_button");
DisableButton("profile_submit_button"); DisableButton("profile_submit_button");
DisableButton("cancel_edit_button");
DisableButton("profile_copy_button"); DisableButton("profile_copy_button");
DisableButton("profile_publish_button"); DisableButton("profile_publish_button");
} }
......
...@@ -709,21 +709,32 @@ ...@@ -709,21 +709,32 @@
<div style="margin-top: 10px;"></div> <div style="margin-top: 10px;"></div>
<div class='form-group'> <div class='form-group'>
<div class='col-sm-offset-2 col-sm-10'> <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) { %> <% if (!viewing || canmodify) { %>
<button class='btn btn-primary btn-xs pull-right' disabled <button class='btn btn-primary btn-xs pull-right' disabled
id='profile_submit_button' id='profile_submit_button'
style='margin-right: 10px;' style='margin-right: 5px;'
type='submit' name='create'> type='submit' name='create'>
<%- button_label %> <%- button_label %>
</button> </button>
<% } %> <% } %>
<% if (candelete) { %>
<button class='btn btn-danger btn-xs pull-left' disabled
id='profile_delete_button'
style='margin-right: 10px;'
data-toggle='modal'
data-target='#confirm-delete-profile-modal'
type='button' name='delete'>Delete
</button>
<% } %>
<% if (viewing) { %> <% if (viewing) { %>
<% if (!disabled && gotrspec) { %>
<a class='btn btn-primary btn-xs pull-right' disabled
id='profile_instantiate_button'
style='margin-right: 10px;'
type='submit' name='create'>Instantiate
</a>
<a class='btn btn-primary btn-xs pull-left' <a class='btn btn-primary btn-xs pull-left'
id='profile_copy_button' id='profile_copy_button'
style='margin-right: 10px;' style='margin-right: 10px;'
...@@ -759,15 +770,12 @@ ...@@ -759,15 +770,12 @@
Share Share
</button> </button>
</span> </span>
<% } %> <% if (!disabled && gotrspec) { %>
<% if (candelete) { %> <a class='btn btn-primary btn-xs pull-left' disabled
<button class='btn btn-danger btn-xs pull-left' disabled id='profile_instantiate_button'
id='profile_delete_button' style='margin-right: 10px;'
style='margin-right: 10px;' type='submit' name='create'>Instantiate
data-toggle='modal' </a>
data-target='#confirm-delete-profile-modal'
type='button' name='delete'>Delete
</button>
<% } %> <% } %>
<% if (withpublishing && canpublish) { %> <% if (withpublishing && canpublish) { %>
<span class='pull-right' <span class='pull-right'
...@@ -794,6 +802,20 @@ ...@@ -794,6 +802,20 @@
</div> </div>
</div> </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 --> <!-- Confirm Tour Reuse -->
<div id='reuse_tour_modal' class='modal fade' <div id='reuse_tour_modal' class='modal fade'
data-keyboard='false' data-backdrop='static'> 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