diff --git a/data/mhje98b7-miyt4d.json b/data/mhje98b7-miyt4d.json index 65d7181..0a6b976 100644 --- a/data/mhje98b7-miyt4d.json +++ b/data/mhje98b7-miyt4d.json @@ -7,7 +7,12 @@ "text": "asdasd", "status": "free", "link": "https://asd" + }, + { + "id": "mhjhkpdr-doaihj", + "text": "вфывфыввввввввввв флывдфлоы длфоы двлофыдлв офдлыв", + "status": "free" } ], - "updatedAt": "2025-11-03T17:58:36.288Z" + "updatedAt": "2025-11-03T19:22:23.845Z" } \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-26-669Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-26-669Z.json deleted file mode 100644 index 925f0be..0000000 --- a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-26-669Z.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "mhje98b7-miyt4d", - "title": "Новый вишлист", - "items": [ - { - "id": "mhjegov5-ggd1mw", - "text": "фыв", - "status": "free", - "link": "https://tass.ru" - } - ], - "updatedAt": "2025-11-03T17:57:06.902Z" -} \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-28-547Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-28-547Z.json deleted file mode 100644 index a24dc50..0000000 --- a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-28-547Z.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id": "mhje98b7-miyt4d", - "title": "Новый вишлист", - "items": [ - { - "id": "mhjegov5-ggd1mw", - "text": "фыв", - "status": "free", - "link": "https://tass.ru" - }, - { - "id": "mhjg1eo3-dlj1kz", - "text": "asd", - "status": "free" - } - ], - "updatedAt": "2025-11-03T17:58:26.691Z" -} \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-32-751Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-32-751Z.json deleted file mode 100644 index be1fd5c..0000000 --- a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-32-751Z.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "id": "mhje98b7-miyt4d", - "title": "Новый вишлист", - "items": [], - "updatedAt": "2025-11-03T17:58:30.750Z" -} \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T18-32-53-277Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T18-32-53-277Z.json new file mode 100644 index 0000000..cf7d294 --- /dev/null +++ b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T18-32-53-277Z.json @@ -0,0 +1,15 @@ +{ + "id": "mhje98b7-miyt4d", + "title": "Новый вишлист", + "items": [ + { + "id": "mhjg1jch-1diytg", + "text": "asdasd", + "status": "taken", + "link": "https://asd", + "takenBy": "", + "takenAt": "2025-11-03T18:32:50.502Z" + } + ], + "updatedAt": "2025-11-03T18:32:50.502Z" +} \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-36-285Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T18-41-26-652Z.json similarity index 62% rename from data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-36-285Z.json rename to data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T18-41-26-652Z.json index db60529..759d31d 100644 --- a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T17-58-36-285Z.json +++ b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T18-41-26-652Z.json @@ -5,8 +5,9 @@ { "id": "mhjg1jch-1diytg", "text": "asdasd", - "status": "free" + "status": "free", + "link": "https://asd" } ], - "updatedAt": "2025-11-03T17:58:32.753Z" + "updatedAt": "2025-11-03T18:32:53.281Z" } \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T19-22-21-495Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T19-22-21-495Z.json new file mode 100644 index 0000000..1ed3465 --- /dev/null +++ b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T19-22-21-495Z.json @@ -0,0 +1,18 @@ +{ + "id": "mhje98b7-miyt4d", + "title": "Новый вишлист", + "items": [ + { + "id": "mhjg1jch-1diytg", + "text": "asdasd", + "status": "free", + "link": "https://asd" + }, + { + "id": "mhjhkpdr-doaihj", + "text": "вфывфыввввввввввв флывдфлоы длфоы двлофыдлв офдлыв", + "status": "free" + } + ], + "updatedAt": "2025-11-03T18:41:26.655Z" +} \ No newline at end of file diff --git a/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T19-22-23-841Z.json b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T19-22-23-841Z.json new file mode 100644 index 0000000..76b756c --- /dev/null +++ b/data/versions/mhje98b7-miyt4d/mhje98b7-miyt4d-2025-11-03T19-22-23-841Z.json @@ -0,0 +1,20 @@ +{ + "id": "mhje98b7-miyt4d", + "title": "Новый вишлист", + "items": [ + { + "id": "mhjg1jch-1diytg", + "text": "asdasd", + "status": "taken", + "link": "https://asd", + "takenBy": "", + "takenAt": "2025-11-03T19:22:21.499Z" + }, + { + "id": "mhjhkpdr-doaihj", + "text": "вфывфыввввввввввв флывдфлоы длфоы двлофыдлв офдлыв", + "status": "free" + } + ], + "updatedAt": "2025-11-03T19:22:21.499Z" +} \ No newline at end of file diff --git a/public/app.js b/public/app.js index ef58d17..f2f8e9b 100644 --- a/public/app.js +++ b/public/app.js @@ -407,14 +407,40 @@ const ui = { const topRow = document.createElement('div'); topRow.className = 'w-full flex items-center gap-2'; - const input = document.createElement('input'); - input.type = 'text'; + const input = document.createElement('textarea'); input.value = item.text || ''; - input.className = 'flex-1 min-w-0 px-2 py-1 rounded-md bg-white/70 dark:bg-slate-800/60 border border-transparent focus:border-brand focus:outline-none break-words font-medium'; - input.addEventListener('change', async () => { + input.className = 'item-name-input flex-1 min-w-0 px-2 py-1 rounded-md bg-white/70 dark:bg-slate-800/60 border border-transparent focus:border-brand focus:outline-none font-medium resize-none'; // Removed overflow-hidden + input.rows = 1; + input.addEventListener('input', () => { + input.style.height = 'auto'; + input.style.height = (input.scrollHeight) + 'px'; + }); + input.addEventListener('change', async (e) => { + e.stopPropagation(); // Prevent li click from firing await api.updateItem(this.state.currentId, item.id, { text: input.value }); await this.refresh(); }); + // Set initial height after content is set + setTimeout(() => { + input.style.height = 'auto'; + input.style.height = (input.scrollHeight) + 'px'; + }, 0); + + const deleteItemBtn = document.createElement('button'); + deleteItemBtn.className = 'px-3 py-1.5 rounded-md border border-red-300/80 text-red-700 hover:bg-red-50 dark:border-red-700/60 dark:text-red-300 dark:hover:bg-red-900/30 transition text-sm shrink-0'; + deleteItemBtn.textContent = '🗑️'; + deleteItemBtn.title = 'Удалить желание'; + deleteItemBtn.addEventListener('click', async (e) => { + e.stopPropagation(); // Prevent li click from firing + const ok = await ui.confirmDialog('Удалить желание', 'Вы уверены, что хотите удалить это желание?'); + if (!ok) return; + console.log('Attempting to delete item:', this.state.currentId, item.id); + await api.deleteItem(this.state.currentId, item.id); + await this.refresh(); + }); + + topRow.appendChild(input); + topRow.appendChild(deleteItemBtn); const badge = document.createElement('span'); const taken = item.status === 'taken'; @@ -424,7 +450,8 @@ const ui = { const actionBtn = document.createElement('button'); actionBtn.className = `px-3 py-1.5 rounded-md border shrink-0 ${taken?'border-slate-300/80 bg-slate-100 hover:bg-slate-200 dark:border-slate-600 dark:bg-slate-700 dark:hover:bg-slate-600':'border-transparent bg-brand text-white hover:bg-brand-600'} transition`; actionBtn.textContent = taken ? 'Освободить' : 'Взять'; - actionBtn.addEventListener('click', async () => { + actionBtn.addEventListener('click', async (e) => { + e.stopPropagation(); // Prevent li click from firing if (taken) { const ok = await ui.confirmDialog('Освободить пункт', 'Вы уверены? Это может освободить пункт, который забрали не вы.'); if (!ok) return; @@ -434,9 +461,11 @@ const ui = { await this.refresh(); }); - topRow.appendChild(input); - topRow.appendChild(badge); - topRow.appendChild(actionBtn); + // Новая строка для статуса и кнопки + const bottomRowControls = document.createElement('div'); + bottomRowControls.className = 'w-full flex items-center gap-2'; + bottomRowControls.appendChild(badge); + bottomRowControls.appendChild(actionBtn); // Нижняя строка: кнопки ссылок const bottomRow = document.createElement('div'); @@ -446,8 +475,9 @@ const ui = { linkBtn.className = item.link ? 'px-3 py-1.5 rounded-md border border-transparent bg-brand text-white hover:bg-brand-600 transition text-sm shrink-0' : 'px-3 py-1.5 rounded-md border border-slate-300/80 dark:border-slate-600 hover:bg-slate-50 dark:hover:bg-slate-800 transition text-sm shrink-0'; - linkBtn.textContent = item.link ? 'Открыть ссылку' : 'Добавить ссылку'; - linkBtn.addEventListener('click', async () => { + linkBtn.innerHTML = item.link ? 'Открыть ссылку' : 'Добавить ссылку'; + linkBtn.addEventListener('click', async (e) => { + e.stopPropagation(); // Prevent li click from firing if (item.link) { const url = api.normalizeLink(item.link); window.open(url, '_blank', 'noopener'); @@ -465,8 +495,9 @@ const ui = { if (item.link) { editLinkBtn = document.createElement('button'); editLinkBtn.className = 'px-3 py-1.5 rounded-md border border-slate-300/80 dark:border-slate-600 hover:bg-slate-50 dark:hover:bg-slate-800 transition text-sm shrink-0'; - editLinkBtn.textContent = 'Изменить ссылку'; - editLinkBtn.addEventListener('click', async () => { + editLinkBtn.innerHTML = 'Изменить ссылку'; + editLinkBtn.addEventListener('click', async (e) => { + e.stopPropagation(); // Prevent li click from firing const v = await ui.promptDialog('Изменить ссылку', 'URL (оставьте пустым чтобы удалить)', item.link || ''); if (v === null) return; const link = (v || '').trim(); @@ -478,21 +509,9 @@ const ui = { bottomRow.appendChild(linkBtn); if (editLinkBtn) bottomRow.appendChild(editLinkBtn); - const deleteItemBtn = document.createElement('button'); - deleteItemBtn.className = 'px-3 py-1.5 rounded-md border border-red-300/80 text-red-700 hover:bg-red-50 dark:border-red-700/60 dark:text-red-300 dark:hover:bg-red-900/30 transition text-sm shrink-0'; - deleteItemBtn.textContent = '🗑️'; - deleteItemBtn.title = 'Удалить желание'; - deleteItemBtn.addEventListener('click', async () => { - const ok = await ui.confirmDialog('Удалить желание', 'Вы уверены, что хотите удалить это желание?'); - if (!ok) return; - console.log('Attempting to delete item:', this.state.currentId, item.id); - await api.deleteItem(this.state.currentId, item.id); - await this.refresh(); - }); - bottomRow.appendChild(deleteItemBtn); - li.appendChild(topRow); li.appendChild(bottomRow); + li.appendChild(bottomRowControls); ul.appendChild(li); }); } diff --git a/public/index.html b/public/index.html index 730da7a..ff97381 100644 --- a/public/index.html +++ b/public/index.html @@ -10,7 +10,7 @@