Skip to content

Commit

Permalink
Merge pull request #865 from NFDI4Chem/refactor-notification-view
Browse files Browse the repository at this point in the history
fix: update notification view
  • Loading branch information
CS76 authored Oct 16, 2023
2 parents 2ce7d2f + 2d593cc commit 4b89d56
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 149 deletions.
15 changes: 15 additions & 0 deletions app/Http/Controllers/Admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,19 @@ public function markNotificationAsRead(User $user, Request $request)

return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', 'notification-markedAsRead');
}

/**
* Mark all notification as read.
*
* @param User $user
* @return \Illuminate\Http\RedirectResponse
*/
public function markAllNotificationAsRead(Request $request)
{
$user = Auth::user();

$user->unreadNotifications()->update(['read_at' => now()]);

return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', 'all-notification-markedAsRead');
}
}
2 changes: 1 addition & 1 deletion app/Notifications/ProjectInviteNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function via($notifiable)
*/
public function toArray($notifiable)
{
$title = 'Invitation from project - '.$this->invitation->project->name;
$title = 'Invitation from project - <b>'.$this->invitation->project->name.'</b>';
$message = 'You have been invited to join the project - '.$this->invitation->project->name.' (role: '.$this->invitation['role'].') by '.$this->invitation['invited_by'].'. Please check your mail to accept or decline the invitation.';

return [
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/StudyInviteNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function via($notifiable)
*/
public function toArray($notifiable)
{
$title = 'Invitation from study - '.$this->invitation->study->name;
$title = 'Invitation from study - <b>'.$this->invitation->study->name.'</b>';
$message = 'You have been invited to join the study - '.$this->invitation->study->name.' (role: '.$this->invitation['role'].') by '.$this->invitation['invited_by'].'. Please check your mail to accept or decline the invitation.';

return [
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/TeamInvitationNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function via($notifiable)
*/
public function toArray($notifiable)
{
$title = 'Invitation from team - '.$this->invitation->team->name;
$title = 'Invitation recieved to join <b>'.$this->invitation->team->name.'</b> team';
$message = 'You have been invited to join the '.$this->invitation->team->name.' team (role: '.$this->invitation['role'].') by '.$this->invitation['invited_by'].'. Please check your mail to accept or decline the invitation.';

return [
Expand Down
87 changes: 16 additions & 71 deletions resources/js/Layouts/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -294,78 +294,23 @@
:notification="$page.props.user.notifications"
/>
<div class="ml-4 flex items-center md:ml-6">
<Menu as="div" class="ml-3 relative">
<div>
<span>
<MenuButton
type="button"
class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition"
>
<BellIcon
class="w-6 h-6 fill-current text-gray-600"
/>
<span
v-if="hasUnreadNotification()"
class="inline-flex items-center justify-center px-1.5 py-0.5 text-xs font-bold leading-none text-red-100 bg-red-600 rounded-full"
>
{{ countNotification() }}</span
>
</MenuButton>
</span>
</div>
<transition
enter-active-class="transition ease-out duration-100"
enter-from-class="transform opacity-0 scale-95"
enter-to-class="transform opacity-100 scale-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100 scale-100"
leave-to-class="transform opacity-0 scale-95"
<div>
<button
@click="openShowNotificationDialog"
type="button"
class="m-1"
>
<MenuItems
class="origin-top-right absolute right-0 mt-2 w-72 text-sm leading-5 text-gray-700 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 divide-y divide-gray-100 focus:outline-none"
>
<span v-if="hasUnreadNotification() > 0">
<div
class="block px-4 p-2 text-xs text-gray-400"
>
Unread Notifications
</div>
<template
v-for="notification in $page.props
.user.notifications"
:key="notification"
>
<MenuItem
v-on:click="
openShowNotificationDialog(
notification
)
"
class="border-t border-gray-100"
>
<a
href="#"
class="block px-4 py-2 hover:bg-gray-100"
>
{{
notification.data[
"title"
]
}}
</a>
</MenuItem>
</template>
</span>
<span v-else>
<div
class="block px-4 py-2 text-m text-gray-600"
>
No unread notifications
</div>
</span>
</MenuItems>
</transition>
</Menu>
<BellIcon
class="w-6 h-6 fill-current text-gray-600"
/>
</button>
</div>
<span
v-if="hasUnreadNotification()"
class="inline-flex items-center justify-center px-1.5 py-0.5 text-xs font-bold leading-none text-red-100 bg-red-600 rounded-full"
>
{{ countNotification() }}</span
>
<div class="tooltip">
<a
id="tour-step-documentation"
Expand Down
Loading

0 comments on commit 4b89d56

Please sign in to comment.