new comment showing in comments panel
This commit is contained in:
parent
26369ad71b
commit
2c99811caf
5 changed files with 88 additions and 34 deletions
|
|
@ -11,3 +11,67 @@ Template: document
|
||||||
----
|
----
|
||||||
|
|
||||||
Comments:
|
Comments:
|
||||||
|
|
||||||
|
-
|
||||||
|
page:
|
||||||
|
uri: projects/miss-dior-blooming-bouquet
|
||||||
|
title: Miss Dior Blooming Bouquet
|
||||||
|
file:
|
||||||
|
uuid: file://s0lNtRA0Z7ybTCWG
|
||||||
|
replies: [ ]
|
||||||
|
text: test
|
||||||
|
author:
|
||||||
|
name: Adrien Payet
|
||||||
|
email: adrien.payet@outlook.com
|
||||||
|
uuid: user://WWjXgPWk
|
||||||
|
role: admin
|
||||||
|
position:
|
||||||
|
pageIndex: 1
|
||||||
|
x: "22.956789508989"
|
||||||
|
y: "22.586872586873"
|
||||||
|
date: 2024-11-16T12:04:11+01:00
|
||||||
|
id: m3k28t8f
|
||||||
|
type: comment
|
||||||
|
isRead: false
|
||||||
|
-
|
||||||
|
page:
|
||||||
|
uri: projects/miss-dior-blooming-bouquet
|
||||||
|
title: Miss Dior Blooming Bouquet
|
||||||
|
file:
|
||||||
|
uuid: file://s0lNtRA0Z7ybTCWG
|
||||||
|
replies: [ ]
|
||||||
|
text: encore
|
||||||
|
author:
|
||||||
|
name: Adrien Payet
|
||||||
|
email: adrien.payet@outlook.com
|
||||||
|
uuid: user://WWjXgPWk
|
||||||
|
role: admin
|
||||||
|
position:
|
||||||
|
pageIndex: 1
|
||||||
|
x: "24.049536437931"
|
||||||
|
y: "37.451737451737"
|
||||||
|
date: 2024-11-16T12:04:32+01:00
|
||||||
|
id: m3k299rb
|
||||||
|
type: comment
|
||||||
|
isRead: false
|
||||||
|
-
|
||||||
|
page:
|
||||||
|
uri: projects/miss-dior-blooming-bouquet
|
||||||
|
title: Miss Dior Blooming Bouquet
|
||||||
|
file:
|
||||||
|
uuid: file://s0lNtRA0Z7ybTCWG
|
||||||
|
replies: [ ]
|
||||||
|
text: et encore
|
||||||
|
author:
|
||||||
|
name: Adrien Payet
|
||||||
|
email: adrien.payet@outlook.com
|
||||||
|
uuid: user://WWjXgPWk
|
||||||
|
role: admin
|
||||||
|
position:
|
||||||
|
pageIndex: 1
|
||||||
|
x: '67.486226863373'
|
||||||
|
y: '53.088803088803'
|
||||||
|
date: 2024-11-16T12:05:20+01:00
|
||||||
|
id: m3k2ab7h
|
||||||
|
type: comment
|
||||||
|
isRead: false
|
||||||
|
|
@ -105,24 +105,20 @@
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import "dayjs/locale/fr";
|
import "dayjs/locale/fr";
|
||||||
import uniqid from "uniqid";
|
import uniqid from "uniqid";
|
||||||
import { watch, ref } from "vue";
|
import { watch, ref, computed } from "vue";
|
||||||
import { useUserStore } from "../../stores/user";
|
import { useUserStore } from "../../stores/user";
|
||||||
import { usePageStore } from "../../stores/page";
|
import { usePageStore } from "../../stores/page";
|
||||||
import { useApiStore } from "../../stores/api";
|
import { useApiStore } from "../../stores/api";
|
||||||
import { useDialogStore } from "../../stores/dialog";
|
import { useDialogStore } from "../../stores/dialog";
|
||||||
import Comment from "./Comment.vue";
|
import Comment from "./Comment.vue";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
|
||||||
dayjs.locale("fr");
|
dayjs.locale("fr");
|
||||||
|
|
||||||
const { currentPageIndex, file, comments } = defineProps({
|
|
||||||
currentPageIndex: Number,
|
|
||||||
file: Object,
|
|
||||||
comments: Array,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { user } = useUserStore();
|
const { user } = useUserStore();
|
||||||
const { page } = usePageStore();
|
const { page } = usePageStore();
|
||||||
const dialog = useDialogStore();
|
const dialog = useDialogStore();
|
||||||
|
const { comments, openedFile } = storeToRefs(useDialogStore());
|
||||||
const api = useApiStore();
|
const api = useApiStore();
|
||||||
|
|
||||||
const openedComment = ref(null);
|
const openedComment = ref(null);
|
||||||
|
|
@ -131,22 +127,13 @@ const newCommentPageIndex = ref(null);
|
||||||
const newCommentPosition = ref(null);
|
const newCommentPosition = ref(null);
|
||||||
const newCommentText = ref("");
|
const newCommentText = ref("");
|
||||||
const isAddOpen = ref(false);
|
const isAddOpen = ref(false);
|
||||||
const emits = defineEmits(["update:file"]);
|
|
||||||
|
|
||||||
const sortedComments = ref(comments.reverse());
|
const sortedComments = computed(() => comments.value.reverse());
|
||||||
const sortedReplies = ref(null);
|
const sortedReplies = ref(null);
|
||||||
|
|
||||||
watch(openedComment, (newVal) => {
|
watch(openedComment, (newVal) => {
|
||||||
sortedReplies.value = newVal ? newVal.replies.slice().reverse() : null;
|
sortedReplies.value = newVal ? newVal.replies.slice().reverse() : null;
|
||||||
});
|
});
|
||||||
watch(
|
|
||||||
() => file,
|
|
||||||
(newVal) => {
|
|
||||||
if (newVal.comments) {
|
|
||||||
sortedComments.value = newVal.comments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
watch(
|
watch(
|
||||||
() => comments,
|
() => comments,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
|
|
@ -180,7 +167,7 @@ function handleSubmit(event = null) {
|
||||||
const date = dayjs().format();
|
const date = dayjs().format();
|
||||||
const newComment = {
|
const newComment = {
|
||||||
pageUri: page.uri + "/client-brief",
|
pageUri: page.uri + "/client-brief",
|
||||||
fileName: file.name,
|
fileName: openedFile.value.name,
|
||||||
userUuid: user.uuid,
|
userUuid: user.uuid,
|
||||||
text: newCommentText.value,
|
text: newCommentText.value,
|
||||||
date,
|
date,
|
||||||
|
|
@ -207,7 +194,6 @@ async function replyComment(newComment) {
|
||||||
openedComment.value = newFile.comments.find(
|
openedComment.value = newFile.comments.find(
|
||||||
(item) => item.id === openedComment.value.id
|
(item) => item.id === openedComment.value.id
|
||||||
);
|
);
|
||||||
emits("update:file", newFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addComment(newComment) {
|
async function addComment(newComment) {
|
||||||
|
|
@ -215,9 +201,7 @@ async function addComment(newComment) {
|
||||||
newCommentText.value = "";
|
newCommentText.value = "";
|
||||||
isAddOpen.value = false;
|
isAddOpen.value = false;
|
||||||
|
|
||||||
dialog.content.files = dialog.content.files.map((file) =>
|
dialog.updateFile(newFile);
|
||||||
file.id === newFile.id ? newFile : file
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeComment() {
|
function closeComment() {
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,7 @@
|
||||||
>
|
>
|
||||||
<span class="sr-only">Afficher les commentaires</span>
|
<span class="sr-only">Afficher les commentaires</span>
|
||||||
</button>
|
</button>
|
||||||
<Comments
|
<Comments v-if="isCommentsOpen" />
|
||||||
v-if="isCommentsOpen"
|
|
||||||
:current-page-index="currentPageIndex"
|
|
||||||
:file="file"
|
|
||||||
:comments="file.comments ?? []"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -48,7 +43,9 @@ import { ref, watch } from "vue";
|
||||||
import { useDialogStore } from "../../../stores/dialog";
|
import { useDialogStore } from "../../../stores/dialog";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
||||||
const file = useDialogStore().content.files[0];
|
const dialog = useDialogStore();
|
||||||
|
dialog.openedFile = dialog.content.files[0];
|
||||||
|
const file = dialog.openedFile;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
@ -124,7 +121,6 @@ const onPdfLoaded = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function setCommentBubbles() {
|
function setCommentBubbles() {
|
||||||
console.log(file.comments);
|
|
||||||
if (!file.comments) return;
|
if (!file.comments) return;
|
||||||
file.comments.forEach((comment) => {
|
file.comments.forEach((comment) => {
|
||||||
const bubble = document.createElement("a");
|
const bubble = document.createElement("a");
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,6 @@ export const useApiStore = defineStore("api", () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
"Une erreur s'est produite lors de l'ajout du commentaire :",
|
"Une erreur s'est produite lors de l'ajout du commentaire :",
|
||||||
commentaire,
|
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref, computed } from "vue";
|
||||||
|
|
||||||
export const useDialogStore = defineStore("dialog", () => {
|
export const useDialogStore = defineStore("dialog", () => {
|
||||||
const content = ref(null);
|
const content = ref(null);
|
||||||
|
const openedFile = ref(null);
|
||||||
|
const comments = computed(() => {
|
||||||
|
return openedFile.value.comments;
|
||||||
|
});
|
||||||
|
|
||||||
return { content };
|
function updateFile(newFile) {
|
||||||
|
content.value.files = content.value.files.map((file) =>
|
||||||
|
file.id === newFile.id ? newFile : file
|
||||||
|
);
|
||||||
|
openedFile.value = newFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { content, openedFile, comments, updateFile };
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue