Skip to content

Commit

Permalink
feat: ability to unmute announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentauger committed Jan 3, 2025
1 parent 34b7627 commit 3966783
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class CheckAnnouncementController extends Controller
public function __invoke(Request $request)
{

$announcment = Announcement::active()->orderBy('start_at', 'desc')->get();
$announcement = Announcement::active()->orderBy('start_at', 'desc')->get();

if ($announcment->isEmpty()) {
if ($announcement->isEmpty()) {
return response()->json([], 204);
}

return AnnouncementResource::collection($announcment);
return AnnouncementResource::collection($announcement);

}
}
4 changes: 2 additions & 2 deletions resources/src/components/MainFooter.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
const year = new Date().getFullYear()
import AnnouncementMonitor from '@/models/Announcement/components/AnnouncementMonitor.vue'
</script>

<template>
Expand All @@ -13,7 +13,7 @@ const year = new Date().getFullYear()
>{{ $t('common.contact-us') }}</a>
</div>
<div class="text-caption">
&copy; {{ year }} OSP-PSO
<AnnouncementMonitor />
</div>
</div>
</q-footer>
Expand Down
2 changes: 0 additions & 2 deletions resources/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import MainDrawer from '@/components/MainDrawer.vue'
import MainFooter from '@/components/MainFooter.vue'
import MainHeader from '@/components/MainHeader.vue'
import AnnouncementMonitor from '@/models/Announcement/components/AnnouncementMonitor.vue'
import { useQuasar } from 'quasar'
const { t } = useI18n()
Expand Down Expand Up @@ -59,7 +58,6 @@ watch(

<template>
<q-layout view="hHh Lpr lff">
<AnnouncementMonitor />
<MainHeader @toggle-left-drawer="toggleLeftDrawer" />
<MainDrawer
v-if="authStore.isAuthenticated"
Expand Down
4 changes: 3 additions & 1 deletion resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@
"upload-a-new-version-of-the-publication": "Drop the file or click to automatically upload a new version of the publication",
"upload-the-publication": "Drop the file or click to automatically to upload the publication",
"from": "from",
"form-invalid": "There are errors in the form, please fix them to be able to save this form."
"form-invalid": "There are errors in the form, please fix them to be able to save this form.",
"no_announcements": "There are no general announcements at this time.",
"announcements": "Click here to show the muted announcement | Click here to show the {count} muted announcements"
},
"create-author-dialog": {
"title": "Create a new author"
Expand Down
3 changes: 2 additions & 1 deletion resources/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@
"upload-a-new-version-of-the-publication": "Déposez le fichier ou cliquez pour automatiquement télécharger une nouvelle version de la publication",
"upload-the-publication": "Déposez le fichier ou cliquez pour automatiquement télécharger une publication",
"from": "de",
"form-invalid": "Il y a des erreurs dans le formulaire, merci de les corriger pour pouvoir sauvegarder ce formulaire."
"form-invalid": "Il y a des erreurs dans le formulaire, merci de les corriger pour pouvoir sauvegarder ce formulaire.",
"no_announcements": "Il n’y a pas d’annonces générales pour le moment."
},
"create-author-dialog": {
"title": "Créer un nouvel auteur"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,30 @@ function notify(announcement: AnnouncementResource) {
],
})
}
function unmutedAnnouncement() {
muted.value = []
updateStatus()
}
</script>

<template>
<div />
<q-btn
flat
round
dense
size="sm"
:color="announcements?.data.length ? 'secondary' : 'grey-7'"
:disable="!announcements"
:icon="announcements?.data.length ? 'mdi-bell-badge' : 'mdi-bell-outline'"
class="q-mb-xs"
@click="unmutedAnnouncement"
>
<q-tooltip anchor="top left" self="bottom right">
<span v-if="!announcements">{{ $t('common.no_announcements') }}</span>
<span v-else>{{ $t('common.announcements', { count: announcements.data.length }) }}</span>
</q-tooltip>
</q-btn>
</template>

<style scoped></style>
2 changes: 1 addition & 1 deletion tests/Feature/Models/AnnouncementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use App\Models\Announcement;

test('an unauthenticated use can query the announcment page', function () {
test('an unauthenticated use can query the announcement page', function () {

$response = $this->get('/api/announcements');
$response->assertStatus(204);
Expand Down

0 comments on commit 3966783

Please sign in to comment.