change notifications structure from object to array
This commit is contained in:
parent
0d25794b87
commit
20824983a6
8 changed files with 64 additions and 50 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<article class="comment | flow" :data-status="setStatus(comment)">
|
||||
<header>
|
||||
<p>
|
||||
<strong>{{ comment.user.name ?? comment.user.email }}</strong>
|
||||
<strong>{{ comment.author.name ?? comment.author.email }}</strong>
|
||||
<template v-if="commentIndex">
|
||||
<span class="comment__id">#{{ commentIndex }}</span>
|
||||
•
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
<template v-if="comments">
|
||||
<template v-if="!openedComment">
|
||||
<Comment
|
||||
v-for="(comment, commentIndex) in Object.values(comments).reverse()"
|
||||
v-for="(comment, commentIndex) in sortedComments"
|
||||
:comment="comment"
|
||||
:commentIndex="commentIndex + 1"
|
||||
:commentIndex="comments.length - commentIndex"
|
||||
:key="comment.id"
|
||||
@click="openedComment = comment"
|
||||
/>
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
import dayjs from "dayjs";
|
||||
import "dayjs/locale/fr";
|
||||
import uniqid from "uniqid";
|
||||
import { ref } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { useUserStore } from "../../stores/user";
|
||||
import { usePageStore } from "../../stores/page";
|
||||
import { useApiStore } from "../../stores/api";
|
||||
|
|
@ -99,7 +99,7 @@ dayjs.locale("fr");
|
|||
const { currentPageIndex, file, comments } = defineProps({
|
||||
currentPageIndex: Number,
|
||||
file: Object,
|
||||
comments: Object,
|
||||
comments: Array,
|
||||
});
|
||||
|
||||
const { user } = useUserStore();
|
||||
|
|
@ -111,6 +111,9 @@ const openedComment = ref(null);
|
|||
const newCommentText = ref("");
|
||||
const isAddOpen = ref(false);
|
||||
const emits = defineEmits(["update:file"]);
|
||||
const sortedComments = computed(() => {
|
||||
return comments.reverse();
|
||||
});
|
||||
|
||||
// Functions
|
||||
function handleSubmit(event) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
>
|
||||
<router-link
|
||||
v-if="currentTab === 'all' || !notification.isRead"
|
||||
:to="notification.page.uri + '?fileUuid=' + notification.file.uuid"
|
||||
:to="notification.page.uri + '?notificationId=' + notification.id"
|
||||
>
|
||||
<article
|
||||
class="notification | bg-white rounded-lg | p-16 | flow"
|
||||
|
|
@ -136,13 +136,7 @@ const tabs = computed(() => {
|
|||
});
|
||||
|
||||
const sortedNotifications = computed(() => {
|
||||
const allNotifications = [
|
||||
...Object.values(notifications.value.comments || {}),
|
||||
...Object.values(notifications.value.content || {}),
|
||||
...Object.values(notifications.value.meetings || {}),
|
||||
];
|
||||
|
||||
const sortedNotifications = allNotifications.sort((a, b) => {
|
||||
const sortedNotifications = notifications.value.sort((a, b) => {
|
||||
dayjs(b.date).diff(dayjs(a.date));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -179,17 +179,18 @@ const user = useUserStore().user;
|
|||
|
||||
const file = ref(null);
|
||||
|
||||
const route = useRoute();
|
||||
// const route = useRoute();
|
||||
|
||||
if (route.query.fileUuid) {
|
||||
page.value.steps.forEach((step) => {
|
||||
step.files.forEach((item) => {
|
||||
if (item.uuid === route.query.fileUuid) {
|
||||
file.value = item;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// if (route.query.notificationId) {
|
||||
// page.value.steps.forEach((step) => {
|
||||
// const srcNotification = user.notifications;
|
||||
// step.files.forEach((item) => {
|
||||
// if (item.uuid === route.query.notificationId) {
|
||||
// file.value = item;
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
function setStepStatus(stepName) {
|
||||
const stepIndex = steps.indexOf(stepName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue