-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Raimund Schlüßler <[email protected]>
- Loading branch information
1 parent
1745e48
commit cbc313c
Showing
9 changed files
with
196 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<!-- | ||
Nextcloud - Tasks | ||
|
||
@author Raimund Schlüßler | ||
@copyright 2024 Raimund Schlüßler <raimund.schluessler@mailbox.org> | ||
|
||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or any later version. | ||
|
||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public | ||
License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
--> | ||
|
||
<template> | ||
<NcActions class="filter reactive" | ||
force-menu | ||
:type="isFilterActive ? 'primary' : 'tertiary'" | ||
:title="t('tasks', 'Active filter')"> | ||
<template #icon> | ||
<span class="material-design-icon"> | ||
<FilterIcon v-if="isFilterActive" :size="20" /> | ||
<FilterOffIcon v-else :size="20" /> | ||
</span> | ||
</template> | ||
<NcActionInput | ||
type="multiselect" | ||
:label="t('tasks', 'Filter by tags')" | ||
track-by="id" | ||
:multiple="true" | ||
append-to-body | ||
:options="tags" | ||
:value="filter.tags" | ||
@input="setTags"> | ||
<template #icon> | ||
<TagMultiple :size="20" /> | ||
</template> | ||
{{ t('tasks', 'Select tags to filter by') }} | ||
</NcActionInput> | ||
<NcActionButton class="reactive" | ||
:close-after-click="true" | ||
@click="resetFilter"> | ||
<template #icon> | ||
<Close :size="20" /> | ||
</template> | ||
{{ t('tasks', 'Reset filter') }} | ||
</NcActionButton> | ||
</NcActions> | ||
</template> | ||
|
||
<script> | ||
import { translate as t } from '@nextcloud/l10n' | ||
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' | ||
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' | ||
import NcActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js' | ||
|
||
import Close from 'vue-material-design-icons/Close.vue' | ||
import FilterIcon from 'vue-material-design-icons/Filter.vue' | ||
import FilterOffIcon from 'vue-material-design-icons/FilterOff.vue' | ||
import TagMultiple from 'vue-material-design-icons/TagMultiple.vue' | ||
|
||
import { mapGetters, mapMutations } from 'vuex' | ||
|
||
export default { | ||
name: 'FilterDropdown', | ||
components: { | ||
NcActions, | ||
NcActionButton, | ||
NcActionInput, | ||
Close, | ||
FilterIcon, | ||
FilterOffIcon, | ||
TagMultiple, | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
tags: 'tags', | ||
filter: 'filter', | ||
}), | ||
isFilterActive() { | ||
return this.filter.tags.length | ||
}, | ||
}, | ||
methods: { | ||
t, | ||
...mapMutations(['setFilter']), | ||
|
||
setTags(tags) { | ||
const filter = this.filter | ||
filter.tags = tags | ||
this.setFilter(filter) | ||
}, | ||
|
||
resetFilter() { | ||
this.setFilter({ tags: [] }) | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
// overlay the sort direction icon with the sort order icon | ||
.material-design-icon { | ||
width: 44px; | ||
height: 44px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |
<span v-linkify="{text: task.summary, linkify: true}" /> | ||
</div> | ||
<div v-if="task.tags.length > 0" class="tags-list"> | ||
<span v-for="(tag, index) in task.tags" :key="index" class="tag"> | ||
<span v-for="(tag, index) in task.tags" :key="index" class="tag no-nav" @click="addTagToFilter(tag)"> | ||
Check failure on line 56 in src/components/TaskBody.vue
|
||
<span :title="tag" class="tag-label"> | ||
{{ tag }} | ||
</span> | ||
|
@@ -260,6 +260,7 @@ export default { | |
computed: { | ||
...mapGetters({ | ||
searchQuery: 'searchQuery', | ||
filter: 'filter', | ||
}), | ||
|
||
dueDateShort() { | ||
|
@@ -428,11 +429,11 @@ export default { | |
*/ | ||
showTask() { | ||
// If the task directly matches the search, we show it. | ||
if (this.task.matches(this.searchQuery)) { | ||
if (this.task.matches(this.searchQuery, this.filter)) { | ||
return true | ||
} | ||
// We also have to show tasks for which one sub(sub...)task matches. | ||
return this.searchSubTasks(this.task, this.searchQuery) | ||
return this.searchSubTasks(this.task, this.searchQuery, this.filter) | ||
}, | ||
|
||
/** | ||
|
@@ -481,7 +482,7 @@ export default { | |
'clearTaskDeletion', | ||
'fetchFullTask', | ||
]), | ||
...mapMutations(['resetStatus']), | ||
...mapMutations(['resetStatus', 'setFilter']), | ||
sort, | ||
/** | ||
* Checks if a date is overdue | ||
|
@@ -494,6 +495,14 @@ export default { | |
} | ||
}, | ||
|
||
addTagToFilter(tag) { | ||
const filter = this.filter | ||
if (!this.filter?.tags.includes(tag)) { | ||
filter.tags.push(tag) | ||
this.setFilter(filter) | ||
} | ||
}, | ||
|
||
/** | ||
* Set task uri in the data transfer object | ||
* so we can get it when dropped on an | ||
|
@@ -870,13 +879,15 @@ $breakpoint-mobile: 1024px; | |
border-radius: 18px !important; | ||
margin: 4px 2px; | ||
align-items: center; | ||
cursor: pointer; | ||
|
||
.tag-label { | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
width: 100%; | ||
text-align: center; | ||
cursor: pointer; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,9 +122,6 @@ export default class Task { | |
sortOrder = this.getSortOrder() | ||
} | ||
this._sortOrder = +sortOrder | ||
|
||
this._searchQuery = '' | ||
this._matchesSearchQuery = true | ||
} | ||
|
||
/** | ||
|
@@ -680,19 +677,21 @@ export default class Task { | |
* Checks if the task matches the search query | ||
* | ||
* @param {string} searchQuery The search string | ||
* @param {Object} filter Object containing the filter parameters | ||
Check warning on line 680 in src/models/task.js
|
||
* @return {boolean} If the task matches | ||
*/ | ||
matches(searchQuery) { | ||
// If the search query maches the previous search, we don't have to search again. | ||
if (this._searchQuery === searchQuery) { | ||
return this._matchesSearchQuery | ||
matches(searchQuery, filter) { | ||
// Check whether the filter matches | ||
// Needs to match all tags | ||
for (const tag of filter?.tags) { | ||
if (!this.tags.includes(tag)) { | ||
return false | ||
} | ||
} | ||
// We cache the current search query for faster future comparison. | ||
this._searchQuery = searchQuery | ||
|
||
// If the search query is empty, the task matches by default. | ||
if (!searchQuery) { | ||
this._matchesSearchQuery = true | ||
return this._matchesSearchQuery | ||
return true | ||
} | ||
// We search in these task properties | ||
const keys = ['summary', 'note', 'tags'] | ||
|
@@ -702,20 +701,17 @@ export default class Task { | |
// For the tags search the array | ||
if (key === 'tags') { | ||
for (const tag of this[key]) { | ||
if (tag.toLowerCase().indexOf(searchQuery) > -1) { | ||
this._matchesSearchQuery = true | ||
return this._matchesSearchQuery | ||
if (tag.toLowerCase().includes(searchQuery)) { | ||
return true | ||
} | ||
} | ||
} else { | ||
if (this[key].toLowerCase().indexOf(searchQuery) > -1) { | ||
this._matchesSearchQuery = true | ||
return this._matchesSearchQuery | ||
if (this[key].toLowerCase().includes(searchQuery)) { | ||
return true | ||
} | ||
} | ||
} | ||
this._matchesSearchQuery = false | ||
return this._matchesSearchQuery | ||
return false | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.