diff --git a/app/Actions/TagRepo.php b/app/Actions/TagRepo.php index 0cbfa4163bf..541701ea398 100644 --- a/app/Actions/TagRepo.php +++ b/app/Actions/TagRepo.php @@ -58,6 +58,23 @@ public function getForEntity($entityType, $entityId) return $entity->tags; } + /** + * Get all tags for a particular entity. + * @param string $entityType + * @param int $entityId + * @return mixed + */ + public function getForIndex($searchTerm = false) + { + $query = $this->tag->select('*', \DB::raw('count(*) as count'))->groupBy('name'); + + if ($searchTerm) { + $query = $query->where('name', 'LIKE', $searchTerm . '%')->orderBy('name', 'ASC'); + } + $query = $this->permissionService->filterRestrictedEntityRelations($query, 'tags', 'entity_id', 'entity_type'); + return $query->get(['id, name']); + } + /** * Get tag name suggestions from scanning existing tag names. * If no search term is given the 50 most popular tag names are provided. diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 6abbeeebaa4..38f09d680e2 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -54,4 +54,34 @@ public function getValueSuggestions(Request $request) $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName); return response()->json($suggestions); } + + + /** + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function index(){ + $tags = $this->tagRepo->getForIndex(false); + + return view('tags/index', [ + 'tags' => $tags + ]); + + } + + + /** + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function search($searchTerm){ + $tags = $this->tagRepo->getForIndex($searchTerm); + + return view('tags/search', [ + 'tags' => $tags, + 'searchTerm' => $searchTerm + ]); + + } + } diff --git a/resources/assets/sass/_lists.scss b/resources/assets/sass/_lists.scss index 18a7ea9cee0..76f8c4f6be2 100644 --- a/resources/assets/sass/_lists.scss +++ b/resources/assets/sass/_lists.scss @@ -413,3 +413,29 @@ ul.pagination { } } + +//Tags grid view +.tag.grid { + grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); + grid-column-gap: 0px; +} + +.taggroup { + border-bottom: 1px #dddddd solid; + overflow-x: auto; +} + +.taggroup h4 { + margin-top: 0px; + max-height: 200px; +} + +.tag.content { + background-color: #FFFFFF; + padding: 0 24px 24px 24px; + border-left: 1px solid #DDD; + max-width: 100%; + > h1 { + display: inline-block; + } +} \ No newline at end of file diff --git a/resources/lang/de/common.php b/resources/lang/de/common.php index 5579a488aea..7793e3a38df 100644 --- a/resources/lang/de/common.php +++ b/resources/lang/de/common.php @@ -51,6 +51,7 @@ 'toggle_thumbnails' => 'Thumbnails zeigen/verstecken', 'details' => 'Details', 'grid_view' => 'Gitteransicht', + 'list_tag' => 'Schlagwort Liste', 'list_view' => 'Listenansicht', /** diff --git a/resources/lang/en/common.php b/resources/lang/en/common.php index ac2edc621f9..10cb2804609 100644 --- a/resources/lang/en/common.php +++ b/resources/lang/en/common.php @@ -47,6 +47,7 @@ 'details' => 'Details', 'grid_view' => 'Grid View', 'list_view' => 'List View', + 'list_tag' => 'List Tags', 'default' => 'Default', // Header diff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.php index 84150203f08..3a28b063604 100644 --- a/resources/views/books/index.blade.php +++ b/resources/views/books/index.blade.php @@ -1,11 +1,16 @@ @extends('sidebar-layout') @section('toolbar') -
+
@include('books/view-toggle', ['booksViewType' => $booksViewType])
+
+ +
@if($currentUser->can('book-create-all')) diff --git a/resources/views/shelves/index.blade.php b/resources/views/shelves/index.blade.php index a887a843e57..38b36a38b3c 100644 --- a/resources/views/shelves/index.blade.php +++ b/resources/views/shelves/index.blade.php @@ -1,11 +1,16 @@ @extends('sidebar-layout') @section('toolbar') -
+
@include('shelves/view-toggle', ['shelvesViewType' => $shelvesViewType])
+
@if($currentUser->can('bookshelf-create-all')) diff --git a/resources/views/tags/characterlist.blade.php b/resources/views/tags/characterlist.blade.php new file mode 100644 index 00000000000..5167cbb158e --- /dev/null +++ b/resources/views/tags/characterlist.blade.php @@ -0,0 +1,11 @@ +

{{ trans('entities.tags') }} {{$searchTerm}}

+
+ @if(count($tags) > 0) + + @foreach($tags as $tag) + @include('tags/list-item', ['tag' => $tag]) + @endforeach + @else +

{{ trans('common.no_items') }}

+ @endif +
\ No newline at end of file diff --git a/resources/views/tags/index.blade.php b/resources/views/tags/index.blade.php new file mode 100644 index 00000000000..475c3b3a60f --- /dev/null +++ b/resources/views/tags/index.blade.php @@ -0,0 +1,7 @@ +@extends('simple-layout') + +@section('body') +
+ @include('tags/list', ['tags' => $tags]) +
+@stop \ No newline at end of file diff --git a/resources/views/tags/list-item.blade.php b/resources/views/tags/list-item.blade.php new file mode 100644 index 00000000000..867901aafe3 --- /dev/null +++ b/resources/views/tags/list-item.blade.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/resources/views/tags/list.blade.php b/resources/views/tags/list.blade.php new file mode 100644 index 00000000000..3054f0cdae8 --- /dev/null +++ b/resources/views/tags/list.blade.php @@ -0,0 +1,23 @@ +

{{ trans('entities.tags') }}

+
+ @if(count($tags) > 0) + @php + $charactersplit = ''; + @endphp + @foreach($tags as $tag) + @if (substr(strtoupper($tag->name),0,1) != $charactersplit) + @if ('' != $charactersplit) +
+ @endif + @php + $charactersplit = substr(strtoupper($tag->name),0,1); + @endphp +
+

{{$charactersplit}}

+ @endif + @include('tags/list-item', ['tag' => $tag]) + @endforeach + @else +

{{ trans('common.no_items') }}

+ @endif +
\ No newline at end of file diff --git a/resources/views/tags/search.blade.php b/resources/views/tags/search.blade.php new file mode 100644 index 00000000000..4500859c188 --- /dev/null +++ b/resources/views/tags/search.blade.php @@ -0,0 +1,7 @@ +@extends('simple-layout') + +@section('body') +
+ @include('tags/characterlist', ['tags' => $tags, 'searchTerm' => $searchTerm]) +
+@stop \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index d3c5f46d3cc..fe2ac31bf67 100644 --- a/routes/web.php +++ b/routes/web.php @@ -160,6 +160,8 @@ Route::get('/', 'HomeController@index'); Route::get('/home', 'HomeController@index'); Route::get('/custom-head-content', 'HomeController@customHeadContent'); + Route::get('/tags/', 'TagController@index'); + Route::get('/tags/{id}', 'TagController@search'); // Settings Route::group(['prefix' => 'settings'], function() {