Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit b54640c

Browse files
committed
- small fix and new option
- add another option `clearNestDescendants` - small fix
1 parent cfffc1a commit b54640c

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ return [
8989
*
9090
* do you want to clear its parent and make it a root ?
9191
*/
92-
'clearPartialyNestedParent'=> false,
92+
'clearPartialyNestedParent'=> true,
9393

9494
/*
9595
* when removing a root page from a menu, ex.
@@ -103,6 +103,11 @@ return [
103103
*/
104104
'clearRootDescendants' => false,
105105

106+
/**
107+
* when removing a nest from a list, do you want to reset its hierarchy ?
108+
*/
109+
'clearNestDescendants' => false,
110+
106111
/*
107112
* when deleteing a page "from the db", do you also want to delete all of its childrens ?
108113
*/

src/Controllers/Admin/Traits/MenuOps.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ public function removePage($id, Request $request)
6060
*/
6161
public function removeChild(Request $request)
6262
{
63-
$this->clearSelfAndNests($request->child_id);
63+
if (config('simpleMenu.clearNestDescendants')) {
64+
$this->clearSelfAndNests($request->child_id);
65+
} else {
66+
$page = $this->findPage($request->child_id);
67+
$page->makeRoot();
68+
$page->touch();
69+
}
6470

6571
return response()->json(['done'=>true]);
6672
}

src/Traits/NavigationTrait.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ public function getUrl($code)
2121
{
2222
$name = Route::currentRouteName();
2323

24+
// redir to '/' if the first item in "bc" is in diff locale
25+
$bc = $this->getRouteData($name)['breadCrumb'];
26+
if (isset($bc) && count($bc) && !$this->searchForRoute($bc->pluck('route_name')->first(), $code)) {
27+
return LaravelLocalization::getLocalizedURL($code, url('/'), [], true);
28+
}
29+
2430
// routeName is not saved in the db (ex.php artisan make:auth)
2531
// or only url
2632
$routesListFile = include $this->listFileDir;
27-
2833
if (is_null($name) || !array_get($routesListFile, $name)) {
2934
return LaravelLocalization::getLocalizedURL($code, null, [], true);
3035
}
@@ -110,7 +115,7 @@ public function getBC()
110115
$name = Route::currentRouteName();
111116
$bc = $this->getRouteData($name)['breadCrumb'];
112117

113-
if (isset($bc) && count($bc) && $this->searchForRoute($bc->pluck('route_name')->first(), $this->getCrntLocale())) {
118+
if (isset($bc) && count($bc)) {
114119
return $bc;
115120
}
116121
}

src/config/simpleMenu.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,19 @@
3939
'userModel' => App\User::class,
4040

4141
/*
42-
* when adding a page which is a nest of a nother to a menu
42+
* when adding a page which is a nest of another to a menu
4343
*
4444
* root
4545
* | child 1
46-
* | child 2 "add this along with its childrens to another menu"
46+
* | child 2 "add this along with its children to another menu"
4747
* | child 3
4848
*
4949
* do you want to clear its parent and make it a root ?
50+
*
51+
* note that this will cause issues for breadcumb as to "what to show" and "what to hide"
52+
* if set to "false"
5053
*/
51-
'clearPartialyNestedParent'=> false,
54+
'clearPartialyNestedParent'=> true,
5255

5356
/*
5457
* when removing a root page from a menu, ex.
@@ -63,7 +66,12 @@
6366
'clearRootDescendants' => false,
6467

6568
/*
66-
* when deleteing a page "from the db", do you also want to delete all of its childrens ?
69+
* when removing a nest from a list, do you want to reset its hierarchy ?
70+
*/
71+
'clearNestDescendants'=> false,
72+
73+
/*
74+
* when deleting a page "from the db", do you also want to delete all of its children ?
6775
*/
6876
'deletePageAndNests' => false,
6977

src/resources/views/breadCrumb.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<nav class="breadcrumb">
33
<ul>
44
@foreach ($breadCrumb as $page)
5-
@break(!$page->title)
65
@include('SimpleMenu::menu.partials.r_params')
76

87
<li class="{{ SimpleMenu::isActiveRoute() ? 'is-active' : '' }}">

0 commit comments

Comments
 (0)