Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
97c1c00f
Commit
97c1c00f
authored
Feb 26, 2018
by
cygnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes for making the add form with pure javscript
parent
1de35d41
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
24 deletions
+78
-24
admin.js
public/js/backend/admin.js
+21
-2
create.blade.php
resources/views/backend/access/users/create.blade.php
+57
-22
No files found.
public/js/backend/admin.js
View file @
97c1c00f
...
...
@@ -39,15 +39,27 @@ var Backend = {}; // common variable used in all the files of the backend
request
=
new
ActiveXObject
(
"
Microsoft.XMLHTTP
"
);
}
request
.
open
(
method
,
url
,
true
);
request
.
setRequestHeader
(
'
X-CSRF-TOKEN
'
,
'
application/x-www-form-urlencoded; charset=UTF-8
'
);
request
.
setRequestHeader
(
'
X-CSRF-TOKEN
'
,
csrf
);
request
.
setRequestHeader
(
'
X-Requested-With
'
,
'
XMLHttpRequest
'
);
if
(
"
post
"
===
method
.
toLowerCase
()){
request
.
setRequestHeader
(
'
Content-Type
'
,
'
application/x-www-form-urlencoded; charset=UTF-8
'
);
data
=
this
.
jsontoformdata
(
data
);
}
// when request is in the ready state change the details or perform success function
request
.
onreadystatechange
=
function
()
{
if
(
request
.
readyState
===
XMLHttpRequest
.
DONE
)
{
// Everything is good, the response was received.
request
.
onload
=
callback
.
success
(
request
);
}
};
request
.
onerror
=
callback
.
error
;
request
.
send
(
data
);
},
...
...
@@ -68,6 +80,13 @@ var Backend = {}; // common variable used in all the files of the backend
return
urljson
;
},
removeClass
:
function
(
el
,
className
){
if
(
el
.
classList
)
el
.
classList
.
remove
(
className
);
else
el
.
className
=
el
.
className
.
replace
(
new
RegExp
(
'
(^|
\\
b)
'
+
className
.
split
(
'
'
).
join
(
'
|
'
)
+
'
(
\\
b|$)
'
,
'
gi
'
),
'
'
);
}
},
/**
...
...
resources/views/backend/access/users/create.blade.php
View file @
97c1c00f
...
...
@@ -182,31 +182,66 @@
{{ Html::script('js/backend/access/users/script.js') }}
<script type="
text
/
javascript
">
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 resp = request.responseText;
console.log(resp);
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
");
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>';
}
};
csrf = $('meta[name="
csrf
-
token
"]').attr('content');
Backend.Utils.ajaxrequest("
{{
route
(
'admin.get.permission'
)
}}
","
post
",{role_id: $('.get-role-for-permissions').val()},csrf,callback);
Backend.Utils.ajaxrequest("
{{
route
(
'admin.get.permission'
)
}}
","
post
",{role_id: event.target.value ,"
_tocken
":csrf},csrf,callback);
}
});
document.getElementById("
role
-
3
").click();
});
</script>
@endsection
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment