diff --git a/apps/admin-panel/src/views/apps/product/VariantRowEditor.vue b/apps/admin-panel/src/views/apps/product/VariantRowEditor.vue index 7fb9b151..fc8192cf 100644 --- a/apps/admin-panel/src/views/apps/product/VariantRowEditor.vue +++ b/apps/admin-panel/src/views/apps/product/VariantRowEditor.vue @@ -7,7 +7,7 @@ :aria-label="mode === 'create' ? 'افزودن تنوع جدید' : 'ویرایش تنوع'" @keydown="onKeydown" > - +
@@ -61,7 +60,7 @@ :min="0" :step="50000" addon-after="ریال" - placeholder="نداشت: صفر" + placeholder="اختیاری" :formatter="formatThousands" :parser="parseThousands" /> diff --git a/apps/admin-panel/src/views/apps/product/variant.ts b/apps/admin-panel/src/views/apps/product/variant.ts index c838206b..38e97f84 100644 --- a/apps/admin-panel/src/views/apps/product/variant.ts +++ b/apps/admin-panel/src/views/apps/product/variant.ts @@ -111,7 +111,7 @@ export function validateVariant(v: VariantRow): VariantErrors { else if (Number(v.grams) <= 0) e.grams = 'وزن باید بیشتر از صفر باشد'; if (!isBlank(v.qty) && Number(v.qty) < 0) e.qty = 'تعداد منفی نمی‌شود'; if (isBlank(v.percentage_pay)) e.percentage_pay = 'اجرت درصدی را وارد کنید'; - if (isBlank(v.rial_pay)) e.rial_pay = 'اجرت ریالی را وارد کنید؛ اگر ندارد صفر بزنید'; + if (!isBlank(v.rial_pay) && Number(v.rial_pay) < 0) e.rial_pay = 'اجرت ریالی منفی نمی‌شود'; return e; } diff --git a/apps/user-app-v2/src/assets/img/Vector.svg b/apps/user-app-v2/src/assets/img/Vector.svg deleted file mode 100644 index 733693aa..00000000 --- a/apps/user-app-v2/src/assets/img/Vector.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apps/user-app-v2/src/components/home/ProductCarousel.vue b/apps/user-app-v2/src/components/home/ProductCarousel.vue index 2a877033..c34ee9d6 100644 --- a/apps/user-app-v2/src/components/home/ProductCarousel.vue +++ b/apps/user-app-v2/src/components/home/ProductCarousel.vue @@ -69,6 +69,13 @@ const dragging = ref(false) const drag = ref(0) let startX = 0 let pointerId: number | null = null +// The cell under the finger at pointerdown. Pointer capture retargets +// pointerup (and therefore click) onto the stage, so the card's own click +// never runs — a tap has to be resolved from this index instead. +let pressedIndex: number | null = null +// Set when pointerup already handled the tap, so a click that does arrive +// afterwards does not open the product a second time. +let tapHandled = false const SWIPE_THRESHOLD = 46 @@ -153,12 +160,23 @@ function prev() { go(index.value - 1) } +function indexFromEvent(e: Event): number | null { + const target = e.target + if (!(target instanceof Element) || !stage.value) return null + const cell = target.closest('.reel__cell') + if (!cell) return null + const i = [...stage.value.querySelectorAll('.reel__cell')].indexOf(cell) + return i >= 0 ? i : null +} + function onDown(e: PointerEvent) { if (count.value < 2) return dragging.value = true startX = e.clientX drag.value = 0 pointerId = e.pointerId + pressedIndex = indexFromEvent(e) + tapHandled = false ;(e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId) } @@ -171,33 +189,57 @@ function onMove(e: PointerEvent) { function onUp(e: PointerEvent) { if (!dragging.value) return const moved = e.clientX - startX + const pressed = pressedIndex dragging.value = false drag.value = 0 pointerId = null + pressedIndex = null // RTL: dragging right pushes the stack toward the previous card. - if (moved > SWIPE_THRESHOLD) prev() - else if (moved < -SWIPE_THRESHOLD) next() + if (moved > SWIPE_THRESHOLD) { + prev() + return + } + if (moved < -SWIPE_THRESHOLD) { + next() + return + } + + // A tap. Pointer capture delivers this pointerup to the stage, so the + // card's click listener never runs; the cell recorded on pointerdown is + // what was actually tapped. + tapHandled = true + activate(pressed) } -// A tap on a side card centres it instead of opening it, and a tap that ended -// a drag does neither. -function onOpen(i: number, product: ProductSummary) { - if (Math.abs(drag.value) > 1) return +// A tap on a side card centres it instead of opening it. The centred card +// opens, and the trailing tile goes to the full newest-products list. +function activate(i: number | null) { + if (i == null) return + const slot = slots.value[i] + if (!slot) return if (i !== index.value) { go(i) return } - emit('open', product) + if (slot.kind === 'product' && slot.product) emit('open', slot.product) + else emit('all') +} + +function onOpen(i: number, _product: ProductSummary) { + if (tapHandled) { + tapHandled = false + return + } + activate(i) } function onAll(i: number) { - if (Math.abs(drag.value) > 1) return - if (i !== index.value) { - go(i) + if (tapHandled) { + tapHandled = false return } - emit('all') + activate(i) } diff --git a/apps/user-app-v2/src/components/home/ProductPanel.vue b/apps/user-app-v2/src/components/home/ProductPanel.vue index 55496c55..a7415b6c 100644 --- a/apps/user-app-v2/src/components/home/ProductPanel.vue +++ b/apps/user-app-v2/src/components/home/ProductPanel.vue @@ -82,14 +82,30 @@ function format(v: number) { display: block; } +// The stand-in is the brand mark, not a photo, so it stays a mark in the +// middle of the frame instead of filling the slot the piece will occupy. +.panel__art img[lazy='loading'], +.panel__art img[lazy='error'] { + max-width: 62%; + max-height: 52%; +} + // Dark mode: product photos are shot on white, so they sit on a light mat // instead of showing as white boxes on a dark card (@photoMat — transparent, -// i.e. no change, in light mode). +// i.e. no change, in light mode). The brand mark that stands in while a photo +// loads is black line art, so it stays on the card and is drawn light, the +// same way the header logo is. html.theme-dark .panel__art img { background: @photoMat; border-radius: 12px; } +html.theme-dark .panel__art img[lazy='loading'], +html.theme-dark .panel__art img[lazy='error'] { + background: transparent; + filter: invert(1); +} + .panel__title { margin: 14px 0 0; font-size: 14px; diff --git a/apps/user-app-v2/src/components/product/CartItem.vue b/apps/user-app-v2/src/components/product/CartItem.vue index 7e3fa535..f6416561 100644 --- a/apps/user-app-v2/src/components/product/CartItem.vue +++ b/apps/user-app-v2/src/components/product/CartItem.vue @@ -11,8 +11,8 @@ field existed; that was wrong, and the customer was charged a figure the cart never showed. - All cart behaviour is unchanged: quantity increment/decrement, remove at - qty 1, and the note affordance that opens the parent's drawer. + All cart behaviour for a line: it is one piece, so the row can be removed, + noted, or moved to buy-later. There is no quantity. -->