mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-04-20 23:11:56 +02:00
Add tags overview to guest mode (#160)
This commit is contained in:
parent
b0a1438479
commit
e7118237c3
@ -3,12 +3,37 @@
|
||||
namespace App\Http\Controllers\Guest;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\LinkList;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display an overview of all lists.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return View
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$tags = Tag::isPrivate(false)
|
||||
->withCount('links')
|
||||
->orderBy(
|
||||
$request->input('orderBy', 'name'),
|
||||
$request->input('orderDir', 'asc')
|
||||
)
|
||||
->paginate(getPaginationLimit());
|
||||
|
||||
return view('guest.tags.index', [
|
||||
'tags' => $tags,
|
||||
'route' => $request->getBaseUrl(),
|
||||
'orderBy' => $request->input('orderBy', 'name'),
|
||||
'orderDir' => $request->input('orderDir', 'asc'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
@ -29,10 +54,10 @@ class TagController extends Controller
|
||||
|
||||
return view('guest.tags.show', [
|
||||
'tag' => $tag,
|
||||
'tag_links' => $links,
|
||||
'tagLinks' => $links,
|
||||
'route' => $request->getBaseUrl(),
|
||||
'order_by' => $request->input('orderBy', 'title'),
|
||||
'order_dir' => $request->input('orderDir', 'ASC'),
|
||||
'orderBy' => $request->input('orderBy', 'title'),
|
||||
'orderDir' => $request->input('orderDir', 'ASC'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,11 @@
|
||||
@lang('list.lists')
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="{{ route('guest.tags.index') }}" class="nav-link pl-3 pl-md-2">
|
||||
@lang('tag.tags')
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav ml-auto">
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<header class="d-flex align-items-center">
|
||||
<h3 class="mb-0">
|
||||
@lang('link.links')
|
||||
@lang('tag.tags')
|
||||
</h3>
|
||||
</header>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
</div>
|
||||
|
||||
@if(!$tags->isEmpty())
|
||||
{!! $tags->onEachSide(1)->links() !!}
|
||||
{!! $tags->onEachSide(1)->appends(['orderBy' => $orderBy, 'orderDir' => $orderDir])->links() !!}
|
||||
@endif
|
||||
|
||||
@endsection
|
||||
|
@ -3,10 +3,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
{!! tableSorter(trans('tag.name'), $route, 'name', $order_by, $order_dir) !!}
|
||||
{!! tableSorter(trans('tag.name'), $route, 'name', $orderBy, $orderDir) !!}
|
||||
</th>
|
||||
<th>
|
||||
@lang('link.links')
|
||||
{!! tableSorter(trans('link.links'), $route, 'links_count', $orderBy, $orderDir) !!}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -19,11 +19,11 @@
|
||||
</div>
|
||||
<div class="card-table">
|
||||
|
||||
@include('guest.links.partials.table', ['links' => $tag_links])
|
||||
@include('guest.links.partials.table', ['links' => $tagLinks])
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! $tag_links->onEachSide(1)->links() !!}
|
||||
{!! $tagLinks->onEachSide(1)->appends(['orderBy' => $orderBy, 'orderDir' => $orderDir])->links() !!}
|
||||
|
||||
@endsection
|
||||
|
@ -22,16 +22,33 @@ class TagControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function testValidTagOverviewResponse(): void
|
||||
{
|
||||
factory(User::class)->create();
|
||||
|
||||
$tagPublic = factory(Tag::class)->create(['is_private' => false]);
|
||||
$tagPrivate = factory(Tag::class)->create(['is_private' => true]);
|
||||
|
||||
$response = $this->get('guest/tags');
|
||||
|
||||
$response->assertOk()
|
||||
->assertSee($tagPublic->name)
|
||||
->assertDontSee($tagPrivate->name);
|
||||
}
|
||||
|
||||
public function testValidTagDetailResponse(): void
|
||||
{
|
||||
factory(User::class)->create();
|
||||
|
||||
$tag = factory(Tag::class)->create(['is_private' => false]);
|
||||
factory(Tag::class)->create([
|
||||
'name' => 'testTag',
|
||||
'is_private' => false,
|
||||
]);
|
||||
|
||||
$response = $this->get('guest/tags/1');
|
||||
|
||||
$response->assertOk()
|
||||
->assertSee($tag->name);
|
||||
->assertSee('testTag');
|
||||
}
|
||||
|
||||
public function testInvalidTagDetailResponse(): void
|
||||
|
Loading…
x
Reference in New Issue
Block a user