Finished delete and data table fiew for tests
This commit is contained in:
@ -138,6 +138,19 @@ table.dataTable {
|
||||
|
||||
.user-row-actions {
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.test-row-actions {
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dt-buttons {
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
float:none;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.user-row-actions button {
|
||||
@ -197,6 +210,10 @@ table.dataTable {
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.button-icon {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* Fallback for Edge
|
||||
-------------------------------------------------- */
|
||||
@supports (-ms-ime-align: auto) {
|
||||
|
@ -350,12 +350,49 @@ $('form[name=form-update-account]').submit(function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('.delete-test').click(function(event) {
|
||||
|
||||
_id = $(this).data('_id')
|
||||
|
||||
$.ajax({
|
||||
url: `/admin/tests/delete/${_id}`,
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
window.location.href = '/admin/tests/';
|
||||
},
|
||||
error: function(response) {
|
||||
if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
|
||||
alert.innerHTML = alert.innerHTML + `
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
|
||||
${response.responseJSON.error}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
`;
|
||||
} else if (response.responseJSON.error instanceof Array) {
|
||||
for (var i = 0; i < response.responseJSON.error.length; i ++) {
|
||||
alert.innerHTML = alert.innerHTML + `
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
|
||||
${response.responseJSON.error[i]}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Edit and Delete Test Button Handlers
|
||||
|
||||
$('form[name=form-create-test]').submit(function(event) {
|
||||
|
||||
var $form = $(this);
|
||||
var alert = document.getElementById('alert-box');
|
||||
var data = $form.serialize();
|
||||
console.log(data)
|
||||
alert.innerHTML = ''
|
||||
|
||||
$.ajax({
|
||||
@ -364,10 +401,9 @@ $('form[name=form-create-test]').submit(function(event) {
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
window.location.reload();
|
||||
window.location.href = '/admin/tests/';
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response.responseJSON)
|
||||
if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
|
||||
alert.innerHTML = alert.innerHTML + `
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
@ -396,8 +432,6 @@ $('form[name=form-create-test]').submit(function(event) {
|
||||
// Dismiss Cookie Alert
|
||||
$('#dismiss-cookie-alert').click(function(event){
|
||||
|
||||
console.log('Foo')
|
||||
|
||||
$.ajax({
|
||||
url: '/cookies/',
|
||||
type: 'GET',
|
||||
|
Reference in New Issue
Block a user