Added a delete confirmation modal to all views.

This commit is contained in:
Brian McGonagill 2022-08-26 11:18:18 -05:00
parent 4d9d2acff6
commit 29ddc544e5
27 changed files with 117 additions and 127 deletions

View file

@ -0,0 +1,18 @@
<template name="deleteConfirmationModal">
<div id="modalDelete" class="modal">
<div class="modal-content">
<h4>Delete Confirmation</h4>
You are about to permanently delete {{itemName}} from the {{viewName}} list. Are you sure?
</div>
<div class="modal-footer">
<div class="row">
<div class="col s6 m6 l6">
<a class="modal-close waves-effect waves-light btn left cancelDelete orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn confirmDelete red right">Delete</a>
</div>
</div>
</div>
</div>
</template>

View file

@ -0,0 +1,33 @@
Template.deleteConfirmationModal.onCreated(function() {
});
Template.deleteConfirmationModal.onRendered(function() {
$('.modal').modal();
});
Template.deleteConfirmationModal.helpers({
itemName: function() {
return Session.get("item");
},
viewName: function() {
return Session.get("view");
}
});
Template.deleteConfirmationModal.events({
'click .confirmDelete' (event) {
event.preventDefault();
let deleteId = Session.get("deleteId");
let method = Session.get("method");
Meteor.call(method, deleteId, function(err, result) {
if (err) {
console.log(" ERROR deleting item from modal: " + err);
} else {
// console.log(" SUCCESSFULLY deleted.");
$('#modalDelete').modal('close');
}
});
},
});

View file

@ -26,11 +26,11 @@ Template.headerBar.events({
'click .navBtn' (event) {
event.preventDefault();
var clickedTarget = event.target.id;
console.log("clicked " + clickedTarget);
// console.log("clicked " + clickedTarget);
if (clickedTarget == 'mainMenu') {
FlowRouter.go('/');
} else {
console.log("should be going to /" + clickedTarget);
// console.log("should be going to /" + clickedTarget);
FlowRouter.go('/' + clickedTarget);
}
},