wip: delete button item modal

This commit is contained in:
Supan Adit Pratama 2023-03-05 20:11:37 +07:00
parent 75d929128b
commit 5e1471463f

View File

@ -209,6 +209,35 @@
</div> </div>
<!-- /.modal-dialog --> <!-- /.modal-dialog -->
</div> </div>
<div class="modal fade" id="todo-item-delete-modal">
<div class="modal-dialog">
<div class="modal-content">
<form action="/" method="post" id="todo-item-delete-modal-form">
<div class="modal-header">
<h4 class="modal-title">Deleting todo item</h4>
</div>
<div class="modal-body">
Are you sure want to delete this todo item ?
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-default pull-left"
id="todo-item-delete-modal-cancel-button">
Cancel
</button>
<button type="submit" class="btn btn-primary">
<i class="fa fa-spinner fa-spin" id="todo-item-delete-modal-confirm-loading-indicator"></i>
<span id="todo-item-delete-modal-confirm-button">Yes</span>
</button>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
@endsection @endsection
@section('js') @section('js')
@ -388,21 +417,23 @@
} }
const deleteTodoItem = function (todoItem) { const deleteTodoItem = function (todoItem) {
$.ajax({ sessionStorage.setItem("TODO_ITEM_ID", todoItem.id);
type: "DELETE", $("#todo-item-delete-modal").modal('show');
url: "/web/todo/item/" + todoItem.id, // $.ajax({
headers: { // type: "DELETE",
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), // url: "/web/todo/item/" + todoItem.id,
}, // headers: {
contentType: "application/json", // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
async: true, // },
success: function (result) { // contentType: "application/json",
loadTodoItemList(); // async: true,
}, // success: function (result) {
error: function (result) { // loadTodoItemList();
toastr.error(result.responseJSON.message); // },
} // error: function (result) {
}); // toastr.error(result.responseJSON.message);
// }
// });
} }
const loadTodoItemList = function () { const loadTodoItemList = function () {
@ -725,6 +756,11 @@
}); });
}); });
// Delete Todo Item Cancel Action
$("#todo-item-delete-modal-cancel-button").on("click", function () {
$("#todo-item-delete-modal").modal('hide');
});
// Search // Search
$("input#search-todo").on('keyup', function () { $("input#search-todo").on('keyup', function () {
loadTodoList(); loadTodoList();