Skip to content

Commit 6ba5c81

Browse files
authored
Merge pull request #29 from laravelcm/update-forum-section
✨ ajout de la possibilite de retirer un thread comme resolu
2 parents d4e1853 + b4b9cae commit 6ba5c81

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

app/Http/Livewire/Forum/Reply.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ public function edit()
5959
$this->emitSelf('refresh');
6060
}
6161

62+
public function UnMarkAsSolution(): void
63+
{
64+
$this->authorize(ThreadPolicy::UPDATE, $this->thread);
65+
66+
$this->thread->unmarkSolution();
67+
68+
$this->emitSelf('refresh');
69+
70+
$this->notification()->success(
71+
'Réponse acceptée',
72+
'Vous avez retiré cette réponse comme solution pour ce sujet.'
73+
);
74+
}
75+
6276
public function markAsSolution(): void
6377
{
6478
$this->authorize(ThreadPolicy::UPDATE, $this->thread);

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"/js/app.js": "/js/app.js?id=9abd09e80a5426001802",
3-
"/css/app.css": "/css/app.css?id=2d48602df6b458ee81ad"
3+
"/css/app.css": "/css/app.css?id=29b070295883a7994af2"
44
}

resources/views/components/forum/thread.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-skin-
6262
<x-markdown-content :content="$thread->body" />
6363
</div>
6464
<div class="mt-6">
65-
<livewire:reactions wire:key="$thread->id" :model="$thread" :with-place-holder="false"/>
65+
<livewire:reactions wire:key="$thread->id" :model="$thread" :with-place-holder="false" :with-background="false"/>
6666
</div>
6767
</div>

resources/views/livewire/forum/reply.blade.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<li x-data="{ open: @entangle('isUpdating') }" @class(['sm:-mx-4 p-4 border border-green-500 rounded-md relative z-10' => $isSolution])>
44
<div class="sm:flex sm:space-x-3" id="reply-{{ $reply->id }}">
5-
<div class="flex items-center font-sans">
5+
<div class="flex items-center font-sans sm:items-start">
66
<div class="flex-shrink-0">
77
<img class="h-10 w-10 rounded-full" src="{{ $reply->author->profile_photo_url }}" alt="Avatar de {{ $reply->author->username }}">
88
</div>
@@ -14,8 +14,8 @@
1414
</div>
1515
</div>
1616
<div x-show="!open" class="flex-1">
17-
<div class="hidden sm:flex sm:items-start">
18-
<div class="flex items-center flex-1 text-sm space-x-2 font-sans">
17+
<div class="flex items-start">
18+
<div class="hidden sm:flex sm:items-center flex-1 text-sm space-x-2 font-sans">
1919
<a href="{{ route('profile', $reply->author->username) }}" class="font-medium text-skin-inverted">
2020
{{ $reply->author->name }} <span class="inline-flex text-skin-muted">{{ '@' . $reply->author->username }}</span>
2121
</a>
@@ -31,20 +31,30 @@
3131
</div>
3232
@endcan
3333
</div>
34-
@if ($isSolution)
35-
<span class="absolute -top-3 z-20 right-3 ml-4 inline-flex items-center px-3 py-0.5 rounded-full text-sm font-medium bg-green-500 text-green-900">
36-
<x-heroicon-o-check-circle class="h-4 w-4 mr-1.5" />
37-
Réponse acceptée
38-
</span>
39-
@else
40-
@can(App\Policies\ThreadPolicy::UPDATE, $thread)
41-
<div class="ml-4">
34+
@can(App\Policies\ThreadPolicy::UPDATE, $thread)
35+
@if ($isSolution)
36+
<div class="mt-2 flex items-center sm:mt-0 sm:ml-4 sm:-mt-3">
37+
<button wire:click="UnMarkAsSolution" type="button" class="inline-flex items-center justify-center p-2.5 bg-red-500 bg-opacity-10 text-red-600 text-sm leading-5 rounded-full focus:outline-none transform hover:scale-125 transition-all">
38+
<x-heroicon-s-x-circle class="w-6 h-6" />
39+
</button>
40+
<span class="ml-2 text-sm font-sans text-red-500 sm:hidden">Retirer comme solution</span>
41+
</div>
42+
@else
43+
<div class="mt-2 flex items-center sm:mt-0 sm:ml-4 sm:-mt-3">
4244
<button wire:click="markAsSolution" type="button" class="inline-flex items-center justify-center p-2.5 bg-green-500 bg-opacity-10 text-green-600 text-sm leading-5 rounded-full focus:outline-none transform hover:scale-125 transition-all">
4345
<x-heroicon-s-check-circle class="w-6 h-6" />
4446
</button>
47+
<span class="ml-2 text-sm font-sans text-green-500 sm:hidden">Marquer comme solution</span>
4548
</div>
46-
@endcan
47-
@endif
49+
@endif
50+
@else
51+
@if($isSolution)
52+
<span class="absolute -top-3 z-20 right-3 ml-4 inline-flex items-center px-3 py-0.5 rounded-full text-sm font-medium bg-green-500 text-green-900">
53+
<x-heroicon-o-check-circle class="h-4 w-4 mr-1.5" />
54+
Réponse acceptée
55+
</span>
56+
@endif
57+
@endcan
4858
</div>
4959
<div class="mt-1 font-normal prose sm:prose-base prose-green text-skin-base overflow-x-auto sm:max-w-none">
5060
<x-markdown-content :content="$reply->body" />

0 commit comments

Comments
 (0)