File manager - Edit - /home/autoph/public_html/projects/tickets-autohub/public/js/authentication/task/form.js
Back
(function(e){ "use strict"; function checkRoleVal(){ $('#_userRole').on('change', function(e){ var selectedRoleName = $(this).find('option:selected').text(); $.ajax({ type: "POST", url: "/users/getAbilitiesByRole/" + $(this).val(), dataType: 'json', data: null, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ var abilities = $("<div></div>"); var roleTitle = $("<h6></h6>"); roleTitle.html("Change To: <br/><br/>" + selectedRoleName + ":"); abilities.append(roleTitle); // Reset the existing content of the _roleAbilities div $('#_roleAbilities').empty(); // Append the abilities div to the _roleAbilities div $('#_roleAbilities').append(abilities); $.each(result, function(index, key) { var ability = $("<div></div>"); ability.text("🗸 " + key.title); abilities.append(ability); }); }, error: function(error){ } }); }); } function getUserAbilities(){ $.ajax({ type: "POST", url: "/users/getUserAbility/" + user.id, dataType: 'json', data: null, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ $.each(result.roles, function(index, role) { // Create a new div element for the role var roleDiv = $("<div></div>"); // Create an h6 element for the role title var roleTitle = $("<h6></h6>"); roleTitle.html("Current:<br/><br/>" + role.title + " Level:"); // Append the role title to the role div roleDiv.append(roleTitle); // Append the role div to the existing div with id "abilitiesDiv" $('#abilitiesDiv').append(roleDiv); // Iterate over the abilities of the current role $.each(role.abilities, function(index, ability) { // Create a new div element for each ability var abilityDiv = $("<div></div>"); // Set the text content of the ability div abilityDiv.text("🗸 " + ability.title); // Append the ability div to the role div roleDiv.append(abilityDiv); }); }); }, error: function(error){ // console.log(error); // swal.fire({ // 'icon':"error", // 'text': error.statusText // }); } }); } function submit(){ $('#_editUserForm').on('submit', (e)=>{ e.preventDefault(); if ($("#_userRole").val() === '') { roleError.style.display = 'block'; e.preventDefault(); // Prevent form submission } else { roleError.style.display = 'none'; } var formData = new FormData(); formData.append('id',user.id); formData.append('f_name',$('#_fName').val()); formData.append('l_name',$('#_lName').val()); formData.append('email',$('#_email').val()); formData.append('viber',$("#_viber").val()); formData.append('anydesk',$("#_anydesk").val()); formData.append('position',$('#_position').val()); formData.append('role',$('#_userRole').val()); $.ajax({ type: "POST", url: "/users/update", dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ toastRWithTime(result.message,"success"); window.location.reload(); // swal.fire({ // 'text': result.message // }); // window.location.href = "/category"; }, error: function(error){ // console.log(error); // swal.fire({ // 'icon':"error", // 'text': error.statusText // }); } }); }); } $(function(){ getUserAbilities(); submit(); checkRoleVal(); }); })();
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings