feat: add edit button for ICS subscriptions (#100)

Adds a pencil-icon edit button to each ICS subscription row. Clicking it
opens a modal to update name, color, and shared visibility via PATCH
/calendar/subscriptions/:id. Adds updatedToast i18n key to all 15 locales.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ulas Kalayci
2026-04-29 10:37:16 +02:00
parent f9b796ca13
commit 06adc0f3f5
16 changed files with 104 additions and 30 deletions
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "خاص",
"shared": "مشترك"
}
},
"updatedToast": "تم تحديث الاشتراك."
},
"memberPhoneLabel": "رقم الهاتف (اختياري)",
"memberEmailLabel": "البريد الإلكتروني (اختياري)",
+2 -1
View File
@@ -757,7 +757,8 @@
"empty": "Noch keine Abonnements.",
"addedToast": "Abonnement hinzugefügt.",
"syncedToast": "Abonnement synchronisiert.",
"deletedToast": "Abonnement gelöscht."
"deletedToast": "Abonnement gelöscht.",
"updatedToast": "Abonnement aktualisiert."
},
"memberPhoneLabel": "Telefonnummer (optional)",
"memberEmailLabel": "E-Mail (optional)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Ιδιωτικό",
"shared": "Κοινόχρηστο"
}
},
"updatedToast": "Η συνδρομή ενημερώθηκε."
},
"memberPhoneLabel": "Αριθμός τηλεφώνου (προαιρετικό)",
"memberEmailLabel": "Email (προαιρετικό)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Private",
"shared": "Shared"
}
},
"updatedToast": "Subscription updated."
},
"memberPhoneLabel": "Phone number (optional)",
"memberEmailLabel": "Email (optional)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Privado",
"shared": "Compartido"
}
},
"updatedToast": "Suscripción actualizada."
},
"memberPhoneLabel": "Número de teléfono (opcional)",
"memberEmailLabel": "Correo electrónico (opcional)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Privé",
"shared": "Partagé"
}
},
"updatedToast": "Abonnement mis à jour."
},
"memberPhoneLabel": "Numéro de téléphone (facultatif)",
"memberEmailLabel": "E-mail (facultatif)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "निजी",
"shared": "साझा"
}
},
"updatedToast": "सदस्यता अपडेट की गई।"
},
"memberPhoneLabel": "फ़ोन नंबर (वैकल्पिक)",
"memberEmailLabel": "ईमेल (वैकल्पिक)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Privato",
"shared": "Condiviso"
}
},
"updatedToast": "Abbonamento aggiornato."
},
"memberPhoneLabel": "Numero di telefono (opzionale)",
"memberEmailLabel": "E-mail (opzionale)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "プライベート",
"shared": "共有"
}
},
"updatedToast": "サブスクリプションが更新されました。"
},
"memberPhoneLabel": "電話番号(任意)",
"memberEmailLabel": "メールアドレス(任意)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Privado",
"shared": "Partilhado"
}
},
"updatedToast": "Subscrição atualizada."
},
"memberPhoneLabel": "Telefone (opcional)",
"memberEmailLabel": "E-mail (opcional)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Личное",
"shared": "Общее"
}
},
"updatedToast": "Подписка обновлена."
},
"memberPhoneLabel": "Номер телефона (необязательно)",
"memberEmailLabel": "Электронная почта (необязательно)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Privat",
"shared": "Delad"
}
},
"updatedToast": "Prenumeration uppdaterad."
},
"memberPhoneLabel": "Telefonnummer (valfritt)",
"memberEmailLabel": "E-post (valfritt)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Özel",
"shared": "Paylaşımlı"
}
},
"updatedToast": "Abonelik güncellendi."
},
"memberPhoneLabel": "Telefon numarası (isteğe bağlı)",
"memberEmailLabel": "E-posta (isteğe bağlı)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "Приватне",
"shared": "Спільне"
}
},
"updatedToast": "Підписку оновлено."
},
"memberPhoneLabel": "Номер телефону (необов'язково)",
"memberEmailLabel": "Електронна пошта (необов'язково)",
+2 -1
View File
@@ -732,7 +732,8 @@
"badges": {
"private": "私人",
"shared": "共享"
}
},
"updatedToast": "订阅已更新。"
},
"memberPhoneLabel": "电话号码(可选)",
"memberEmailLabel": "电子邮件(可选)",
+59
View File
@@ -1644,6 +1644,19 @@ function renderIcsList(container, subs, user) {
syncBtn.appendChild(syncIcon);
actions.appendChild(syncBtn);
const editBtn = document.createElement('button');
editBtn.className = 'btn btn--icon btn--ghost';
editBtn.title = t('settings.ics.actions.edit');
editBtn.setAttribute('aria-label', t('settings.ics.actions.edit'));
editBtn.dataset.action = 'ics-edit';
editBtn.dataset.id = sub.id;
const editIcon = document.createElement('i');
editIcon.setAttribute('data-lucide', 'pencil');
editIcon.style.cssText = 'width:14px;height:14px';
editIcon.setAttribute('aria-hidden', 'true');
editBtn.appendChild(editIcon);
actions.appendChild(editBtn);
const delBtn = document.createElement('button');
delBtn.className = 'btn btn--icon btn--danger-outline';
delBtn.title = t('settings.ics.actions.delete');
@@ -1756,6 +1769,52 @@ function bindIcsEvents(container, user, initialSubs) {
}
}
if (action === 'ics-edit') {
const sub = subs.find((s) => s.id === id);
if (!sub) return;
openModal({
title: t('settings.ics.actions.edit'),
size: 'sm',
content: `
<form id="ics-edit-form" class="settings-form">
<div class="form-group">
<label class="form-label" for="ics-edit-name">${t('settings.ics.form.name')}</label>
<input class="form-input" type="text" id="ics-edit-name" value="${esc(sub.name)}" required maxlength="100" />
</div>
<div class="settings-name-color-row">
<div class="form-group settings-color-field">
<label class="form-label" for="ics-edit-color">${t('settings.ics.form.color')}</label>
<input class="settings-color-button" type="color" id="ics-edit-color" value="${esc(sub.color || '#3b82f6')}" />
</div>
<div class="form-group" style="display:flex;align-items:center;gap:var(--space-2);padding-top:var(--space-5)">
<input type="checkbox" id="ics-edit-shared" ${sub.shared ? 'checked' : ''} />
<label class="form-label" for="ics-edit-shared" style="margin:0">${t('settings.ics.form.shared')}</label>
</div>
</div>
<p id="ics-edit-error" class="form-error" hidden></p>
</form>
`,
onSave: async (modalEl, close) => {
const name = modalEl.querySelector('#ics-edit-name').value.trim();
const color = modalEl.querySelector('#ics-edit-color').value;
const shared = modalEl.querySelector('#ics-edit-shared').checked ? 1 : 0;
const errEl = modalEl.querySelector('#ics-edit-error');
errEl.hidden = true;
try {
const res = await api.patch(`/calendar/subscriptions/${id}`, { name, color, shared });
const idx = subs.findIndex((s) => s.id === id);
if (idx >= 0) subs[idx] = res.data;
renderIcsList(container, subs, user);
window.oikos?.showToast(t('settings.ics.updatedToast'), 'success');
close();
} catch (err) {
errEl.textContent = err.message ?? t('common.errorGeneric');
errEl.hidden = false;
}
},
});
}
if (action === 'ics-delete') {
const name = target.dataset.name;
if (!await confirmModal(t('settings.ics.confirm_delete'), { danger: true, confirmLabel: t('common.delete') })) return;