Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/feedback.js

60 lines
1.8 KiB
JavaScript

$('#statusModal').on('show.bs.modal', (e) => {
const btn = $(e.relatedTarget);
const id = btn.data('id');
const state = btn.data('state');
console.log(id, state);
const modal = $('#statusModal');
$('#feedbackState option').each(() => {
$(this).removeAttr('disabled').removeAttr('selected');
});
const activeOption = $('#feedbackState option[value=' + state + ']');
activeOption.attr('selected', 'selected');
let curOption = activeOption;
for (let i = 0; i < 6; i++) {
curOption = curOption.prev();
if (curOption.length === 0) {
break;
}
curOption.attr('disabled', 'disabled');
}
$('form', modal).attr('action', '/admin/feedback/change/' + id);
});
function archiveFeedback(id) {
const row = $('#entry-' + id);
$.ajax({
url: '/admin/feedback/archive',
method: 'post',
data: {
id
},
success: (result) => {
// result = JSON.parse(result);
console.log(result);
if (result.type === 'success') {
setTimeout(() => {
row.find('#loader').css({
color: '#fff',
backgroundColor: '#2ecc71'
});
row.find('#loader .fa').removeClass('fa-spinner').removeClass('fa-spin').addClass('fa-check');
setTimeout(() => {
row.fadeOut(1000);
setTimeout(() => row.remove(), 3000);
}, 2000)
}, 1000);
} else {
}
},
beforeSend: () => {
row.children().hide();
row.append('<td id="loader" colspan="12" style="text-align:center;"><i class="fa fa-spinner fa-spin"></i></td>');
}
});
}