mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Correctly filter tasks in challenges and remove filters where unhelpful (#12522)
* Correctly filter tasks in challenges and remove filters where unhelpful * update isDue property on the client as soon as challenges are created or edited * change method of update for task on receiving data * try different assign method * fix lint * fix issue with data reactivity Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
This commit is contained in:
@@ -21,7 +21,10 @@
|
||||
>
|
||||
{{ badgeCount }}
|
||||
</div>
|
||||
<div class="filters d-flex justify-content-end">
|
||||
<div
|
||||
v-if="typeFilters.length > 1"
|
||||
class="filters d-flex justify-content-end"
|
||||
>
|
||||
<div
|
||||
v-for="filter in typeFilters"
|
||||
:key="filter"
|
||||
@@ -353,6 +356,7 @@ import {
|
||||
getTypeLabel,
|
||||
getFilterLabels,
|
||||
getActiveFilter,
|
||||
sortAndFilterTasks,
|
||||
} from '@/libs/store/helpers/filterTasks';
|
||||
|
||||
import habitIcon from '@/assets/svg/habit.svg';
|
||||
@@ -433,7 +437,7 @@ export default {
|
||||
type: this.type,
|
||||
filterType: this.activeFilter.label,
|
||||
})
|
||||
: this.filterByLabel(this.taskListOverride, this.activeFilter.label);
|
||||
: this.filterByLabel(this.taskListOverride, this.type, this.activeFilter.label);
|
||||
|
||||
const taggedList = this.filterByTagList(filteredTaskList, this.selectedTags);
|
||||
const searchedList = this.filterBySearchText(taggedList, this.searchText);
|
||||
@@ -500,7 +504,7 @@ export default {
|
||||
// Set Task Column Label
|
||||
this.typeLabel = getTypeLabel(this.type);
|
||||
// Get Category Filter Labels
|
||||
this.typeFilters = getFilterLabels(this.type);
|
||||
this.typeFilters = getFilterLabels(this.type, this.challenge);
|
||||
// Set default filter for task column
|
||||
this.activateFilter(this.type);
|
||||
},
|
||||
@@ -637,7 +641,7 @@ export default {
|
||||
filter = 'due'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
|
||||
this.activeFilter = getActiveFilter(type, filter);
|
||||
this.activeFilter = getActiveFilter(type, filter, this.challenge);
|
||||
},
|
||||
setColumnBackgroundVisibility () {
|
||||
this.$nextTick(() => {
|
||||
@@ -665,14 +669,10 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
filterByLabel (taskList, filter) {
|
||||
filterByLabel (taskList, type, filter) {
|
||||
if (!taskList) return [];
|
||||
return taskList.filter(task => {
|
||||
if (filter === 'complete2') return task.completed;
|
||||
if (filter === 'due') return task.isDue;
|
||||
if (filter === 'notDue') return !task.isDue;
|
||||
return !task.completed;
|
||||
});
|
||||
const selectedFilter = getActiveFilter(type, filter, this.challenge);
|
||||
return sortAndFilterTasks(taskList, selectedFilter);
|
||||
},
|
||||
filterByTagList (taskList, tagList = []) {
|
||||
let filteredTaskList = taskList;
|
||||
|
||||
Reference in New Issue
Block a user