feat(teams): quick add

Also fixes issue with lock icons
Also hides task copies from personal task board
This commit is contained in:
Sabe Jones
2021-05-05 16:55:07 -05:00
committed by SabreCat
parent a5680836bd
commit 072b09e030
5 changed files with 28 additions and 8 deletions

View File

@@ -43,7 +43,7 @@
class="tasks-list"
>
<textarea
v-if="isUser"
v-if="isUser || canCreateTasks()"
ref="quickAdd"
v-model="quickAddText"
class="quick-add"
@@ -350,6 +350,7 @@ import draggable from 'vuedraggable';
import Task from './task';
import ClearCompletedTodos from './clearCompletedTodos';
import buyMixin from '@/mixins/buy';
import sync from '@/mixins/sync';
import { mapState, mapActions, mapGetters } from '@/libs/store';
import shopItem from '../shops/shopItem';
import BuyQuestModal from '@/components/shops/quests/buyQuestModal.vue';
@@ -382,7 +383,7 @@ export default {
shopItem,
draggable,
},
mixins: [buyMixin, notifications],
mixins: [buyMixin, notifications, sync],
// @TODO Set default values for props
// allows for better control of props values
// allows for better control of where this component is called
@@ -542,6 +543,7 @@ export default {
...mapActions({
loadCompletedTodos: 'tasks:fetchCompletedTodos',
createTask: 'tasks:create',
createGroupTasks: 'tasks:createGroupTasks',
}),
async taskSorted (data) {
const filteredList = this.taskList;
@@ -606,7 +608,12 @@ export default {
this.showPopovers = true;
this.isDragging(false);
},
quickAdd (ev) {
canCreateTasks () {
if (!this.group) return false;
return (this.group.leader && this.group.leader._id === this.user._id)
|| (this.group.managers && Boolean(this.group.managers[this.user._id]));
},
async quickAdd (ev) {
// Add a new line if Shift+Enter Pressed
if (ev.shiftKey) {
this.quickAddRows += 1;
@@ -620,13 +627,18 @@ export default {
const tasks = text.split('\n').reverse().filter(taskText => (!!taskText)).map(taskText => {
const task = taskDefaults({ type: this.type, text: taskText }, this.user);
task.tags = this.selectedTags.slice();
if (this.isUser) task.tags = this.selectedTags.slice();
return task;
});
this.quickAddText = '';
this.quickAddRows = 1;
this.createTask(tasks);
if (this.group) {
await this.createGroupTasks({ groupId: this.group.id, tasks });
this.sync();
} else {
this.createTask(tasks);
}
this.$refs.quickAdd.blur();
return true;
},
@@ -687,7 +699,7 @@ export default {
filterByLabel (taskList, type, filter) {
if (!taskList) return [];
const selectedFilter = getActiveFilter(type, filter, this.challenge);
return sortAndFilterTasks(taskList, selectedFilter);
return sortAndFilterTasks(taskList, selectedFilter, Boolean(this.group));
},
filterByTagList (taskList, tagList = []) {
let filteredTaskList = taskList;