mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-13 20:57:24 +01:00
Added clear completed todos (#9782)
This commit is contained in:
33
website/client/components/tasks/clearCompletedTodos.vue
Normal file
33
website/client/components/tasks/clearCompletedTodos.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<template lang="pug">
|
||||||
|
.text-center.delete-completed
|
||||||
|
.help-text {{ $t('clearCompletedDescription') }}
|
||||||
|
.btn.btn-danger(@click='clearTodos()') {{ $t('clearCompleted') }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.delete-completed {
|
||||||
|
padding: 1em;
|
||||||
|
|
||||||
|
.help-text {
|
||||||
|
color: #878190;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-danger {
|
||||||
|
font-size: 12px;
|
||||||
|
padding: .4em .6em;
|
||||||
|
margin-top: .5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
clearTodos () {
|
||||||
|
if (!confirm(this.$t('clearCompletedConfirm'))) return;
|
||||||
|
this.$store.dispatch('tasks:clearCompletedTodos');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
)
|
)
|
||||||
transition(name="quick-add-tip-slide")
|
transition(name="quick-add-tip-slide")
|
||||||
.quick-add-tip.small-text(v-show="quickAddFocused", v-html="$t('addMultipleTip')")
|
.quick-add-tip.small-text(v-show="quickAddFocused", v-html="$t('addMultipleTip')")
|
||||||
|
clear-completed-todos(v-if="activeFilters[type].label === 'complete2'")
|
||||||
.column-background(
|
.column-background(
|
||||||
v-if="isUser === true",
|
v-if="isUser === true",
|
||||||
:class="{'initial-description': initialColumnDescription}",
|
:class="{'initial-description': initialColumnDescription}",
|
||||||
@@ -243,6 +244,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Task from './task';
|
import Task from './task';
|
||||||
|
import ClearCompletedTodos from './clearCompletedTodos';
|
||||||
import sortBy from 'lodash/sortBy';
|
import sortBy from 'lodash/sortBy';
|
||||||
import throttle from 'lodash/throttle';
|
import throttle from 'lodash/throttle';
|
||||||
import buyMixin from 'client/mixins/buy';
|
import buyMixin from 'client/mixins/buy';
|
||||||
@@ -267,6 +269,7 @@ export default {
|
|||||||
mixins: [buyMixin, notifications],
|
mixins: [buyMixin, notifications],
|
||||||
components: {
|
components: {
|
||||||
Task,
|
Task,
|
||||||
|
ClearCompletedTodos,
|
||||||
BuyQuestModal,
|
BuyQuestModal,
|
||||||
shopItem,
|
shopItem,
|
||||||
draggable,
|
draggable,
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ export async function fetchCompletedTodos (store, forceLoad = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function clearCompletedTodos (store) {
|
||||||
|
await axios.post('/api/v3/tasks/clearCompletedTodos');
|
||||||
|
store.state.tasks.data.todos = store.state.tasks.data.todos.filter(task => {
|
||||||
|
return !task.completed;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function order (store, [rawTasks, tasksOrder]) {
|
export function order (store, [rawTasks, tasksOrder]) {
|
||||||
const tasks = {
|
const tasks = {
|
||||||
habits: [],
|
habits: [],
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"clearCompleted": "Delete Completed",
|
"clearCompleted": "Delete Completed",
|
||||||
|
"clearCompletedDescription": "Completed To-Dos are deleted after 30 days for non-subscribers and 90 days for subscribers.",
|
||||||
|
"clearCompletedConfirm": "Are you sure you want to clear your completed todos?",
|
||||||
"lotOfToDos": "Your most recent 30 completed To-Dos are shown here. You can see older completed To-Dos from Data > Data Display Tool or Data > Export Data > User Data.",
|
"lotOfToDos": "Your most recent 30 completed To-Dos are shown here. You can see older completed To-Dos from Data > Data Display Tool or Data > Export Data > User Data.",
|
||||||
"deleteToDosExplanation": "If you click the button below, all of your completed To-Dos and archived To-Dos will be permanently deleted, except for To-Dos from active challenges and Group Plans. Export them first if you want to keep a record of them.",
|
"deleteToDosExplanation": "If you click the button below, all of your completed To-Dos and archived To-Dos will be permanently deleted, except for To-Dos from active challenges and Group Plans. Export them first if you want to keep a record of them.",
|
||||||
"addMultipleTip": "<strong>Tip:</strong> To add multiple Tasks, separate each one using a line break (Shift + Enter) and then press \"Enter.\"",
|
"addMultipleTip": "<strong>Tip:</strong> To add multiple Tasks, separate each one using a line break (Shift + Enter) and then press \"Enter.\"",
|
||||||
|
|||||||
Reference in New Issue
Block a user