read content notification on click
This commit is contained in:
parent
1fae3dd414
commit
495e1c024e
7 changed files with 25 additions and 16 deletions
|
|
@ -9,7 +9,6 @@ return [
|
||||||
|
|
||||||
$page = page($data->briefUri);
|
$page = page($data->briefUri);
|
||||||
$project = $page->parent();
|
$project = $page->parent();
|
||||||
$dialogUri = $data->dialogUri ? $data->dialogUri : null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$newPage = $page->update([
|
$newPage = $page->update([
|
||||||
|
|
@ -22,8 +21,6 @@ return [
|
||||||
$notification = [
|
$notification = [
|
||||||
'location' => [
|
'location' => [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
'project' => $project,
|
|
||||||
'dialogUri' => (string) $dialogUri,
|
|
||||||
],
|
],
|
||||||
'date' => $dateTime->format('Y-m-d\TH:i:sP'),
|
'date' => $dateTime->format('Y-m-d\TH:i:sP'),
|
||||||
'text' => "Nouveau brief",
|
'text' => "Nouveau brief",
|
||||||
|
|
@ -32,7 +29,7 @@ return [
|
||||||
'type' => 'content'
|
'type' => 'content'
|
||||||
];
|
];
|
||||||
|
|
||||||
kirby()->user()->sendNotification($project, $notification);
|
$project->createNotification($notification);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"success" => "'" . $project->title()->value() . "' brief validated."
|
"success" => "'" . $project->title()->value() . "' brief validated."
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,10 @@ function handleClick() {
|
||||||
async function read() {
|
async function read() {
|
||||||
if (getStatus.value !== "unread") return;
|
if (getStatus.value !== "unread") return;
|
||||||
try {
|
try {
|
||||||
const newNotification = await api.readNotification(comment, page.value.uri);
|
const newNotification = await api.readNotification(
|
||||||
|
comment.id,
|
||||||
|
page.value.uri
|
||||||
|
);
|
||||||
userStore.readNotification(comment.id, route.params.id);
|
userStore.readNotification(comment.id, route.params.id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Erreur lors de la lecture de la notification : ", error);
|
console.log("Erreur lors de la lecture de la notification : ", error);
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@
|
||||||
<article
|
<article
|
||||||
class="notification | bg-white rounded-lg | p-16 | flow"
|
class="notification | bg-white rounded-lg | p-16 | flow"
|
||||||
data-type="content"
|
data-type="content"
|
||||||
@click="
|
@click="readNotification()"
|
||||||
read(notification);
|
|
||||||
router.push(notification.location.page.uri);
|
|
||||||
"
|
|
||||||
title="Aller au contenu"
|
title="Aller au contenu"
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
|
|
@ -16,7 +13,7 @@
|
||||||
>Contenu</strong
|
>Contenu</strong
|
||||||
>
|
>
|
||||||
<span class="notification__client | text-grey-700">{{
|
<span class="notification__client | text-grey-700">{{
|
||||||
notification.location.project.title
|
notification.project.title
|
||||||
}}</span>
|
}}</span>
|
||||||
<time
|
<time
|
||||||
datetime=""
|
datetime=""
|
||||||
|
|
@ -37,8 +34,17 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useNotificationsStore } from "../../stores/notifications";
|
import { useNotificationsStore } from "../../stores/notifications";
|
||||||
|
import { useUserStore } from "../../stores/user";
|
||||||
|
import { useApiStore } from "../../stores/api";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { notification } = defineProps({ notification: Object });
|
const { notification } = defineProps({ notification: Object });
|
||||||
const { formatDate, read } = useNotificationsStore();
|
const { formatDate } = useNotificationsStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const api = useApiStore();
|
||||||
|
|
||||||
|
function readNotification() {
|
||||||
|
api.readNotification(notification.id, notification.project.uri);
|
||||||
|
userStore.readNotification(notification.id, notification.project.slug);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
}}</strong
|
}}</strong
|
||||||
>
|
>
|
||||||
<span class="notification__client | text-grey-700">{{
|
<span class="notification__client | text-grey-700">{{
|
||||||
notification.location.project.title
|
notification.project.title
|
||||||
}}</span>
|
}}</span>
|
||||||
<time
|
<time
|
||||||
datetime=""
|
datetime=""
|
||||||
|
|
|
||||||
|
|
@ -149,12 +149,12 @@ export const useApiStore = defineStore("api", () => {
|
||||||
* @param {string} projectId UUID or URI
|
* @param {string} projectId UUID or URI
|
||||||
* @returns status with message if error
|
* @returns status with message if error
|
||||||
*/
|
*/
|
||||||
async function readNotification(comment, projectId) {
|
async function readNotification(notificationId, projectId) {
|
||||||
const headers = {
|
const headers = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
projectId,
|
projectId,
|
||||||
notificationId: comment.id,
|
notificationId,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,10 @@
|
||||||
class="btn | ml-auto"
|
class="btn | ml-auto"
|
||||||
@click="validate"
|
@click="validate"
|
||||||
v-if="page.content.isvalidated != 'true'"
|
v-if="page.content.isvalidated != 'true'"
|
||||||
:disabled="page.files.length === 0"
|
:disabled="page.moodboard.length === 0"
|
||||||
|
:title="
|
||||||
|
page.moodboard.length === 0 ? 'Ajoutez au moins une image' : undefined
|
||||||
|
"
|
||||||
>
|
>
|
||||||
Valider et envoyer le brief
|
Valider et envoyer le brief
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ function getHref(notification) {
|
||||||
|
|
||||||
const isDocumentBrief =
|
const isDocumentBrief =
|
||||||
notification.location.page.template === "client-brief" &&
|
notification.location.page.template === "client-brief" &&
|
||||||
notification.location?.file.type === "document";
|
notification.location?.file?.type === "document";
|
||||||
|
|
||||||
if (isDocumentBrief) {
|
if (isDocumentBrief) {
|
||||||
return notification.project.uri + "?dialog=client-brief&comments=true";
|
return notification.project.uri + "?dialog=client-brief&comments=true";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue