Added cancel button for snippet edit
This commit is contained in:
parent
dc94262bfb
commit
b995df4533
|
@ -55,6 +55,21 @@ function makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, date, text, attachmen
|
|||
}
|
||||
updateProjectSelector();
|
||||
|
||||
if (originalSnippetEl) {
|
||||
snippetEdit.cancelLink.addEventListener("click", function() {
|
||||
cancel();
|
||||
});
|
||||
} else {
|
||||
snippetEdit.cancelLink.remove();
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if (originalSnippetEl) {
|
||||
snippetEdit.root.parentElement.insertBefore(originalSnippetEl, snippetEdit.root);
|
||||
}
|
||||
snippetEdit.root.remove();
|
||||
}
|
||||
|
||||
function addProject(proj) {
|
||||
let projEl = snippetEditProjectTemplate();
|
||||
projEl.projectId.value = proj.id;
|
||||
|
@ -328,8 +343,7 @@ function makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, date, text, attachmen
|
|||
if (originalSnippetEl && (!attachmentChanged && originalText == snippetEdit.text.value.trim() && !projectsChanged)) {
|
||||
// NOTE(asaf): We're in edit mode and nothing changed, so no need to submit to the server.
|
||||
ev.preventDefault();
|
||||
snippetEdit.root.parentElement.insertBefore(originalSnippetEl, snippetEdit.root);
|
||||
snippetEdit.root.remove();
|
||||
cancel();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<a data-tmpl="username" class="flex-shrink-0"></a>
|
||||
<div class="spacer flex-grow-1"></div>
|
||||
<span data-tmpl="date" class="flex-shrink-0">Date</span>
|
||||
<a data-tmpl="cancelLink" href="javascript:;" class="ml2 flex-shrink-0">✖</a>
|
||||
</div>
|
||||
<textarea data-tmpl="text" placeholder="Description and/or links" class="w-100 h4 mt3" name="text"></textarea>
|
||||
<div class="mv3">
|
||||
|
|
Loading…
Reference in New Issue