From 2fde4710762c5541bb064e77d9dee2782996e40e Mon Sep 17 00:00:00 2001 From: poignatov Date: Wed, 18 Mar 2026 21:46:46 +0300 Subject: [PATCH] =?UTF-8?q?6.21.1:=20=D0=9C=D0=B5=D0=BD=D1=8E=20=D0=B4?= =?UTF-8?q?=D0=B5=D0=B9=D1=81=D1=82=D0=B2=D0=B8=D0=B9=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=B5=20=D0=B6=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- VERSION | 2 +- play-life-web/package.json | 2 +- play-life-web/src/components/WishlistForm.jsx | 130 +++++++++++++++++- 3 files changed, 129 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 7ecad14..476d3ce 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.21.0 +6.21.1 diff --git a/play-life-web/package.json b/play-life-web/package.json index f900406..607f7c8 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.21.0", + "version": "6.21.1", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/WishlistForm.jsx b/play-life-web/src/components/WishlistForm.jsx index 083dac5..a5b47f6 100644 --- a/play-life-web/src/components/WishlistForm.jsx +++ b/play-life-web/src/components/WishlistForm.jsx @@ -3,6 +3,7 @@ import { createPortal } from 'react-dom' import Cropper from 'react-easy-crop' import { useAuth } from './auth/AuthContext' import Toast from './Toast' +import './Wishlist.css' import './WishlistForm.css' // Извлекает первый URL из текста @@ -61,6 +62,10 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n const [imageUrlInput, setImageUrlInput] = useState('') // Ссылка на картинку для загрузки по URL const [loadingImageFromUrl, setLoadingImageFromUrl] = useState(false) const [newTaskConsumed, setNewTaskConsumed] = useState(false) // Флаг что newTaskId уже добавлен как цель + const [isDeleting, setIsDeleting] = useState(false) + const [isCopying, setIsCopying] = useState(false) + const [showActionMenu, setShowActionMenu] = useState(false) + const actionMenuHistoryRef = useRef(false) const fileInputRef = useRef(null) // Загрузка задач, проектов и саджестов групп @@ -677,6 +682,77 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n onNavigate?.('task-form', navParams) } + const openActionMenu = () => { + setShowActionMenu(true) + window.history.pushState({ actionMenu: true }, '') + actionMenuHistoryRef.current = true + } + + const closeActionMenu = () => { + setShowActionMenu(false) + if (actionMenuHistoryRef.current) { + actionMenuHistoryRef.current = false + window.history.back() + } + } + + // Обработка popstate для закрытия action menu кнопкой назад + useEffect(() => { + const handlePopState = () => { + if (showActionMenu) { + actionMenuHistoryRef.current = false + setShowActionMenu(false) + } + } + window.addEventListener('popstate', handlePopState) + return () => window.removeEventListener('popstate', handlePopState) + }, [showActionMenu]) + + const handleDelete = async () => { + if (!wishlistId) return + + setShowActionMenu(false) + if (actionMenuHistoryRef.current) { + actionMenuHistoryRef.current = false + window.history.go(-2) + } else { + window.history.back() + } + + setIsDeleting(true) + try { + const response = await authFetch(`${API_URL}/${wishlistId}`, { method: 'DELETE' }) + if (!response.ok) { + throw new Error('Ошибка при удалении') + } + } catch (err) { + console.error('Error deleting wishlist item:', err) + } + } + + const handleCopy = async () => { + if (!wishlistId) return + + setShowActionMenu(false) + if (actionMenuHistoryRef.current) { + actionMenuHistoryRef.current = false + window.history.go(-2) + } else { + window.history.back() + } + + setIsCopying(true) + try { + const response = await authFetch(`${API_URL}/${wishlistId}/copy`, { method: 'POST' }) + if (!response.ok) { + const errorText = await response.text().catch(() => '') + throw new Error(errorText || 'Ошибка при копировании') + } + } catch (err) { + console.error('Error copying wishlist item:', err) + } + } + const handleSubmit = async (e) => { e.preventDefault() setError('') @@ -1077,13 +1153,14 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n zIndex: 1500, display: 'flex', justifyContent: 'center', + gap: '0.75rem', }}> + {wishlistId && ( + + )} , document.body ) : null} + {showActionMenu && createPortal( +
+
e.stopPropagation()}> +
+

{name}

+
+
+ + +
+
+
, + document.body + )} ) }