Commit 0241a481 authored by cygnet's avatar cygnet

changes done for deleted user and edit user page to convert them in javascript

parent 97c1c00f
...@@ -279,20 +279,29 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -279,20 +279,29 @@ var Backend = {}; // common variable used in all the files of the backend
*/ */
Profile: Profile:
{ {
selectors:{
},
init: function () init: function ()
{ {
this.setSelectors(); this.setSelectors();
this.addHandlers(); this.addHandlers();
}, },
setSelectors:function(){ setSelectors:function(){
this.selectors.state = document.querySelector(".st"); this.selectors.state = document.querySelector(".st");
this.selectors.cities = document.querySelector(".ct"); this.selectors.cities = document.querySelector(".ct");
}, },
addHandlers: function () addHandlers: function ()
{ {
if(this.selectors.state!=null){
this.selectors.state.select2(); this.selectors.state.select2();
}
if(this.selectors.cities!=null){
this.selectors.cities.select2(); this.selectors.cities.select2();
} }
}
}, },
/** /**
......
...@@ -68,7 +68,13 @@ ...@@ -68,7 +68,13 @@
{{-- For DataTables --}} {{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }} {{ Html::script(mix('js/dataTable.js')) }}
<script> <script>
$(function() {
(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({ var dataTable = $('#users-table').dataTable({
processing: true, processing: true,
serverSide: true, serverSide: true,
...@@ -103,10 +109,16 @@ ...@@ -103,10 +109,16 @@
Backend.DataTableSearch.init(dataTable); Backend.DataTableSearch.init(dataTable);
$("body").on("click", "a[name='delete_user_perm']", function(e) {
e.preventDefault();
var linkURL = $(this).attr("href");
})();
window.onload = function(){
document.querySelectorAll("a[name='delete_user_perm']").forEach(function(element){
element.onclick = function(event){
event.preventDefault();
var linkURL = event.target.getAttribute("href");
swal({ swal({
title: "{{ trans('strings.backend.general.are_you_sure') }}", title: "{{ trans('strings.backend.general.are_you_sure') }}",
text: "{{ trans('strings.backend.access.users.delete_user_confirm') }}", text: "{{ trans('strings.backend.access.users.delete_user_confirm') }}",
...@@ -121,11 +133,13 @@ ...@@ -121,11 +133,13 @@
window.location.href = linkURL; window.location.href = linkURL;
} }
}); });
}); }
})
$("body").on("click", "a[name='restore_user']", function(e) { document.querySelectorAll("a[name='restore_user']").forEach(function(element){
e.preventDefault(); element.onclick = function(event){
var linkURL = $(this).attr("href"); event.preventDefault();
var linkURL = event.target.getAttribute("href");
swal({ swal({
title: "{{ trans('strings.backend.general.are_you_sure') }}", title: "{{ trans('strings.backend.general.are_you_sure') }}",
...@@ -141,7 +155,9 @@ ...@@ -141,7 +155,9 @@
window.location.href = linkURL; window.location.href = linkURL;
} }
}); });
}); }
}); })
};
</script> </script>
@endsection @endsection
...@@ -167,12 +167,15 @@ ...@@ -167,12 +167,15 @@
{{ Html::script('js/backend/access/users/script.js') }} {{ Html::script('js/backend/access/users/script.js') }}
<script type="text/javascript"> <script type="text/javascript">
/*
jQuery(document).ready(function() { jQuery(document).ready(function() {
Backend.Access.init(); Backend.Access.init();
/** /**
* This function is used to get clicked element role id and return required result * This function is used to get clicked element role id and return required result
*/ */
jQuery('.get-role-for-permissions').click(function () { /* jQuery('.get-role-for-permissions').click(function () {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "{{ route('admin.get.permission') }}", url: "{{ route('admin.get.permission') }}",
...@@ -205,5 +208,67 @@ ...@@ -205,5 +208,67 @@
}); });
}); });
*/
Backend.Utils.documentReady(function(){
Backend.Access.init();
csrf = $('meta[name="csrf-token"]').attr('content');
/**
* This function is used to get clicked element role id and return required result
*/
document.querySelectorAll(".get-role-for-permissions").forEach(function(element){
element.onclick =function(event){
callback = {
success:function(request){
console.log("request",request,request.status);
if (request.status >= 200 && request.status < 400) {
// Success!
var response = JSON.parse(request.responseText);
var p = response.permissions;
var q = response.rolePermissions;
var qAll = response.allPermissions;
document.querySelector(".get-available-permissions").innerHTML = "";
htmlstring = "";
if (p.length == 0) {
document.querySelector(".get-available-permissions").innerHTML = '<p>There are no available permissions.</p>';
} else {
for (var key in p) {
var addChecked = '';
if (qAll == 1 && q.length == 0) {
addChecked = 'checked="checked"';
} else {
if (typeof q[key] !== "undefined") {
addChecked = 'checked="checked"';
}
}
htmlstring += '<label class="control control--checkbox"> <input type="checkbox" name="permissions[' + key + ']" value="' + key + '" id="perm_' + key + '" ' + addChecked + ' /> <label for="perm_' + key + '">' + p[key] + '</label> <div class="control__indicator"></div> </label> <br>';
}
}
document.querySelector(".get-available-permissions").innerHTML = htmlstring;
Backend.Utils.removeClass(document.getElementById("available-permissions"),'hidden');
} else {
// We reached our target server, but it returned an error
console.log("errror in request");
document.querySelector(".get-available-permissions").innerHTML = '<p>There are no available permissions.</p>';
}
},
error:function(){
console.log("errror");
document.querySelector(".get-available-permissions").innerHTML = '<p>There are no available permissions.</p>';
}
};
Backend.Utils.ajaxrequest("{{ route('admin.get.permission') }}","post",{role_id: event.target.value ,"_tocken":csrf},csrf,callback);
}
});
});
</script> </script>
@endsection @endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment