File manager - Edit - /home/autoph/public_html/projects/tickets-autohub/public/js/authentication/task/add.js
Back
(function(e){ "use strict"; var status_check; function initTree(){ $.ajax({ url: "/roles/fetchRoles", type: "GET", dataType: 'json', data: null, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ console.log(result); $('#tree-container').jstree({ core: { data: result }, checkbox: { three_state: true }, plugins: ['checkbox'] }).on('ready.jstree', function() { var tree = $('#tree-container').jstree(true); }); }, error: function(error){ } }); } function submit(){ $('#rolesForm').on('submit', function(e){ e.preventDefault(); let com_id = $("#multiple-select-clear-field-company").val(); let dealer_id = $("#multiple-select-clear-field-dealer").val(); // let fullAccess = ($("#full_access").is(":checked") ? 1 : 0); let fullAccess = 0; if($("#full_access").is(":checked")){ fullAccess =1; } var selectedNodes = $('#tree-container').jstree('get_checked', true); var selectedData = []; $.each(selectedNodes, function(index, node) { var nodeId = node.id; var nodeText = node.text; var parentNode = $('#tree-container').jstree('get_parent', node); var parentText = ''; if (parentNode !== '#') { parentText = $('#tree-container').jstree('get_node', parentNode).text; } selectedData.push({ nodeId: nodeId, nodeText: nodeText, parentNodeText: parentText }); }); $.ajax({ type: "POST", url: "/roles/store", dataType: 'json', data: { abilities: selectedData, stat:status_check, title:$('#role_title').val(),com_id: com_id, dealer_id : dealer_id, full_access : fullAccess }, // processData: false, // contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ toastRWithTime(result.message,"success"); }, error: function(error){ toastRWithTime(error.responseJSON['message'],"error") } }); }); } $(function(e){ $("#tree-container").jstree("close_all"); $("#activate_role").change(function() { if ($(this).is(":checked")) { toastRWithTime('activate role',"success"); status_check = 1; } else { toastRWithTime("deactivate role","error") status_check = null; } }); $(".expand-all").on("click", function (t) { t.preventDefault(); $("#tree-container").jstree("open_all"); }); $(".collapse-all").on("click", function (t) { t.preventDefault(); $("#tree-container").jstree("close_all"); }); $('.check-all').on('click', function(e){ e.preventDefault(); var tree = $('#tree-container').jstree(true); tree.check_all(); toastRWithTime("all abilities checked","Success"); }); $('.uncheck-all').on('click', function(e){ e.preventDefault(); var tree = $('#tree-container').jstree(true); tree.uncheck_all(); toastRWithTime("all abilities unchecked","error"); }); initTree(); submit(); }); $( '#multiple-select-clear-field-company' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), closeOnSelect: false, allowClear: true, } ); $( '#multiple-select-clear-field-dealer' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), closeOnSelect: false, allowClear: true, } ); function sChange(){ const comArr = $('#multiple-select-clear-field-company').val(); // Get the selected values $.ajax({ url: "/roles/fetchDealers", type: "POST", data: {com_id: comArr}, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ $('#multiple-select-clear-field-dealer').empty(); $.each(result[0], function(index, dealer) { let optSelected = (result[1].includes(dealer.id) ? 'selected' :''); // console.log(dealer.id+' '+optSelected); $('#multiple-select-clear-field-dealer').append('<option value="' + dealer.id + '" '+optSelected+'>' + dealer.dealer_name + '</option>'); }); }, error: function(error){ console.log(error); } }); } sChange(); $("#multiple-select-clear-field-company").on('change', function(){ const comArr = $(this).val(); $.ajax({ url: "/roles/fetchDealers", type: "POST", data: {com_id: comArr}, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ $('#multiple-select-clear-field-dealer').empty(); $.each(result[0], function(index, dealer) { let optSelected = (result[1].includes(dealer.id) ? 'selected' :'hinde'); $('#multiple-select-clear-field-dealer').append('<option value="' + dealer.id + '" '+optSelected+'>' + dealer.dealer_name + '</option>'); }); }, error: function(error){ console.log(error); } }); }); if($("#full_access").is(':checked')){ $(".div-company").hide(); $(".div-dealer").hide(); } else { $(".div-company").show(); $(".div-dealer").show(); } $("#full_access").on('click',function(){ $(".div-company").show(); $(".div-dealer").show(); if($(this).is(':checked')){ $('#multiple-select-clear-field-company').append('<option value="" selected></option>'); $('#multiple-select-clear-field-dealer').val(''); $(".div-company").hide(); $(".div-dealer").hide(); } }); })();
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings