This commit is contained in:
isUnknown 2025-02-19 17:36:51 +01:00
parent 12631cdec7
commit 710967f3cc
2 changed files with 66 additions and 40 deletions

View file

@ -7,6 +7,7 @@
class="btn btn--image" class="btn btn--image"
:aria-pressed="activeTracks.includes(track) ? true : false" :aria-pressed="activeTracks.includes(track) ? true : false"
:aria-controls="track.slug" :aria-controls="track.slug"
:id="track.slug"
:style="`--btn-image: url(${getFrontViewUrl(track)});`" :style="`--btn-image: url(${getFrontViewUrl(track)});`"
@click="selectTrack(track)" @click="selectTrack(track)"
:data-comments="getCommentsCount(track)" :data-comments="getCommentsCount(track)"
@ -48,12 +49,15 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, computed, watch } from 'vue'; import { ref, computed, watch, onMounted, onBeforeMount } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { usePageStore } from '../../../stores/page'; import { usePageStore } from '../../../stores/page';
import Interactive360 from './Interactive360.vue'; import Interactive360 from './Interactive360.vue';
import { useDialogStore } from '../../../stores/dialog'; import { useDialogStore } from '../../../stores/dialog';
import { useVirtualSampleStore } from '../../../stores/virtualSample'; import { useVirtualSampleStore } from '../../../stores/virtualSample';
import { useRoute } from 'vue-router';
const route = useRoute();
const { page } = storeToRefs(usePageStore()); const { page } = storeToRefs(usePageStore());
const { isCommentsOpen, isCommentPanelEnabled, activeTracks, openedFile } = const { isCommentsOpen, isCommentPanelEnabled, activeTracks, openedFile } =
@ -61,6 +65,24 @@ const { isCommentsOpen, isCommentPanelEnabled, activeTracks, openedFile } =
const { isCompareModeEnabled } = storeToRefs(useVirtualSampleStore()); const { isCompareModeEnabled } = storeToRefs(useVirtualSampleStore());
onBeforeMount(() => {
if (route.hash.length > 0) {
const trackToOpen = tracks.value.find(
(track) => track.slug === route.hash.substring(1)
);
activeTracks.value = [trackToOpen];
} else {
activeTracks.value = [tracks.value[0]];
}
});
onMounted(() => {
if (route.hash.length > 0) {
const targetBtn = document.querySelector(route.hash);
targetBtn.scrollIntoView();
}
});
const tracks = computed( const tracks = computed(
() => () =>
page.value.steps.find((step) => step.slug === 'virtual-sample').files page.value.steps.find((step) => step.slug === 'virtual-sample').files
@ -101,8 +123,6 @@ watch(isCompareModeEnabled, (newValue) => {
} }
}); });
activeTracks.value = [tracks.value[0]];
function getFrontViewUrl(track) { function getFrontViewUrl(track) {
if (track.files.length > 1) { if (track.files.length > 1) {
return track.files[7].url; return track.files[7].url;

View file

@ -53,52 +53,53 @@
</template> </template>
<script setup> <script setup>
import dayjs from "dayjs"; import dayjs from 'dayjs';
import "dayjs/locale/fr"; import 'dayjs/locale/fr';
import Tabs from "../components/Tabs.vue"; import slugify from 'slugify';
import { useUserStore } from "../stores/user"; import Tabs from '../components/Tabs.vue';
import { ref, computed } from "vue"; import { useUserStore } from '../stores/user';
import { storeToRefs } from "pinia"; import { ref, computed } from 'vue';
import { useApiStore } from "../stores/api"; import { storeToRefs } from 'pinia';
import Comment from "../components/notifications/Comment.vue"; import { useApiStore } from '../stores/api';
import Reply from "../components/notifications/Reply.vue"; import Comment from '../components/notifications/Comment.vue';
import Content from "../components/notifications/Content.vue"; import Reply from '../components/notifications/Reply.vue';
import { useRouter } from "vue-router"; import Content from '../components/notifications/Content.vue';
import ProjectRequest from "../components/notifications/ProjectRequest.vue"; import { useRouter } from 'vue-router';
import AppointmentRequest from "../components/notifications/AppointmentRequest.vue"; import ProjectRequest from '../components/notifications/ProjectRequest.vue';
import AppointmentRequest from '../components/notifications/AppointmentRequest.vue';
dayjs.locale("fr"); dayjs.locale('fr');
const userStore = useUserStore(); const userStore = useUserStore();
const router = useRouter(); const router = useRouter();
const { notifications } = storeToRefs(useUserStore()); const { notifications } = storeToRefs(useUserStore());
const api = useApiStore(); const api = useApiStore();
const currentTab = ref("all"); const currentTab = ref('all');
const tabs = computed(() => { const tabs = computed(() => {
return [ return [
{ {
label: "Tout", label: 'Tout',
id: "all", id: 'all',
icon: null, icon: null,
count: null, count: null,
isActive: currentTab.value === "all", isActive: currentTab.value === 'all',
}, },
{ {
label: "Non lu", label: 'Non lu',
id: "unread", id: 'unread',
icon: null, icon: null,
count: null, count: null,
isActive: currentTab.value === "unread", isActive: currentTab.value === 'unread',
}, },
]; ];
}); });
const notificationComponents = { const notificationComponents = {
comment: Comment, comment: Comment,
"comment-reply": Reply, 'comment-reply': Reply,
content: Content, content: Content,
"project-request": ProjectRequest, 'project-request': ProjectRequest,
"appointment-request": AppointmentRequest, 'appointment-request': AppointmentRequest,
}; };
const sortedNotifications = computed(() => { const sortedNotifications = computed(() => {
@ -106,9 +107,9 @@ const sortedNotifications = computed(() => {
return dayjs(b.date).diff(dayjs(a.date)); return dayjs(b.date).diff(dayjs(a.date));
}); });
if (currentTab.value === "unread") { if (currentTab.value === 'unread') {
return sortedNotifications.filter( return sortedNotifications.filter(
(notification) => notification.isread !== "true" (notification) => notification.isread !== 'true'
); );
} }
return sortedNotifications; return sortedNotifications;
@ -122,19 +123,19 @@ function readAll() {
try { try {
api.readAllNotifications(); api.readAllNotifications();
} catch (error) { } catch (error) {
console.log("Could not read all notifications : ", error); console.log('Could not read all notifications : ', error);
} }
} }
// Functions // Functions
function handleNotificationClick(notification) { function handleNotificationClick(notification) {
const href = const href =
notification.type === "appointment-request" notification.type === 'appointment-request'
? getHref(notification) + "?tab=designToLight" ? getHref(notification) + '?tab=designToLight'
: getHref(notification); : getHref(notification);
if (href.startsWith("http")) { if (href.startsWith('http')) {
window.open(href, "_blank"); window.open(href, '_blank');
} else { } else {
router.push(href); router.push(href);
} }
@ -143,15 +144,20 @@ function getHref(notification) {
const uri = notification.location.page.uri; const uri = notification.location.page.uri;
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';
} }
if (notification.location.page.template === "track") { if (notification.location.page.template === 'track') {
return notification.project.uri + "?dialog=virtual-sample&comments=true"; const anchor = notification.location.page.title
? '#' + slugify(notification?.location?.page?.title, { lower: true })
: '';
return (
notification.project.uri + '?dialog=virtual-sample&comments=true' + anchor
);
} }
if (notification.location.page.panelurl) { if (notification.location.page.panelurl) {
@ -170,7 +176,7 @@ main {
main > header { main > header {
flex-wrap: nowrap; flex-wrap: nowrap;
} }
main > header [role="tablist"] { main > header [role='tablist'] {
margin-left: 0; margin-left: 0;
} }
</style> </style>