Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/Actions/TagRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 30 additions & 0 deletions app/Http/Controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);

}

}
26 changes: 26 additions & 0 deletions resources/assets/sass/_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions resources/lang/de/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'toggle_thumbnails' => 'Thumbnails zeigen/verstecken',
'details' => 'Details',
'grid_view' => 'Gitteransicht',
'list_tag' => 'Schlagwort Liste',
'list_view' => 'Listenansicht',

/**
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'details' => 'Details',
'grid_view' => 'Grid View',
'list_view' => 'List View',
'list_tag' => 'List Tags',
'default' => 'Default',

// Header
Expand Down
7 changes: 6 additions & 1 deletion resources/views/books/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
@extends('sidebar-layout')

@section('toolbar')
<div class="col-xs-6">
<div class="col-xs-1">
<div class="action-buttons text-left">
@include('books/view-toggle', ['booksViewType' => $booksViewType])
</div>
</div>
<div class="col-xs-5">
<div class="action-buttons text-pos text-left">
<a href="{{baseUrl('/tags')}}" class="text-pos text-button">@icon('tag'){{ trans('common.list_tag') }}</a>
</div>
</div>
<div class="col-xs-6 faded">
<div class="action-buttons">
@if($currentUser->can('book-create-all'))
Expand Down
7 changes: 6 additions & 1 deletion resources/views/shelves/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
@extends('sidebar-layout')

@section('toolbar')
<div class="col-xs-6 faded">
<div class="col-xs-1">
<div class="action-buttons text-left">
@include('shelves/view-toggle', ['shelvesViewType' => $shelvesViewType])
</div>
</div>
<div class="col-xs-5">
<div class="action-buttons text-pos text-left">
<a href="{{baseUrl('/tags')}}" class="text-pos text-button">@icon('tag'){{ trans('common.list_tag') }}</a>
</div>
</div>
<div class="col-xs-6 faded">
<div class="action-buttons">
@if($currentUser->can('bookshelf-create-all'))
Expand Down
11 changes: 11 additions & 0 deletions resources/views/tags/characterlist.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1>{{ trans('entities.tags') }} {{$searchTerm}}</h1>
<div class="tag grid ">
@if(count($tags) > 0)

@foreach($tags as $tag)
@include('tags/list-item', ['tag' => $tag])
@endforeach
@else
<p class="text-muted">{{ trans('common.no_items') }}</p>
@endif
</div>
7 changes: 7 additions & 0 deletions resources/views/tags/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@extends('simple-layout')

@section('body')
<div class="content tag">
@include('tags/list', ['tags' => $tags])
</div>
@stop
3 changes: 3 additions & 0 deletions resources/views/tags/list-item.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="tag entity-list-item" data-entity-type="tag" data-entity-id="{{$tag->id}}">
<h6 class="text-book"><a class="text-book entity-list-item-link" href="{{ baseUrl("/search?term=%5B".$tag->name."%5D") }}"><span class="entity-list-item-name break-text">{{$tag->name}}</span></a></h6>
</div>
23 changes: 23 additions & 0 deletions resources/views/tags/list.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h1>{{ trans('entities.tags') }}</h1>
<div class="tag grid">
@if(count($tags) > 0)
@php
$charactersplit = '';
@endphp
@foreach($tags as $tag)
@if (substr(strtoupper($tag->name),0,1) != $charactersplit)
@if ('' != $charactersplit)
</div>
@endif
@php
$charactersplit = substr(strtoupper($tag->name),0,1);
@endphp
<div class="taggroup entity-list-item grid-content" data-entity-type="taggroup" data-entity-id="{{$charactersplit}}">
<h4><a class="entity-list-item-link" href="/tags/{{$charactersplit}}">{{$charactersplit}}</a></h4>
@endif
@include('tags/list-item', ['tag' => $tag])
@endforeach
@else
<p class="text-muted">{{ trans('common.no_items') }}</p>
@endif
</div>
7 changes: 7 additions & 0 deletions resources/views/tags/search.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@extends('simple-layout')

@section('body')
<div class="content tag">
@include('tags/characterlist', ['tags' => $tags, 'searchTerm' => $searchTerm])
</div>
@stop
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down