From ffca52b0120893bb45fe6b9629fce81b6c27ddc8 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 6 Mar 2019 15:45:42 -0800 Subject: [PATCH 1/3] Add tag index page. --- app/Actions/TagRepo.php | 17 +++++++++++ app/Http/Controllers/TagController.php | 30 ++++++++++++++++++++ resources/assets/sass/_lists.scss | 29 +++++++++++++++++++ resources/views/tags/characterlist.blade.php | 11 +++++++ resources/views/tags/index.blade.php | 7 +++++ resources/views/tags/list-item.blade.php | 3 ++ resources/views/tags/list.blade.php | 23 +++++++++++++++ resources/views/tags/search.blade.php | 7 +++++ routes/web.php | 2 ++ 9 files changed, 129 insertions(+) create mode 100644 resources/views/tags/characterlist.blade.php create mode 100644 resources/views/tags/index.blade.php create mode 100644 resources/views/tags/list-item.blade.php create mode 100644 resources/views/tags/list.blade.php create mode 100644 resources/views/tags/search.blade.php diff --git a/app/Actions/TagRepo.php b/app/Actions/TagRepo.php index 0cbfa4163bf..c7f97a33224 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', 'desc'); + } + $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..9ee32a41236 100644 --- a/resources/assets/sass/_lists.scss +++ b/resources/assets/sass/_lists.scss @@ -413,3 +413,32 @@ 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; + border-left: 1px solid #DDD; + max-width: 100%; + + > h1 { + display: inline-block; + } + +} \ No newline at end of file diff --git a/resources/views/tags/characterlist.blade.php b/resources/views/tags/characterlist.blade.php new file mode 100644 index 00000000000..a7ca76c400f --- /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 +

Tag not found

+ @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..a71ff108f02 --- /dev/null +++ b/resources/views/tags/list-item.blade.php @@ -0,0 +1,3 @@ +
+
{{$tag->name}}
+
\ 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..dea91685c46 --- /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 +

Tag not found

+ @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() { From 0b163a484fd65e1c456e40c170ae2a26df5a5292 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 7 Mar 2019 09:17:29 -0800 Subject: [PATCH 2/3] Add tag link. Add translation tags. --- resources/lang/de/common.php | 1 + resources/lang/en/common.php | 1 + resources/views/books/index.blade.php | 7 ++++++- resources/views/shelves/index.blade.php | 7 ++++++- resources/views/tags/characterlist.blade.php | 2 +- resources/views/tags/list-item.blade.php | 2 +- resources/views/tags/list.blade.php | 2 +- 7 files changed, 17 insertions(+), 5 deletions(-) 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 index a7ca76c400f..5167cbb158e 100644 --- a/resources/views/tags/characterlist.blade.php +++ b/resources/views/tags/characterlist.blade.php @@ -6,6 +6,6 @@ @include('tags/list-item', ['tag' => $tag]) @endforeach @else -

Tag not found

+

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

@endif
\ No newline at end of file diff --git a/resources/views/tags/list-item.blade.php b/resources/views/tags/list-item.blade.php index a71ff108f02..867901aafe3 100644 --- a/resources/views/tags/list-item.blade.php +++ b/resources/views/tags/list-item.blade.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/resources/views/tags/list.blade.php b/resources/views/tags/list.blade.php index dea91685c46..3054f0cdae8 100644 --- a/resources/views/tags/list.blade.php +++ b/resources/views/tags/list.blade.php @@ -18,6 +18,6 @@ @include('tags/list-item', ['tag' => $tag]) @endforeach @else -

Tag not found

+

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

@endif
\ No newline at end of file From 5d9c9859905a607902686017a1f106161a203f66 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 7 Mar 2019 11:39:35 -0800 Subject: [PATCH 3/3] Add some padding to the tag list. Fixed sorting on tag list. --- app/Actions/TagRepo.php | 2 +- resources/assets/sass/_lists.scss | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/Actions/TagRepo.php b/app/Actions/TagRepo.php index c7f97a33224..541701ea398 100644 --- a/app/Actions/TagRepo.php +++ b/app/Actions/TagRepo.php @@ -69,7 +69,7 @@ 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', 'desc'); + $query = $query->where('name', 'LIKE', $searchTerm . '%')->orderBy('name', 'ASC'); } $query = $this->permissionService->filterRestrictedEntityRelations($query, 'tags', 'entity_id', 'entity_type'); return $query->get(['id, name']); diff --git a/resources/assets/sass/_lists.scss b/resources/assets/sass/_lists.scss index 9ee32a41236..76f8c4f6be2 100644 --- a/resources/assets/sass/_lists.scss +++ b/resources/assets/sass/_lists.scss @@ -431,14 +431,11 @@ ul.pagination { } .tag.content { - background-color: #FFFFFF; - padding: 0 24px; + padding: 0 24px 24px 24px; border-left: 1px solid #DDD; max-width: 100%; - > h1 { display: inline-block; } - } \ No newline at end of file