comments > get absolute position of new comment
This commit is contained in:
parent
c0a29c0d18
commit
6e0b2299e2
4 changed files with 133 additions and 16 deletions
|
|
@ -72,4 +72,67 @@ Comments:
|
||||||
isRead: false
|
isRead: false
|
||||||
position:
|
position:
|
||||||
x: null
|
x: null
|
||||||
y: null
|
y: null
|
||||||
|
-
|
||||||
|
page:
|
||||||
|
uri: projects/miss-dior-blooming-bouquet
|
||||||
|
title: Miss Dior Blooming Bouquet
|
||||||
|
file:
|
||||||
|
uuid: file://s0lNtRA0Z7ybTCWG
|
||||||
|
pageIndex: 1
|
||||||
|
replies: [ ]
|
||||||
|
text: test
|
||||||
|
author:
|
||||||
|
name: Adrien Payet
|
||||||
|
email: adrien.payet@outlook.com
|
||||||
|
uuid: user://WWjXgPWk
|
||||||
|
role: admin
|
||||||
|
date: 2024-11-06T16:19:29+01:00
|
||||||
|
id: m360ymc1
|
||||||
|
type: comment
|
||||||
|
isRead: false
|
||||||
|
position:
|
||||||
|
x: "148.03332519531"
|
||||||
|
y: 162
|
||||||
|
-
|
||||||
|
page:
|
||||||
|
uri: projects/miss-dior-blooming-bouquet
|
||||||
|
title: Miss Dior Blooming Bouquet
|
||||||
|
file:
|
||||||
|
uuid: file://s0lNtRA0Z7ybTCWG
|
||||||
|
pageIndex: 1
|
||||||
|
replies: [ ]
|
||||||
|
text: Nouveau commentaire positionné
|
||||||
|
author:
|
||||||
|
name: Adrien Payet
|
||||||
|
email: adrien.payet@outlook.com
|
||||||
|
uuid: user://WWjXgPWk
|
||||||
|
role: admin
|
||||||
|
date: 2024-11-06T16:33:11+01:00
|
||||||
|
id: m361g8sk
|
||||||
|
type: comment
|
||||||
|
isRead: false
|
||||||
|
position:
|
||||||
|
x: "215.03332519531"
|
||||||
|
y: 181
|
||||||
|
-
|
||||||
|
page:
|
||||||
|
uri: projects/miss-dior-blooming-bouquet
|
||||||
|
title: Miss Dior Blooming Bouquet
|
||||||
|
file:
|
||||||
|
uuid: file://s0lNtRA0Z7ybTCWG
|
||||||
|
pageIndex: 1
|
||||||
|
replies: [ ]
|
||||||
|
text: commentaire positionné
|
||||||
|
author:
|
||||||
|
name: Adrien Payet
|
||||||
|
email: adrien.payet@outlook.com
|
||||||
|
uuid: user://WWjXgPWk
|
||||||
|
role: admin
|
||||||
|
date: 2024-11-06T16:35:30+01:00
|
||||||
|
id: m361j842
|
||||||
|
type: comment
|
||||||
|
isRead: false
|
||||||
|
position:
|
||||||
|
x: '239.03332519531'
|
||||||
|
y: 74
|
||||||
|
|
@ -21,8 +21,8 @@ return [
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'filePageIndex' => $data->filePageIndex,
|
'filePageIndex' => $data->filePageIndex,
|
||||||
'position' => [
|
'position' => [
|
||||||
'x' => null,
|
'x' => $data->position->x,
|
||||||
'y' => null
|
'y' => $data->position->y
|
||||||
],
|
],
|
||||||
'replies' => [],
|
'replies' => [],
|
||||||
'text' => $data->text,
|
'text' => $data->text,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
v-if="!openedComment && !isAddOpen"
|
v-if="!openedComment && !isAddOpen"
|
||||||
id="create-comment"
|
id="create-comment"
|
||||||
class="btn btn--white-20 | w-full"
|
class="btn btn--white-20 | w-full"
|
||||||
@click="isAddOpen = true"
|
@click="toggleCommentPositionMode(true)"
|
||||||
>
|
>
|
||||||
Ajouter un commentaire
|
Ajouter un commentaire
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
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 { computed, ref } from "vue";
|
import { watch, ref } 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";
|
||||||
|
|
@ -120,19 +120,25 @@ const api = useApiStore();
|
||||||
|
|
||||||
const openedComment = ref(null);
|
const openedComment = ref(null);
|
||||||
|
|
||||||
|
const newCommentPageIndex = 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 emits = defineEmits(["update:file"]);
|
||||||
const sortedComments = computed(() => {
|
const sortedComments = ref(comments.reverse());
|
||||||
return comments.reverse();
|
const sortedReplies =
|
||||||
});
|
openedComment.value && openedComment.value.replies
|
||||||
const sortedReplies = computed(() => {
|
? ref(openedComment.value.replies.slice().reverse())
|
||||||
const sortedReplies =
|
: ref([]);
|
||||||
openedComment.value && openedComment.value.replies
|
|
||||||
? openedComment.value.replies.slice().reverse()
|
watch(
|
||||||
: [];
|
() => comments,
|
||||||
return sortedReplies;
|
(newVal) => {
|
||||||
});
|
sortedComments.value = newVal.reverse();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const viewContainer = document.querySelector(".vpv-pages-inner-container");
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
function handleSubmit(event) {
|
function handleSubmit(event) {
|
||||||
|
|
@ -140,11 +146,16 @@ function handleSubmit(event) {
|
||||||
const date = dayjs().format();
|
const date = dayjs().format();
|
||||||
const newComment = {
|
const newComment = {
|
||||||
pageUri: page.uri + "/client-brief",
|
pageUri: page.uri + "/client-brief",
|
||||||
filePageIndex: currentPageIndex,
|
filePageIndex: newCommentPageIndex.value,
|
||||||
fileName: file.name,
|
fileName: file.name,
|
||||||
userUuid: user.uuid,
|
userUuid: user.uuid,
|
||||||
text: newCommentText.value,
|
text: newCommentText.value,
|
||||||
date,
|
date,
|
||||||
|
position:
|
||||||
|
{
|
||||||
|
x: newCommentPosition.value.x,
|
||||||
|
y: newCommentPosition.value.y,
|
||||||
|
} ?? false,
|
||||||
id: uniqid(),
|
id: uniqid(),
|
||||||
};
|
};
|
||||||
if (openedComment.value) {
|
if (openedComment.value) {
|
||||||
|
|
@ -180,6 +191,42 @@ function changeFile(newFile) {
|
||||||
function closeComment() {
|
function closeComment() {
|
||||||
openedComment.value = null;
|
openedComment.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleCommentPositionMode(enable) {
|
||||||
|
if (enable) {
|
||||||
|
viewContainer.classList.add("waiting-comment");
|
||||||
|
viewContainer.addEventListener("click", handleCommentPositionClick);
|
||||||
|
} else {
|
||||||
|
viewContainer.classList.remove("waiting-comment");
|
||||||
|
viewContainer.removeEventListener("click", handleCommentPositionClick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCommentPositionClick(event) {
|
||||||
|
const pageContainer = event.target.closest(".page-inner-container");
|
||||||
|
|
||||||
|
const pageLabel = pageContainer
|
||||||
|
.closest(".vpv-page-inner-container")
|
||||||
|
.getAttribute("aria-label");
|
||||||
|
const pageIndex = pageLabel.charAt(pageLabel.length - 1);
|
||||||
|
|
||||||
|
newCommentPageIndex.value = parseInt(pageIndex);
|
||||||
|
|
||||||
|
const viewRect = viewContainer.getBoundingClientRect();
|
||||||
|
const pageRect = pageContainer.getBoundingClientRect();
|
||||||
|
const pageScroll = viewRect.top - pageRect.top;
|
||||||
|
|
||||||
|
const mouseTop = event.clientY;
|
||||||
|
const y = mouseTop - viewRect.top + pageScroll;
|
||||||
|
const x = event.clientX - pageRect.left;
|
||||||
|
|
||||||
|
newCommentPosition.value = {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
};
|
||||||
|
isAddOpen.value = true;
|
||||||
|
toggleCommentPositionMode(false);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -275,4 +322,10 @@ function closeComment() {
|
||||||
#comments-container form footer > * {
|
#comments-container form footer > * {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vpv-pages-inner-container.waiting-comment .page-inner-container,
|
||||||
|
.vpv-pages-inner-container.waiting-comment .vpv-text-layer-text,
|
||||||
|
.vpv-pages-inner-container.waiting-comment .vpv-text-layer-wrapper {
|
||||||
|
cursor: cell !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
data-icon="document"
|
data-icon="document"
|
||||||
></div>
|
></div>
|
||||||
</template>
|
</template>
|
||||||
|
<footer>2 commentaire(s)</footer>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue