Commit 26ec1dc7 authored by Viral Solani's avatar Viral Solani

Merge branch 'indranshastri-master'

parents ce0593f9 c0df05f9
......@@ -23,7 +23,13 @@ npm-debug.log
yarn-error.log
phpunit.txt
public/css
public/js
public/js/*.js
public/js/plugins
public/js/skins
public/js/themes
public/js/skins/*.js
composer.lock
public/img/backend/blog_images/*
public/mix-manifest.json
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
$(function() {
$(".show-permissions").click(function(e) {
e.preventDefault();
var $this = $(this);
var role = $this.data('role');
var permissions = $(".permission-list[data-role='"+role+"']");
var hideText = $this.find('.hide-text');
var showText = $this.find('.show-text');
// console.log(permissions); // for debugging
// show permission list
permissions.toggleClass('hidden');
// toggle the text Show/Hide for the link
hideText.toggleClass('hidden');
showText.toggleClass('hidden');
window.onload = function () {
document.querySelectorAll(".show-permissions").forEach(function(element){
element.onclick = function(event){
event.preventDefault();
var $this = this;
var role = $this.getAttribute("data-role");
var permissions = document.querySelector(".permission-list[data-role='"+role+"']");
var hideText = $this.querySelector('.hide-text');
var showText = $this.querySelector('.show-text');
// show permission list
Backend.Utils.toggleClass(permissions,'hidden');
// toggle the text Show/Hide for the link
Backend.Utils.toggleClass(hideText,'hidden');
Backend.Utils.toggleClass(showText,'hidden');
};
});
});
};
This diff is collapsed.
var Backend = {
/**
* Pages
*
*/
Pages:
{
init: function()
{
Backend.tinyMCE.init();
},
},
/**
* Access management
*
*/
Access:
{
selectors: {
select2: jQuery(".select2"),
},
init: function ()
{
this.addHandlers();
},
addHandlers: function ()
{
this.selectors.select2.select2();
}
},
/**
* Blog
*
*/
Blog:
{
selectors: {
tags: jQuery(".tags"),
categories : jQuery(".categories"),
toDisplay :jQuery(".toDisplay"),
status : jQuery(".status"),
},
init: function ()
{
this.addHandlers();
Backend.tinyMCE.init();
},
addHandlers: function ()
{
this.selectors.tags.select2({
tags: true,
});
this.selectors.categories.select2();
this.selectors.toDisplay.select2();
this.selectors.status.select2();
}
},
/**
* Tiny MCE
*/
tinyMCE: {
init: function () {
tinymce.init({
path_absolute : "/",
selector: 'textarea',
height: 200,
width: 725,
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc'
],
toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
// toolbar2: 'print preview media | forecolor backcolor emoticons | codesample',
image_advtab: true,
relative_urls : false,
file_browser_callback : function(field_name, url, type, win) {
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;
var cmsURL = "/" + 'laravel-filemanager?field_name=' + field_name;
if (type == 'image') {
cmsURL = cmsURL + "&type=Images";
} else {
cmsURL = cmsURL + "&type=Files";
}
tinyMCE.activeEditor.windowManager.open({
file : cmsURL,
title : 'Filemanager',
width : x * 0.8,
height : y * 0.8,
resizable : "yes",
close_previous : "no"
});
},
content_css: [
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
'//www.tinymce.com/css/codepen.min.css'
]
});
}
},
emailTemplate: {
selectors: {
emailtemplateSelection: jQuery(".select2")
},
init: function () {
Backend.emailTemplate.addHandlers();
Backend.tinyMCE.init();
},
// ! Backend.emailTemplate.addHandlers
addHandlers: function () {
// to add placeholder in to active textarea
$("#addPlaceHolder").on('click', function (event) {
Backend.emailTemplate.addPlaceHolder(event);
});
$("#showPreview").on('click', function (event) {
Backend.emailTemplate.showPreview(event);
});
this.selectors.emailtemplateSelection.select2();
},
// ! Backend.emailTemplate.addPlaceHolder
addPlaceHolder: function (event) {
var placeHolder = $('#placeHolder').val();
if (placeHolder != '') {
tinymce.activeEditor.execCommand('mceInsertContent', false, "[" + $('#placeHolder :selected').text() + "]");
}
},
// ! Backend.emailTemplate.showPreview
showPreview: function (event) {
jQuery( ".modal-body" ).html(tinyMCE.get('txtBody').getContent());
$(".model-wrapper").modal('show');
},
},
/**
* Faq
*
*/
Faq:
{
selectors:
{
},
init: function ()
{
// this.addHandlers();
Backend.tinyMCE.init();
},
addHandlers: function ()
{
}
},
/**
* Profile
*
*/
Profile:
{
selectors: {
state: jQuery(".st"),
cities : jQuery(".ct"),
},
init: function ()
{
this.addHandlers();
},
addHandlers: function ()
{
this.selectors.state.select2();
this.selectors.cities.select2();
}
},
DataTableSearch: {
//selector for datatable filters inputs
Selectors:{
searchInputFiled:document.querySelector("div.dataTables_filter input"),
},
//function used for initialize the search inputs given on the datatable
init: function (dataTable) {
// Header All search columns
$("div.dataTables_filter input").unbind();
$("div.dataTables_filter input").keypress( function (e)
{
if (e.keyCode == 13)
{
dataTable.fnFilter( this.value );
}
});
// Individual columns search
$('.search-input-text').on( 'keypress', function (e) {
// for text boxes
if (e.keyCode == 13)
{
var i =$(this).attr('data-column'); // getting column index
var v =$(this).val(); // getting search input value
dataTable.api().columns(i).search(v).draw();
}
});
// Individual columns search
$('.search-input-select').on( 'change', function (e) {
// for dropdown
var i =$(this).attr('data-column'); // getting column index
var v =$(this).val(); // getting search input value
dataTable.api().columns(i).search(v).draw();
});
// Individual columns reset
$('.reset-data').on( 'click', function (e) {
var textbox = $(this).prev('input'); // Getting closest input field
var i =textbox.attr('data-column'); // Getting column index
$(this).prev('input').val(''); // Blank the serch value
dataTable.api().columns(i).search("").draw();
});
//Copy button
$('#copyButton').click(function(){
$('.copyButton').trigger('click');
});
//Download csv
$('#csvButton').click(function(){
$('.csvButton').trigger('click');
});
//Download excelButton
$('#excelButton').click(function(){
$('.excelButton').trigger('click');
});
//Download pdf
$('#pdfButton').click(function(){
$('.pdfButton').trigger('click');
});
//Download printButton
$('#printButton').click(function(){
$('.printButton').trigger('click');
});
var id = $('.table-responsive .dataTables_filter').attr('id');
$('#'+id+' label').append('<a class="reset-data" id="input-sm-reset" href="javascript:void(0)"><i class="fa fa-times"></i></a>');
$(document).on('click', "#"+id+" label #input-sm-reset", function(){
dataTable.fnFilter('');
});
},
}
}
\ No newline at end of file
//common functionalities for all the javascript featueres
var Backend = {}; // common variable used in all the files of the backend
(function()
{
Backend = {
DataTableSearch: { //functionalities related to datable search at all the places
selector:{
},
init: function (dataTable) {
this.setSelectors();
// get the datatable search input and on its key press check if we hit enter then search with datatable
this.cloneElement(this.selector.searchInput,function(element){
element.onkeypress = function(event){
if(event.keyCode==13){
dataTable.fnFilter( this.value );
}
};
}); // to remove all the listinerers
// for text boxes
//column input search if search box on the column of the datatable given with enter then search with datatable
if(this.selector.columnSearchInput.length>0){
this.selector.columnSearchInput.forEach(function(element){
element.onkeypress = function(event){
if (event.keyCode == 13){
var i =element.getAttribute("data-column") // getting column index
var v =element.value; // getting search input value
dataTable.api().columns(i).search(v).draw();
}
};
});
}
// Individual columns search
if(this.selector.columnSelectInput.length>>0){
this.selector.columnSelectInput.forEach(function(element){
element.onchange = function(event){
var i =element.getAttribute("data-column"); // getting column index
var v =element.value; // getting search input value
dataTable.api().columns(i).search(v).draw();
};
});
}
// Individual columns reset
if(this.selector.restButton.length>>0){
this.selector.restButton.forEach(function(element){
element.onclick = function(event){
var inputelement = this.previousElementSibling;
var i = inputelement.getAttribute("data-column");
inputelement.value = "";
dataTable.api().columns(i).search("").draw();
};
});
}
this.setSelectors.copyButton.onclick = function(element){
document.querySelector(".copyButton").click();
};
this.setSelectors.csvButton.onclick = function(element){
document.querySelector(".csvButton").click();
};
this.setSelectors.excelButton.onclick = function(element){
document.querySelector(".excelButton").click();
};
this.setSelectors.pdfButton.onclick = function(element){
document.querySelector(".pdfButton").click();
};
this.setSelectors.printButton.onclick = function(element){
document.querySelector(".printButton").click();
};
},
setSelectors:function(){
this.selector.searchInput = document.querySelector("div.dataTables_filter input");
this.selector.columnSearchInput = document.querySelectorAll(".search-input-text");
this.selector.columnSelectInput = document.querySelectorAll('search-input-select');
this.selector.restButton = document.querySelectorAll('.reset-data');
this.setSelectors.copyButton = document.getElementById("copyButton");
this.setSelectors.csvButton = document.getElementById("csvButton");
this.setSelectors.excelButton = document.getElementById("excelButton");
this.setSelectors.pdfButton = document.getElementById("pdfButton");
this.setSelectors.printButton = document.getElementById("printButton");
},
cloneElement:function(element,callback){
var clone = element.cloneNode();
while (element.firstChild) {
clone.appendChild(element.lastChild);
}
element.parentNode.replaceChild(clone, element);
Backend.DataTableSearch.setSelectors();
callback(this.selector.searchInput);
}
}
};
})();
......@@ -181,46 +181,13 @@
@section('after-scripts')
{{ Html::script('js/backend/access/users/script.js') }}
<script type="text/javascript">
$(document).ready(function() {
Backend.Access.init();
/**
* This function is used to get clicked element role id and return required result
*/
$('.get-role-for-permissions').click(function () {
$.ajax({
type: "POST",
url: "{{ route('admin.get.permission') }}",
dataType: "JSON",
data: {role_id: $(this).val()},
success: function (response) {
var p = response.permissions;
var q = response.rolePermissions;
var qAll = response.allPermissions;
$('.get-available-permissions').html('');
if (p.length == 0) {
('.get-available-permissions').html('<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"';
}
}
$('<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>').appendTo('.get-available-permissions');
}
}
$('#available-permissions').removeClass('hidden');
}
});
});
$("#role-3").click();
Backend.Utils.documentReady(function(){
csrf = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
Backend.Access.selectors.getPremissionURL = "{{ route('admin.get.permission') }}";
Backend.Access.init("create");
});
</script>
@endsection
......@@ -68,7 +68,13 @@
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
......@@ -102,6 +108,7 @@
});
Backend.DataTableSearch.init(dataTable);
});
})();
</script>
@endsection
......@@ -68,80 +68,60 @@
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.access.user.get") }}',
type: 'post',
data: {status: false, trashed: true}
},
columns: [
{data: 'first_name', name: '{{config('access.users_table')}}.first_name'},
{data: 'last_name', name: '{{config('access.users_table')}}.last_name'},
{data: 'email', name: '{{config('access.users_table')}}.email'},
{data: 'confirmed', name: '{{config('access.users_table')}}.confirmed'},
{data: 'roles', name: '{{config('access.roles_table')}}.name', sortable: false},
{data: 'created_at', name: '{{config('access.users_table')}}.created_at'},
{data: 'updated_at', name: '{{config('access.users_table')}}.updated_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[0, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }}
]
}
});
Backend.DataTableSearch.init(dataTable);
$("body").on("click", "a[name='delete_user_perm']", function(e) {
e.preventDefault();
var linkURL = $(this).attr("href");
swal({
title: "{{ trans('strings.backend.general.are_you_sure') }}",
text: "{{ trans('strings.backend.access.users.delete_user_confirm') }}",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "{{ trans('strings.backend.general.continue') }}",
cancelButtonText: "{{ trans('buttons.general.cancel') }}",
closeOnConfirm: false
}, function(isConfirmed){
if (isConfirmed){
window.location.href = linkURL;
(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
});
$("body").on("click", "a[name='restore_user']", function(e) {
e.preventDefault();
var linkURL = $(this).attr("href");
swal({
title: "{{ trans('strings.backend.general.are_you_sure') }}",
text: "{{ trans('strings.backend.access.users.restore_user_confirm') }}",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "{{ trans('strings.backend.general.continue') }}",
cancelButtonText: "{{ trans('buttons.general.cancel') }}",
closeOnConfirm: false
}, function(isConfirmed){
if (isConfirmed){
window.location.href = linkURL;
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.access.user.get") }}',
type: 'post',
data: {status: false, trashed: true}
},
columns: [
{data: 'first_name', name: '{{config('access.users_table')}}.first_name'},
{data: 'last_name', name: '{{config('access.users_table')}}.last_name'},
{data: 'email', name: '{{config('access.users_table')}}.email'},
{data: 'confirmed', name: '{{config('access.users_table')}}.confirmed'},
{data: 'roles', name: '{{config('access.roles_table')}}.name', sortable: false},
{data: 'created_at', name: '{{config('access.users_table')}}.created_at'},
{data: 'updated_at', name: '{{config('access.users_table')}}.updated_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[0, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }}
]
}
});
});
});
Backend.DataTableSearch.init(dataTable);
Backend.Access.selectors.Areyousure = "{{ trans('strings.backend.general.are_you_sure') }}";
Backend.Access.selectors.delete_user_confirm = "{{ trans('strings.backend.access.users.delete_user_confirm') }}";
Backend.Access.selectors.continue = "{{ trans('strings.backend.general.continue') }}";
Backend.Access.selectors.cancel ="{{ trans('buttons.general.cancel') }}";
Backend.Access.selectors.restore_user_confirm ="{{ trans('strings.backend.access.users.restore_user_confirm') }}";
})();
window.onload = function(){
Backend.Access.windowloadhandler();
}
</script>
@endsection
......@@ -167,12 +167,15 @@
{{ Html::script('js/backend/access/users/script.js') }}
<script type="text/javascript">
/*
jQuery(document).ready(function() {
Backend.Access.init();
/**
* 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({
type: "POST",
url: "{{ route('admin.get.permission') }}",
......@@ -205,5 +208,70 @@
});
});
*/
Backend.Utils.documentReady(function(){
csrf = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
Backend.Access.selectors.getPremissionURL = "{{ route('admin.get.permission') }}";
Backend.Access.init("edit");
/*
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>
@endsection
......@@ -81,7 +81,14 @@
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
(function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
......@@ -116,6 +123,6 @@
});
Backend.DataTableSearch.init(dataTable);
});
})();
</script>
@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