Unverified Commit 191e8a27 authored by Vipul Basapati's avatar Vipul Basapati Committed by GitHub

Merge pull request #196 from bvipul/develop

Refactoring Menu Module
parents f38b5d08 a0f1a12f
......@@ -93,7 +93,7 @@ You can now access the server at http://localhost:8000
npm install
npm run development
php artisan key:generate
php artisan jwt:generate
php artisan jwt:secret
php artisan vendor:publish --tag=lfm_public
## Logging In
......
......@@ -199,12 +199,12 @@
"source": {
"type": "git",
"url": "https://github.com/creativeorange/gravatar.git",
"reference": "a0e84f0c8e8922ad151168d6ebd8db6a1b2d8cd2"
"reference": "9affd46be10f1ebb11d5d9f03440f804c09f2b59"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/creativeorange/gravatar/zipball/a0e84f0c8e8922ad151168d6ebd8db6a1b2d8cd2",
"reference": "a0e84f0c8e8922ad151168d6ebd8db6a1b2d8cd2",
"url": "https://api.github.com/repos/creativeorange/gravatar/zipball/9affd46be10f1ebb11d5d9f03440f804c09f2b59",
"reference": "9affd46be10f1ebb11d5d9f03440f804c09f2b59",
"shasum": ""
},
"require": {
......@@ -1414,16 +1414,16 @@
},
{
"name": "laravel/framework",
"version": "v5.6.11",
"version": "v5.6.12",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "195ba6a67bdad2a23105c7ab410cd43e0f20bb73"
"reference": "82d8165d1ea86bdd81ddfa1db9343fa19e7d1450"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/195ba6a67bdad2a23105c7ab410cd43e0f20bb73",
"reference": "195ba6a67bdad2a23105c7ab410cd43e0f20bb73",
"url": "https://api.github.com/repos/laravel/framework/zipball/82d8165d1ea86bdd81ddfa1db9343fa19e7d1450",
"reference": "82d8165d1ea86bdd81ddfa1db9343fa19e7d1450",
"shasum": ""
},
"require": {
......@@ -1432,7 +1432,7 @@
"erusev/parsedown": "~1.7",
"ext-mbstring": "*",
"ext-openssl": "*",
"league/flysystem": "~1.0",
"league/flysystem": "^1.0.8",
"monolog/monolog": "~1.12",
"nesbot/carbon": "^1.24.1",
"php": "^7.1.3",
......@@ -1548,7 +1548,7 @@
"framework",
"laravel"
],
"time": "2018-03-09T16:53:27+00:00"
"time": "2018-03-14T17:29:38+00:00"
},
{
"name": "laravel/socialite",
......@@ -3935,16 +3935,16 @@
"packages-dev": [
{
"name": "barryvdh/laravel-debugbar",
"version": "v3.1.3",
"version": "v3.1.4",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "664fa434e26febf04d60df0368303cf0fe14f63a"
"reference": "7a91480cc6e597caed5117a3c5d685f06d35c5a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/664fa434e26febf04d60df0368303cf0fe14f63a",
"reference": "664fa434e26febf04d60df0368303cf0fe14f63a",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/7a91480cc6e597caed5117a3c5d685f06d35c5a1",
"reference": "7a91480cc6e597caed5117a3c5d685f06d35c5a1",
"shasum": ""
},
"require": {
......@@ -3999,7 +3999,7 @@
"profiler",
"webprofiler"
],
"time": "2018-02-25T13:31:58+00:00"
"time": "2018-03-06T08:35:31+00:00"
},
{
"name": "bvipul/generator",
......@@ -4352,16 +4352,16 @@
},
{
"name": "laravel/browser-kit-testing",
"version": "v4.0.0",
"version": "v4.0.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/browser-kit-testing.git",
"reference": "3ea22c4da537ca8af83746d583360e8e00081a01"
"reference": "d70283fd29ee9ec09d07a9c94cc5518b569cfeaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/3ea22c4da537ca8af83746d583360e8e00081a01",
"reference": "3ea22c4da537ca8af83746d583360e8e00081a01",
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/d70283fd29ee9ec09d07a9c94cc5518b569cfeaf",
"reference": "d70283fd29ee9ec09d07a9c94cc5518b569cfeaf",
"shasum": ""
},
"require": {
......@@ -4396,7 +4396,7 @@
"laravel",
"testing"
],
"time": "2018-02-08T16:44:18+00:00"
"time": "2018-03-13T18:07:36+00:00"
},
{
"name": "maximebf/debugbar",
......
This diff is collapsed.
......@@ -42,6 +42,7 @@
</script>
</head>
<body class="skin-{{ config('backend.theme') }} {{ config('backend.layout') }}">
<div class="loading" style="display:none"></div>
@include('includes.partials.logged-in-as')
<div class="wrapper">
......
......@@ -56,173 +56,7 @@
@section("after-scripts")
{{ Html::script('js/nestable2/jquery.nestable.js') }}
<script type="text/javascript">
var formName = '_add_custom_url_form';
var lastId = null;
$('#menu-items').nestable({
callback: function(l, e){
$(".menu-items-field").val(JSON.stringify($(l).nestable('serialise')));
},
json: $(".menu-items-field").val(),
includeContent:true,
scroll: false,
maxDepth: 10
});
$(".show-modal").click(function(){
$("#showMenuModal").find(".modal-dialog .modal-content .modal-header .modal-title").html($(this).attr("data-header"));
formName = $(this).attr("data-form");
$("#showMenuModal").modal("show");
setTimeout(function() {
$(document).find("#showMenuModal .view-permission-block").remove();
$(document).find("#menu-add-custom-url").removeClass("hidden");
}, 500);
});
$("#showMenuModal").on('show.bs.modal', function () {
$.get("{{ route('admin.menus.getform') }}/" + formName, function(data, status){
if(status == "success") {
$("#showMenuModal").find(".modal-dialog .modal-content .modal-body").html(data);
}
else {
$("#showMenuModal").find(".modal-dialog .modal-content .modal-body").html("Something went wrong! Please try again later.");
}
});
});
var getNewId = function(str) {
var arr = str.match(/"id":[0-9]+/gi);
if(arr) {
$.each(arr, function(index, item) {
arr[index] = parseInt(item.replace('"id":', ''));
});
return Math.max.apply(Math, arr) + 1;
}
return 1;
}
var addMenuItem = function(obj) {
$('#menu-items').nestable('add', {
"id": getNewId($(".menu-items-field").val()),
"content": obj.name,
"name": obj.name,
"url": obj.url,
"url_type" : obj.url_type,
"open_in_new_tab": obj.open_in_new_tab,
"icon": obj.icon,
"view_permission_id": obj.view_permission_id
});
$(".menu-items-field").val(JSON.stringify($('#menu-items').nestable('serialise')));
}
var editMenuItem = function(obj) {
var newObject = {
"id": obj.id,
"content": obj.name,
"name": obj.name,
"url": obj.url,
"url_type": obj.url_type,
"open_in_new_tab": obj.open_in_new_tab,
"icon": obj.icon,
"view_permission_id": obj.view_permission_id
};
var menuItems = $("#menu-items").nestable('serialise');
var itemData;
$.each(menuItems, function(index, item){
itemData = findItemById(item, id);
if(itemData) { return false; }
});
if(itemData.children) {
newObject.children = itemData.children;
}
$('#menu-items').nestable('replace', newObject);
$(".menu-items-field").val(JSON.stringify($('#menu-items').nestable('serialise')));
}
$(document).on("submit", "#menu-add-custom-url", function(e){
e.preventDefault();
var formData = $(this).serializeArray().reduce(function(obj, item) {
obj[item.name] = item.value;
return obj;
}, {});
if(formData.name.length > 0) {
if(formData.id.length > 0) {
editMenuItem(formData);
} else {
addMenuItem(formData);
}
$("#showMenuModal").modal("hide");
}
});
$(document).on("click", ".add-module-to-menu", function(){
var dataObj = {
id: $(this).attr("data-id"),
name: $(this).attr("data-name"),
url: $(this).attr("data-url"),
url_type: $(this).attr("data-url_type"),
open_in_new_tab: $(this).attr("data-open_in_new_tab"),
view_permission_id: $(this).attr("data-view_permission_id"),
}
addMenuItem(dataObj);
});
var findItemById = function(item, id) {
if(item.id == id) {
return item;
}
var found = false;
var foundItem;
if(item.children){
$.each(item.children, function(index, childItem){
foundItem = findItemById(childItem, id);
if(foundItem)
{
console.log(foundItem);
found = true;
return false;
}
});
}
if(found)
{
return foundItem;
}
return null;
};
$(document).ready(function(){
$(document).on("click", ".edit-menu-item", function() {
id = $(this).parents(".dd-item").first().attr("data-id");
$("#showMenuModal").modal("show");
var menuItems = $("#menu-items").nestable('serialise');
var itemData;
$.each(menuItems, function(index, item){
itemData = findItemById(item, id);
//console.log(itemData);
if(itemData) { return false; }
});
if(itemData.id != undefined && itemData.id == id)
{
setTimeout(function() {
$("#showMenuModal").find(".modal-dialog .modal-content .modal-header .modal-title").html("Edit: "+itemData.name);
$(document).find("#showMenuModal .mi-id").val(itemData.id);
$(document).find("#showMenuModal .mi-name").val(itemData.name);
$(document).find("#showMenuModal .mi-url").val(itemData.url);
$(document).find("#showMenuModal .mi-url_type_"+itemData.url_type).prop("checked", true);
if(itemData.open_in_new_tab == 1) {
$(document).find("#showMenuModal .mi-open_in_new_tab").prop("checked", true);
}
$(document).find("#showMenuModal .mi-icon").val(itemData.icon);
if(itemData.view_permission_id) {
$(document).find("#showMenuModal .mi-view_permission_id").val(itemData.view_permission_id);
} else {
$(document).find("#showMenuModal .view-permission-block").remove();
}
$(document).find("#menu-add-custom-url").removeClass("hidden");
}, 500 );
return;
}
});
$(document).on("click", ".remove-menu-item", function() {
$("#menu-items").nestable('remove', $(this).parents(".dd-item").first().attr("data-id"));
$(".menu-items-field").val(JSON.stringify($("#menu-items").nestable('serialise')));
});
});
Backend.Menu.selectors.formUrl = "{{route('admin.menus.getform')}}";
Backend.Menu.init();
</script>
@endsection
......@@ -21,6 +21,7 @@ mix.sass('resources/assets/sass/frontend/app.scss', 'public/css/frontend.css')
'public/js/select2/select2.css',
'public/css/bootstrap.min.css',
'public/css/custom-style.css',
'public/css/loader.css',
'public/css/bootstrap-datetimepicker.min.css'
], 'public/css/backend-custom.css')
.js([
......
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