comments panel : fix comments when active track is single file
This commit is contained in:
parent
41ae744d08
commit
037fad871a
2 changed files with 55 additions and 35 deletions
|
|
@ -104,19 +104,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
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, computed } 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";
|
import { storeToRefs } from 'pinia';
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
dayjs.locale("fr");
|
dayjs.locale('fr');
|
||||||
|
|
||||||
const { user } = useUserStore();
|
const { user } = useUserStore();
|
||||||
const { page } = usePageStore();
|
const { page } = usePageStore();
|
||||||
|
|
@ -145,20 +145,20 @@ watch(openedComment, (newVal) => {
|
||||||
watch(isAddOpen, (newVal) => {
|
watch(isAddOpen, (newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector("textarea#comment").focus();
|
document.querySelector('textarea#comment').focus();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const viewContainer =
|
const viewContainer =
|
||||||
openedFile.value.type === "document"
|
openedFile.value?.type === 'document'
|
||||||
? document.querySelector(".vpv-pages-inner-container")
|
? document.querySelector('.vpv-pages-inner-container')
|
||||||
: document.querySelector(".track");
|
: document.querySelector('.track');
|
||||||
|
|
||||||
window.addEventListener("keydown", (event) => {
|
window.addEventListener('keydown', (event) => {
|
||||||
if (
|
if (
|
||||||
isAddOpen.value &&
|
isAddOpen.value &&
|
||||||
event.key === "Enter" &&
|
event.key === 'Enter' &&
|
||||||
(event.metaKey || event.ctrlKey)
|
(event.metaKey || event.ctrlKey)
|
||||||
) {
|
) {
|
||||||
handleSubmit();
|
handleSubmit();
|
||||||
|
|
@ -167,9 +167,9 @@ window.addEventListener("keydown", (event) => {
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
function unhighlightAllComments() {
|
function unhighlightAllComments() {
|
||||||
document.querySelectorAll(".comment-marker.big").forEach((commentNode) => {
|
document.querySelectorAll('.comment-marker.big').forEach((commentNode) => {
|
||||||
commentNode.classList.remove("big");
|
commentNode.classList.remove('big');
|
||||||
commentNode.classList.remove("active");
|
commentNode.classList.remove('active');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ async function addComment(newComment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetDraftComment() {
|
function resetDraftComment() {
|
||||||
draftComment.value.text = "";
|
draftComment.value.text = '';
|
||||||
draftComment.value.position = null;
|
draftComment.value.position = null;
|
||||||
draftComment.value.padeIndex = null;
|
draftComment.value.padeIndex = null;
|
||||||
}
|
}
|
||||||
|
|
@ -248,17 +248,17 @@ function closeComment() {
|
||||||
function toggleCommentPositionMode(enable) {
|
function toggleCommentPositionMode(enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
waitingForCommentPosition.value = true;
|
waitingForCommentPosition.value = true;
|
||||||
viewContainer.classList.add("waiting-comment");
|
viewContainer.classList.add('waiting-comment');
|
||||||
viewContainer.addEventListener("click", handleCommentPositionClick);
|
viewContainer.addEventListener('click', handleCommentPositionClick);
|
||||||
} else {
|
} else {
|
||||||
waitingForCommentPosition.value = false;
|
waitingForCommentPosition.value = false;
|
||||||
viewContainer.classList.remove("waiting-comment");
|
viewContainer.classList.remove('waiting-comment');
|
||||||
viewContainer.removeEventListener("click", handleCommentPositionClick);
|
viewContainer.removeEventListener('click', handleCommentPositionClick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCommentPositionClick(event) {
|
function handleCommentPositionClick(event) {
|
||||||
if (openedFile.value.type === "document") {
|
if (openedFile.value.type === 'document') {
|
||||||
prepareDraftCommentInPdf(event);
|
prepareDraftCommentInPdf(event);
|
||||||
} else {
|
} else {
|
||||||
prepareDraftCommentInImage(event);
|
prepareDraftCommentInImage(event);
|
||||||
|
|
@ -268,12 +268,12 @@ function handleCommentPositionClick(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareDraftCommentInPdf(event) {
|
function prepareDraftCommentInPdf(event) {
|
||||||
const pageContainer = event.target.closest(".page-inner-container");
|
const pageContainer = event.target.closest('.page-inner-container');
|
||||||
if (!pageContainer || !viewContainer) return;
|
if (!pageContainer || !viewContainer) return;
|
||||||
|
|
||||||
const pageLabel = pageContainer
|
const pageLabel = pageContainer
|
||||||
.closest(".vpv-page-inner-container")
|
.closest('.vpv-page-inner-container')
|
||||||
.getAttribute("aria-label");
|
.getAttribute('aria-label');
|
||||||
const pageIndex = pageLabel.charAt(pageLabel.length - 1);
|
const pageIndex = pageLabel.charAt(pageLabel.length - 1);
|
||||||
|
|
||||||
const viewRect = viewContainer.getBoundingClientRect();
|
const viewRect = viewContainer.getBoundingClientRect();
|
||||||
|
|
@ -356,7 +356,7 @@ function showCorrespondingView() {
|
||||||
padding-right: 2rem;
|
padding-right: 2rem;
|
||||||
}
|
}
|
||||||
.comments.empty::after {
|
.comments.empty::after {
|
||||||
content: "Partagez vos idées en ajoutant des commentaires";
|
content: 'Partagez vos idées en ajoutant des commentaires';
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
|
|
@ -369,7 +369,7 @@ function showCorrespondingView() {
|
||||||
.comments.empty::before {
|
.comments.empty::before {
|
||||||
--icon-size: 1.25rem;
|
--icon-size: 1.25rem;
|
||||||
--icon-color: var(--color-white);
|
--icon-color: var(--color-white);
|
||||||
content: "";
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,8 @@ import { useDialogStore } from '../../../stores/dialog';
|
||||||
import { useVirtualSampleStore } from '../../../stores/virtualSample';
|
import { useVirtualSampleStore } from '../../../stores/virtualSample';
|
||||||
|
|
||||||
const { page } = storeToRefs(usePageStore());
|
const { page } = storeToRefs(usePageStore());
|
||||||
const { isCommentsOpen, isCommentPanelEnabled, activeTracks } = storeToRefs(
|
const { isCommentsOpen, isCommentPanelEnabled, activeTracks, openedFile } =
|
||||||
useDialogStore()
|
storeToRefs(useDialogStore());
|
||||||
);
|
|
||||||
|
|
||||||
const { isCompareModeEnabled } = storeToRefs(useVirtualSampleStore());
|
const { isCompareModeEnabled } = storeToRefs(useVirtualSampleStore());
|
||||||
|
|
||||||
|
|
@ -67,6 +66,27 @@ const tracks = computed(
|
||||||
.dynamic
|
.dynamic
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isSingleImage = computed(() => {
|
||||||
|
return (
|
||||||
|
activeTracks.value?.length === 1 &&
|
||||||
|
activeTracks.value[0]?.files.length === 1
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const singleFile = computed(() => {
|
||||||
|
return isSingleImage.value && activeTracks.value[0].files[0];
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
singleFile,
|
||||||
|
(newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
openedFile.value = singleFile;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
watch(isCompareModeEnabled, (newValue) => {
|
watch(isCompareModeEnabled, (newValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
isCommentsOpen.value = false;
|
isCommentsOpen.value = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue