Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion data/mhje98b7-miyt4d.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
69 changes: 44 additions & 25 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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();
Expand All @@ -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);
});
}
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, Noto Sans, "Apple Color Emoji", "Segoe UI Emoji"; }
.container-max { max-width: 1100px; }
.container-max { max-width: 768px; }
</style>
<meta name="theme-color" content="#0ea5e9" />
<meta name="color-scheme" content="light dark">
Expand Down
Loading