chess/resources/views/content/menu_admin/action.blade.php

117 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2024-08-29 03:56:32 +00:00
<script type="text/javascript">
// INIT
var routeTable = "{{$table}}";
var colum = [
{ data: 'definition'},
{ data: 'list_menu'},
{ data: 'action'},
];
console.log(routeTable)
var columStyle =
[
{ "orderable": false, "targets": [-1] }
];
var table = znGetTableScrolling(routeTable,colum,columStyle,'indexTable', 33);
// INIT
$('#formData').on('keyup keypress', function (e) {
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
e.preventDefault();
return false;
}
});
function modalMenu(id,title) {
$('#get_id').val('');
$("#form-data")[0].reset();
// $('#form-data').bootstrapValidator("resetForm", true);
$('#mForm_title').html('Hak Akses '+title);
$.ajax({
url: "{{$admin_menu_get}}",
type: 'POST',
data:{id:id},
beforeSend: function() {
znLoadingPage();
},
success: function (res) {
$('#get_id').val(id);
console.log(res);
var data = $.parseJSON(res);
$.each(data, function (k,v) {
$('#'+v.menu_uid).prop('checked', 'checked');
});
}
}).done(function(msg) {
znLoadingPageEnd();
znModal('mForm');
}).fail(function(msg) {
znLoadingPageEnd();
});
}
function store() {
let myForm = document.getElementById('form-data');
let formData = new FormData(myForm);
$.ajax({
type: "POST",
url: '{{$admin_menu_store}}',
data : formData,
dataType:'JSON',
contentType: false,
cache: false,
processData: false,
beforeSend: function() {
znLoadingModal('mForm');
KTUtil.btnWait(btnLoader, "spinner spinner-right spinner-white pr-15", "Processing..");
},
success: function( msg ) {
KTUtil.btnRelease(btnLoader);
znLoadingModalEnd('mForm');
}
}).done(function( msg ) {
znNotif('success','Berhasil Menyimpan Data');
$('#mForm').modal('hide');
table.ajax.url(routeTable).load();
}).fail(function(msg) {
KTUtil.btnRelease(btnLoader);
znLoadingModalEnd('mForm');
znNotif('warning','Gagal Menyimpan Data');
});
}
function setChild(id,check) {
$('.c'+id).prop('checked', check);
}
function setParent(id,check) {
var sThisVal = 0;
$('input:checkbox.c'+id).each(function () {
sThisVal += parseInt(this.checked ? 1 : 0);
});
if (sThisVal > 0) {
$('.p'+id).prop('checked', true);
}else {
$('.p'+id).prop('checked', false);
}
}
</script>