Skip to content

Commit

Permalink
Merge pull request #29 from laravelcm/update-forum-section
Browse files Browse the repository at this point in the history
✨ ajout de la possibilite de retirer un thread comme resolu
  • Loading branch information
mckenziearts authored Dec 6, 2021
2 parents d4e1853 + b4b9cae commit 6ba5c81
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
14 changes: 14 additions & 0 deletions app/Http/Livewire/Forum/Reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ public function edit()
$this->emitSelf('refresh');
}

public function UnMarkAsSolution(): void
{
$this->authorize(ThreadPolicy::UPDATE, $this->thread);

$this->thread->unmarkSolution();

$this->emitSelf('refresh');

$this->notification()->success(
'Réponse acceptée',
'Vous avez retiré cette réponse comme solution pour ce sujet.'
);
}

public function markAsSolution(): void
{
$this->authorize(ThreadPolicy::UPDATE, $this->thread);
Expand Down
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=9abd09e80a5426001802",
"/css/app.css": "/css/app.css?id=2d48602df6b458ee81ad"
"/css/app.css": "/css/app.css?id=29b070295883a7994af2"
}
2 changes: 1 addition & 1 deletion resources/views/components/forum/thread.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-skin-
<x-markdown-content :content="$thread->body" />
</div>
<div class="mt-6">
<livewire:reactions wire:key="$thread->id" :model="$thread" :with-place-holder="false"/>
<livewire:reactions wire:key="$thread->id" :model="$thread" :with-place-holder="false" :with-background="false"/>
</div>
</div>
36 changes: 23 additions & 13 deletions resources/views/livewire/forum/reply.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<li x-data="{ open: @entangle('isUpdating') }" @class(['sm:-mx-4 p-4 border border-green-500 rounded-md relative z-10' => $isSolution])>
<div class="sm:flex sm:space-x-3" id="reply-{{ $reply->id }}">
<div class="flex items-center font-sans">
<div class="flex items-center font-sans sm:items-start">
<div class="flex-shrink-0">
<img class="h-10 w-10 rounded-full" src="{{ $reply->author->profile_photo_url }}" alt="Avatar de {{ $reply->author->username }}">
</div>
Expand All @@ -14,8 +14,8 @@
</div>
</div>
<div x-show="!open" class="flex-1">
<div class="hidden sm:flex sm:items-start">
<div class="flex items-center flex-1 text-sm space-x-2 font-sans">
<div class="flex items-start">
<div class="hidden sm:flex sm:items-center flex-1 text-sm space-x-2 font-sans">
<a href="{{ route('profile', $reply->author->username) }}" class="font-medium text-skin-inverted">
{{ $reply->author->name }} <span class="inline-flex text-skin-muted">{{ '@' . $reply->author->username }}</span>
</a>
Expand All @@ -31,20 +31,30 @@
</div>
@endcan
</div>
@if ($isSolution)
<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">
<x-heroicon-o-check-circle class="h-4 w-4 mr-1.5" />
Réponse acceptée
</span>
@else
@can(App\Policies\ThreadPolicy::UPDATE, $thread)
<div class="ml-4">
@can(App\Policies\ThreadPolicy::UPDATE, $thread)
@if ($isSolution)
<div class="mt-2 flex items-center sm:mt-0 sm:ml-4 sm:-mt-3">
<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">
<x-heroicon-s-x-circle class="w-6 h-6" />
</button>
<span class="ml-2 text-sm font-sans text-red-500 sm:hidden">Retirer comme solution</span>
</div>
@else
<div class="mt-2 flex items-center sm:mt-0 sm:ml-4 sm:-mt-3">
<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">
<x-heroicon-s-check-circle class="w-6 h-6" />
</button>
<span class="ml-2 text-sm font-sans text-green-500 sm:hidden">Marquer comme solution</span>
</div>
@endcan
@endif
@endif
@else
@if($isSolution)
<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">
<x-heroicon-o-check-circle class="h-4 w-4 mr-1.5" />
Réponse acceptée
</span>
@endif
@endcan
</div>
<div class="mt-1 font-normal prose sm:prose-base prose-green text-skin-base overflow-x-auto sm:max-w-none">
<x-markdown-content :content="$reply->body" />
Expand Down

0 comments on commit 6ba5c81

Please sign in to comment.