diff --git a/ui/src/pages/ProductStockByAttributes.vue b/ui/src/pages/ProductStockByAttributes.vue index 9eecdc1..700fd30 100644 --- a/ui/src/pages/ProductStockByAttributes.vue +++ b/ui/src/pages/ProductStockByAttributes.vue @@ -253,7 +253,7 @@ - +
Urun Karti
@@ -275,6 +275,7 @@ arrows height="100%" class="product-card-carousel rounded-borders" + @update:model-value="onProductCardSlideChange" >
- +
Urun Fotografi
@@ -665,6 +666,43 @@ function sortImagesForDisplay(list) { return Array.isArray(list) ? [...list] : [] } +function getHashRouteParts() { + if (typeof window === 'undefined') return { path: '', params: new URLSearchParams() } + const rawHash = String(window.location.hash || '') + const hashBody = rawHash.startsWith('#') ? rawHash.slice(1) : rawHash + const qPos = hashBody.indexOf('?') + const path = qPos >= 0 ? hashBody.slice(0, qPos) : hashBody + const query = qPos >= 0 ? hashBody.slice(qPos + 1) : '' + return { path, params: new URLSearchParams(query) } +} + +function replaceHashRouteQuery(key, value) { + if (typeof window === 'undefined') return + const { path, params } = getHashRouteParts() + if (!path) return + if (value === null || value === undefined || String(value).trim() === '') params.delete(key) + else params.set(key, String(value).trim()) + const nextQuery = params.toString() + const nextHash = `#${path}${nextQuery ? `?${nextQuery}` : ''}` + if (window.location.hash === nextHash) return + window.history.replaceState(null, '', `${window.location.pathname}${window.location.search}${nextHash}`) +} + +function getGalleryQueryIndex() { + const { params } = getHashRouteParts() + const n = Number(params.get('g') || 1) + if (!Number.isFinite(n) || n < 1) return 0 + return n - 1 +} + +function setGalleryQueryIndex(index) { + replaceHashRouteQuery('g', Math.max(1, Number(index || 0) + 1)) +} + +function clearGalleryQueryIndex() { + replaceHashRouteQuery('g', null) +} + async function resolveProductImageUrlForCarousel(item) { const resolved = resolveProductImageUrl(item) const contentUrl = String(resolved.contentUrl || '').trim() @@ -1320,7 +1358,8 @@ async function openProductCard(grp1, grp2) { } productCardImages.value = uniqueImages - productCardSlide.value = 0 + productCardSlide.value = Math.min(Math.max(getGalleryQueryIndex(), 0), Math.max(uniqueImages.length - 1, 0)) + setGalleryQueryIndex(productCardSlide.value) productCardData.value = { productCode, colorCode, @@ -1345,6 +1384,7 @@ function openProductImageFullscreen(src) { productImageFullscreenSrc.value = value const idx = Math.max(0, fullscreenImages.value.findIndex((x) => String(x || '').trim() === value)) productImageFullscreenSlide.value = idx + setGalleryQueryIndex(idx) productImageFullscreenZoom.value = 1 productImageFullscreenOffsetX.value = 0 productImageFullscreenOffsetY.value = 0 @@ -1403,12 +1443,26 @@ function onFullscreenMouseUp() { } function onFullscreenSlideChange() { + setGalleryQueryIndex(productImageFullscreenSlide.value) productImageFullscreenZoom.value = 1 productImageFullscreenOffsetX.value = 0 productImageFullscreenOffsetY.value = 0 productImageFullscreenDragging.value = false } +function onProductCardSlideChange() { + setGalleryQueryIndex(productCardSlide.value) +} + +function onProductCardDialogHide() { + productImageFullscreenDialog.value = false + clearGalleryQueryIndex() +} + +function onFullscreenDialogHide() { + onFullscreenMouseUp() +} + function resetForm() { filters.value = createEmptyFilters() rawRows.value = [] diff --git a/ui/src/pages/ProductStockQuery.vue b/ui/src/pages/ProductStockQuery.vue index 7f68dcf..9f1249c 100644 --- a/ui/src/pages/ProductStockQuery.vue +++ b/ui/src/pages/ProductStockQuery.vue @@ -238,7 +238,7 @@ - +
Urun Karti
@@ -260,6 +260,7 @@ arrows height="100%" class="product-card-carousel rounded-borders" + @update:model-value="onProductCardSlideChange" >
- +
Urun Fotografi
@@ -644,6 +645,43 @@ function sortImagesForDisplay(list) { return Array.isArray(list) ? [...list] : [] } +function getHashRouteParts() { + if (typeof window === 'undefined') return { path: '', params: new URLSearchParams() } + const rawHash = String(window.location.hash || '') + const hashBody = rawHash.startsWith('#') ? rawHash.slice(1) : rawHash + const qPos = hashBody.indexOf('?') + const path = qPos >= 0 ? hashBody.slice(0, qPos) : hashBody + const query = qPos >= 0 ? hashBody.slice(qPos + 1) : '' + return { path, params: new URLSearchParams(query) } +} + +function replaceHashRouteQuery(key, value) { + if (typeof window === 'undefined') return + const { path, params } = getHashRouteParts() + if (!path) return + if (value === null || value === undefined || String(value).trim() === '') params.delete(key) + else params.set(key, String(value).trim()) + const nextQuery = params.toString() + const nextHash = `#${path}${nextQuery ? `?${nextQuery}` : ''}` + if (window.location.hash === nextHash) return + window.history.replaceState(null, '', `${window.location.pathname}${window.location.search}${nextHash}`) +} + +function getGalleryQueryIndex() { + const { params } = getHashRouteParts() + const n = Number(params.get('g') || 1) + if (!Number.isFinite(n) || n < 1) return 0 + return n - 1 +} + +function setGalleryQueryIndex(index) { + replaceHashRouteQuery('g', Math.max(1, Number(index || 0) + 1)) +} + +function clearGalleryQueryIndex() { + replaceHashRouteQuery('g', null) +} + async function resolveProductImageUrlForCarousel(item) { const resolved = resolveProductImageUrl(item) const contentUrl = String(resolved.contentUrl || '').trim() @@ -1130,7 +1168,8 @@ async function openProductCard(grp1, grp2) { } productCardImages.value = uniqueImages - productCardSlide.value = 0 + productCardSlide.value = Math.min(Math.max(getGalleryQueryIndex(), 0), Math.max(uniqueImages.length - 1, 0)) + setGalleryQueryIndex(productCardSlide.value) productCardData.value = { productCode, colorCode, @@ -1155,6 +1194,7 @@ function openProductImageFullscreen(src) { productImageFullscreenSrc.value = value const idx = Math.max(0, fullscreenImages.value.findIndex((x) => String(x || '').trim() === value)) productImageFullscreenSlide.value = idx + setGalleryQueryIndex(idx) productImageFullscreenZoom.value = 1 productImageFullscreenOffsetX.value = 0 productImageFullscreenOffsetY.value = 0 @@ -1213,12 +1253,26 @@ function onFullscreenMouseUp() { } function onFullscreenSlideChange() { + setGalleryQueryIndex(productImageFullscreenSlide.value) productImageFullscreenZoom.value = 1 productImageFullscreenOffsetX.value = 0 productImageFullscreenOffsetY.value = 0 productImageFullscreenDragging.value = false } +function onProductCardSlideChange() { + setGalleryQueryIndex(productCardSlide.value) +} + +function onProductCardDialogHide() { + productImageFullscreenDialog.value = false + clearGalleryQueryIndex() +} + +function onFullscreenDialogHide() { + onFullscreenMouseUp() +} + function resetForm() { selectedProductCode.value = '' rawRows.value = []