File manager - Edit - /home/autoph/public_html/projects/Rating-AutoHub/public/js/auth/add_roles.js
Back
(function(e){ "use strict"; var search_type_filter = []; var rolesList = null; var url = window.location.href; // var id = url.match(/\/(\d+)$/)[1]; function fetchAbilities(){ $.ajax({ type: "GET", url: "/getAllAbilities", dataType: 'json', data: null, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ $('#abilities-panel').jstree({ core:{ data: result.abilities }, checkbox: { three_state: true }, plugins:['checkbox'] // }); }) // .on('ready.jstree', function(){ // var tree = $('#abilities-panel').jstree(true); // result.abilities.forEach(function(ability){ // // console.log(ability); // var node = tree.get_json('#', { flat: true }).find(function(n) { // return n.text === ability; // }); // if (node) { // tree.check_node(node.id); // } // }) // }); }, error: function(error){ // toastRWithTime("Not sent",'error'); } }); } function submitRoleAbilities(){ $('#user_abilities').on('submit', function(e){ e.preventDefault(); var selectedNodes = $('#abilities-panel').jstree('get_checked', true); var selectedData = []; $.each(selectedNodes, function(index, node) { var nodeId = node.id; var nodeText = node.text; var parentNode = $('#abilities-panel').jstree('get_parent', node); var parentText = ''; if (parentNode !== '#') { parentText = $('#abilities-panel').jstree('get_node', parentNode).text; } selectedData.push({ nodeId: nodeId, nodeText: nodeText, parentNodeText: parentText }); }); $.ajax({ type: "POST", url: "/addNewRole", dataType: 'json', data: { name: $('#role_name').val(), abilities:selectedData }, // processData: false, // contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ toastRWithTime("Success","success"); // window.location.href = '/userIndex'; }, error: function(error){ console.log(error); toastRWithTime(error.responseJSON.message,"error") } }); }); } $(function(){ fetchAbilities(); submitRoleAbilities(); $('.check-all').on('click', function(e){ e.preventDefault(); var tree = $('#abilities-panel').jstree(true); tree.check_all(); toastRWithTime("all abilities checked","Success"); }); $('.uncheck-all').on('click', function(e){ e.preventDefault(); var tree = $('#abilities-panel').jstree(true); tree.uncheck_all(); toastRWithTime("all abilities unchecked","error"); }); }); })();
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings