feat(trash): Settings retention field (trash_retention_days, 0=keep forever)
This commit is contained in:
@@ -16,6 +16,9 @@ const savingTimezone = ref(false);
|
||||
const timezoneSaved = ref(false);
|
||||
const autoConsolidateTasks = ref(true);
|
||||
const savingAutoConsolidate = ref(false);
|
||||
const trashRetentionDays = ref("90");
|
||||
const savingRetention = ref(false);
|
||||
const retentionSaved = ref(false);
|
||||
|
||||
async function saveAutoConsolidate() {
|
||||
savingAutoConsolidate.value = true;
|
||||
@@ -52,6 +55,22 @@ async function saveTimezone() {
|
||||
savingTimezone.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveRetention() {
|
||||
const n = Math.max(0, Math.floor(Number(trashRetentionDays.value) || 0));
|
||||
trashRetentionDays.value = String(n);
|
||||
savingRetention.value = true;
|
||||
retentionSaved.value = false;
|
||||
try {
|
||||
await apiPut('/api/settings', { trash_retention_days: String(n) });
|
||||
retentionSaved.value = true;
|
||||
setTimeout(() => (retentionSaved.value = false), 2000);
|
||||
} catch {
|
||||
toastStore.show('Failed to save retention setting', 'error');
|
||||
} finally {
|
||||
savingRetention.value = false;
|
||||
}
|
||||
}
|
||||
const newEmail = ref("");
|
||||
const emailPassword = ref("");
|
||||
const changingEmail = ref(false);
|
||||
@@ -383,6 +402,7 @@ onMounted(async () => {
|
||||
// Load notification preferences from user settings
|
||||
const allSettings = await apiGet<Record<string, string>>("/api/settings");
|
||||
userTimezone.value = allSettings.user_timezone ?? "";
|
||||
trashRetentionDays.value = allSettings.trash_retention_days ?? "90";
|
||||
// Default true if unset; explicit "false" disables auto-consolidation.
|
||||
autoConsolidateTasks.value = (allSettings.auto_consolidate_tasks ?? "true") !== "false";
|
||||
if (allSettings.notify_task_reminders !== undefined) {
|
||||
@@ -1021,6 +1041,31 @@ function formatUserDate(iso: string): string {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Trash retention -->
|
||||
<section class="settings-section full-width">
|
||||
<h2>Trash retention</h2>
|
||||
<p class="section-desc">Deleted items move to <router-link to="/trash">Trash</router-link> and can be restored. They're permanently purged after this many days.</p>
|
||||
<div class="field">
|
||||
<label for="trash-retention">Retention period (days)</label>
|
||||
<input
|
||||
id="trash-retention"
|
||||
v-model="trashRetentionDays"
|
||||
type="number"
|
||||
min="0"
|
||||
step="1"
|
||||
class="input"
|
||||
style="max-width: 8rem"
|
||||
/>
|
||||
<p class="field-hint">Set to <strong>0</strong> to keep deleted items forever (never auto-purge).</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn-save" @click="saveRetention" :disabled="savingRetention">
|
||||
{{ savingRetention ? 'Saving…' : 'Save' }}
|
||||
</button>
|
||||
<span v-if="retentionSaved" class="saved-msg">Saved!</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ── Account ── -->
|
||||
|
||||
Reference in New Issue
Block a user