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

Commit 0c7e2bf

Browse files
committed
minor
1 parent 0f63c1d commit 0c7e2bf

22 files changed

+187
-148
lines changed

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SimpleMenu
22

3-
[![Latest Stable Version](https://img.shields.io/packagist/v/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu) [![Total Downloads](https://img.shields.io/packagist/dt/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu) [![Donate with Bitcoin](https://en.cryptobadges.io/badge/micro/16ri7Hh848bw7vxbEevKHFuHXLmsV8Vc9L)](https://en.cryptobadges.io/donate/16ri7Hh848bw7vxbEevKHFuHXLmsV8Vc9L)
3+
[![Latest Stable Version](https://img.shields.io/packagist/v/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu) [![Total Downloads](https://img.shields.io/packagist/dt/ctf0/simple-menu.svg)](https://packagist.org/packages/ctf0/simple-menu)
44

55
Create menus & pages that support (multiLocale "title, url, body, ...", nesting, template, static & dynamic data, roles & permissions).
66

@@ -151,6 +151,10 @@ return [
151151
<br>
152152
153153
## Usage
154+
> [Demo](https://github.com/ctf0/demos/tree/simple-menu)<br>
155+
> [Usage](https://github.com/ctf0/simple-menu/wiki/Usage)<br>
156+
> [Views](https://github.com/ctf0/SimpleMenu/wiki/Crud-Views)
157+
154158
- add `SMUsers` trait to your **User Model**
155159
156160
```php
@@ -165,9 +169,3 @@ return [
165169
```
166170
167171
- visit `localhost:8000/admin`
168-
- [Wiki](https://github.com/ctf0/simple-menu/wiki/Usage)
169-
170-
<br>
171-
172-
## Crud Views
173-
[Wiki](https://github.com/ctf0/SimpleMenu/wiki/Crud-Views)

composer.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
"spatie/laravel-permission": "^2.0",
2727
"spatie/laravel-translatable": "^2.0",
2828
"codezero/laravel-unique-translation": "^1.1",
29-
"ctf0/package-changelog": "^1.0"
30-
},
31-
"suggest": {
32-
"laravelcollective/html": "HTML and Form Builders for the Laravel Framework"
29+
"ctf0/package-changelog": "^1.0",
30+
"laravelcollective/html": "*"
3331
},
3432
"autoload": {
3533
"psr-4": {
@@ -55,4 +53,4 @@
5553
"@php artisan vendor:publish"
5654
]
5755
}
58-
}
56+
}

src/Controllers/Admin/Traits/Paginate.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@
77
use Illuminate\Pagination\LengthAwarePaginator;
88

99
/**
10-
* https://gist.github.com/PaulaAguirre/5473cde2a4b066d262bf96cdb231e91a.
10+
* https://gist.github.com/vluzrmos/3ce756322702331fdf2bf414fea27bcb.
1111
*/
1212
trait Paginate
1313
{
14-
public function paginate($items, $perPage = 15, $page = null, $options = [])
14+
public function paginate($items, $perPage = 15, $page = null)
1515
{
16-
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
17-
$items = $items instanceof Collection ? $items : Collection::make($items);
16+
$pageName = 'page';
17+
$page = $page ?: (Paginator::resolveCurrentPage($pageName) ?: 1);
18+
$items = $items instanceof Collection ? $items : Collection::make($items);
1819

1920
return new LengthAwarePaginator(
20-
$items->forPage($page, $perPage),
21+
$items->forPage($page, $perPage)->values(),
2122
$items->count(),
2223
$perPage,
2324
$page,
24-
$options ?? [
25+
[
2526
'path' => Paginator::resolveCurrentPath(),
26-
'pageName' => 'page',
27+
'pageName' => $pageName,
2728
]
2829
);
2930
}

src/SimpleMenu.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ public function __construct()
2222
$this->listFileDir = config('simpleMenu.routeListPath');
2323
$this->localeCodes = array_keys(LaravelLocalization::getSupportedLocales());
2424

25-
if ($this->listFileDir !== '') {
25+
if ($this->listFileDir) {
2626
static::create_LFD($this->listFileDir);
2727

28-
// create caches
29-
$this->createCaches();
28+
if (!app()->runningInConsole()) {
29+
// create caches
30+
$this->createCaches();
3031

31-
// create routes
32-
$this->createRoutes();
32+
// create routes
33+
$this->createRoutes();
3334

34-
// create menu
35-
$this->createMenus();
35+
// create menu
36+
$this->createMenus();
37+
}
3638
}
3739
}
3840
}

src/SimpleMenuServiceProvider.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ protected function packagePublish()
6565
// views
6666
$this->loadViewsFrom(__DIR__ . '/resources/views', 'SimpleMenu');
6767
$this->publishes([
68-
__DIR__ . '/resources/views' => resource_path('views/vendor/SimpleMenu'),
68+
__DIR__ . '/resources/views' => resource_path('views/vendor/SimpleMenu'),
69+
__DIR__ . '/resources/pagination' => resource_path('views/vendor/pagination'),
6970
], 'views');
7071
}
7172

@@ -140,7 +141,7 @@ protected function autoReg()
140141
$search = 'SimpleMenu';
141142

142143
if ($this->checkExist($mix_file, $search)) {
143-
$data = "\n// SimpleMenu\nmix.sass('resources/assets/vendor/SimpleMenu/sass/style.scss', 'public/assets/vendor/SimpleMenu/style.css').version();";
144+
$data = "\n// SimpleMenu\nmix.sass('resources/assets/vendor/SimpleMenu/sass/style.scss', 'public/assets/vendor/SimpleMenu/style.css')";
144145

145146
$this->file->append($mix_file, $data);
146147
}

src/Traits/MenusTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function createMenus()
2626
public function viewComp($name)
2727
{
2828
$viewFile = view()->exists("SimpleMenu::menu.{$name}")
29-
? "SimpleMenu::menu.{$name}"
30-
: 'SimpleMenu::menu.example';
29+
? "SimpleMenu::menu.{$name}"
30+
: 'SimpleMenu::menu.example';
3131

3232
return view()->composer($viewFile, function ($view) use ($name) {
3333
$view->with([

src/resources/assets/js/manager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Vue.use(require('vue-tippy'), {
1818
}
1919
}
2020
})
21+
require('vue-multi-ref')
2122

2223
// icons
23-
require('vue-multi-ref')
2424
import 'vue-awesome/icons/search'
2525
import 'vue-awesome/icons/times'
2626
import 'vue-awesome/icons/pencil'
@@ -44,4 +44,4 @@ axios.interceptors.response.use(
4444
Vue.component('SmPage', require('./page.vue'))
4545
Vue.component('SmMenu', require('./menu.vue'))
4646
Vue.component('SmIndex', require('./index.vue'))
47-
Vue.component('MyNotification', require('vue-notif'))
47+
Vue.component('MyNotification', require('vue-notif'))

src/resources/assets/js/menu.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<style scoped lang="scss">
22
.menu-list {
3+
height: 100%;
4+
35
a:hover {
46
color: unset !important;
57
background-color: unset !important;
@@ -31,6 +33,11 @@ export default {
3133
created() {
3234
this.getPages()
3335
},
36+
mounted() {
37+
EventHub.listen('updatePagesHierarchy', () => {
38+
this.updatePages(this.pages)
39+
})
40+
},
3441
computed: {
3542
finalList() {
3643
return JSON.stringify(this.saveList)
@@ -161,10 +168,6 @@ export default {
161168
watch: {
162169
pages(val) {
163170
this.updatePages(val)
164-
165-
EventHub.listen('updatePagesHierarchy', () => {
166-
this.updatePages(val)
167-
})
168171
}
169172
},
170173
render() {}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@if ($paginator->hasPages())
2+
<nav class="pagination is-centered">
3+
<ul class="pagination-list">
4+
<li>
5+
@if ($paginator->onFirstPage())
6+
<a class="pagination-previous" disabled>Previous</a>
7+
@else
8+
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="pagination-previous">Previous</a>
9+
@endif
10+
</li>
11+
12+
{{-- Pagination Elements --}}
13+
@foreach ($elements as $element)
14+
{{-- "Three Dots" Separator --}}
15+
@if (is_string($element))
16+
<li><span class="pagination-ellipsis"><span>{{ $element }}</span></span></li>
17+
@endif
18+
19+
{{-- Array Of Links --}}
20+
@if (is_array($element))
21+
@foreach ($element as $page => $url)
22+
@if ($page == $paginator->currentPage())
23+
<li><a class="pagination-link is-current">{{ $page }}</a></li>
24+
@else
25+
<li><a href="{{ $url }}" class="pagination-link">{{ $page }}</a></li>
26+
@endif
27+
@endforeach
28+
@endif
29+
@endforeach
30+
<li>
31+
@if ($paginator->hasMorePages())
32+
<a class="pagination-next" href="{{ $paginator->nextPageUrl() }}" rel="next">Next</a>
33+
@else
34+
<a class="pagination-next" disabled>Next page</a>
35+
@endif
36+
</li>
37+
</ul>
38+
</nav>
39+
@endif

src/resources/views/admin/menus/edit.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class="button is-success">
2828
</div>
2929
</h3>
3030

31-
<sm-menu inline-template
31+
<sm-menu inline-template v-cloak
3232
get-menu-pages="{{ route($crud_prefix.'.menus.getMenuPages', ['id' => $menu->id]) }}"
3333
del-page="{{ route($crud_prefix.'.menus.removePage', ['id' => $menu->id]) }}"
3434
del-child="{{ route($crud_prefix.'.menus.removeChild') }}"

src/resources/views/admin/menus/index.blade.php

+22-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@section('title', trans('SimpleMenu::messages.menus'))
33

44
@section('sub')
5-
<sm-index inline-template :count="{{ count($menus) }}">
5+
<sm-index inline-template v-cloak :count="{{ count($menus) }}">
66
<div>
77
<div class="level">
88
<div class="level-left"></div>
@@ -31,29 +31,30 @@ class="button is-success">
3131

3232
<div class="level">
3333
<div class="level-left">
34-
<h3 class="title">{{ trans('SimpleMenu::messages.menus') }} "<span>@{{ itemsCount }}</span>"</h3>
34+
<h3 class="title">
35+
{{ trans('SimpleMenu::messages.menus') }} "<span>@{{ itemsCount }}</span>"
36+
</h3>
3537
</div>
36-
<div class="level-right">
38+
3739
{{-- search --}}
3840
<div class="level-right">
39-
<div class="field has-addons">
40-
<p class="control has-icons-left">
41-
<input class="input"
42-
type="text"
43-
v-model="searchFor"
44-
placeholder="{{ trans('SimpleMenu::messages.find') }}">
45-
<span class="icon is-left">
46-
<icon name="search"></icon>
47-
</span>
48-
</p>
49-
<p class="control">
50-
<button class="button is-black" :disabled="!searchFor"
51-
@click="resetSearch()">
52-
<span class="icon"><icon name="times"></icon></span>
53-
</button>
54-
</p>
55-
</div>
56-
</div>
41+
<div class="field has-addons">
42+
<p class="control has-icons-left">
43+
<input class="input"
44+
type="text"
45+
v-model="searchFor"
46+
placeholder="{{ trans('SimpleMenu::messages.find') }}">
47+
<span class="icon is-left">
48+
<icon name="search"></icon>
49+
</span>
50+
</p>
51+
<p class="control">
52+
<button class="button is-black" :disabled="!searchFor"
53+
@click="resetSearch()">
54+
<span class="icon"><icon name="times"></icon></span>
55+
</button>
56+
</p>
57+
</div>
5758
</div>
5859
</div>
5960

src/resources/views/admin/pages/create.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<a href="{{ route($crud_prefix.'.pages.index') }}">{{ trans('SimpleMenu::messages.go_back') }}</a>
77
</h3>
88

9-
<sm-page inline-template select-first="{{ LaravelLocalization::getCurrentLocale() }}">
9+
<sm-page inline-template v-cloak select-first="{{ LaravelLocalization::getCurrentLocale() }}">
1010
<div>
1111
{{ Form::open(['method' => 'POST', 'route' => $crud_prefix.'.pages.store', 'files' => true]) }}
1212

@@ -345,4 +345,4 @@ class="input toggle-pad"
345345
{{ Form::close() }}
346346
</div>
347347
</sm-page>
348-
@endsection
348+
@endsection

src/resources/views/admin/pages/edit.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class="button is-success">
5252
</div>
5353
</div>
5454

55-
<sm-page inline-template select-first="{{ LaravelLocalization::getCurrentLocale() }}">
55+
<sm-page inline-template v-cloak select-first="{{ LaravelLocalization::getCurrentLocale() }}">
5656
<div>
5757
{{ Form::model($page, ['method' => 'PUT', 'route' => [$crud_prefix.'.pages.update', $page->id], 'files' => true]) }}
5858

@@ -418,4 +418,4 @@ class="input toggle-pad"
418418
{{ Form::close() }}
419419
</div>
420420
</sm-page>
421-
@endsection
421+
@endsection

src/resources/views/admin/pages/index.blade.php

+19-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@section('title', trans('SimpleMenu::messages.pages'))
33

44
@section('sub')
5-
<sm-index inline-template :count="{{ count($pages) }}">
5+
<sm-index inline-template v-cloak :count="{{ count($pages) }}">
66
<div>
77
<div class="level">
88
<div class="level-left"></div>
@@ -35,27 +35,26 @@ class="button is-success">
3535
{{ trans('SimpleMenu::messages.pages') }} "<span>@{{ itemsCount }}</span>"
3636
</h3>
3737
</div>
38-
<div class="level-right">
38+
3939
{{-- search --}}
4040
<div class="level-right">
41-
<div class="field has-addons">
42-
<p class="control has-icons-left">
43-
<input class="input"
44-
type="text"
45-
v-model="searchFor"
46-
placeholder="{{ trans('SimpleMenu::messages.find') }}">
47-
<span class="icon is-left">
48-
<icon name="search"></icon>
49-
</span>
50-
</p>
51-
<p class="control">
52-
<button class="button is-black" :disabled="!searchFor"
53-
@click="resetSearch()">
54-
<span class="icon"><icon name="times"></icon></span>
55-
</button>
56-
</p>
57-
</div>
58-
</div>
41+
<div class="field has-addons">
42+
<p class="control has-icons-left">
43+
<input class="input"
44+
type="text"
45+
v-model="searchFor"
46+
placeholder="{{ trans('SimpleMenu::messages.find') }}">
47+
<span class="icon is-left">
48+
<icon name="search"></icon>
49+
</span>
50+
</p>
51+
<p class="control">
52+
<button class="button is-black" :disabled="!searchFor"
53+
@click="resetSearch()">
54+
<span class="icon"><icon name="times"></icon></span>
55+
</button>
56+
</p>
57+
</div>
5958
</div>
6059
</div>
6160

0 commit comments

Comments
 (0)