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') -