2019-04-29 21:41:39 +00:00
|
|
|
<template>
|
2021-01-17 17:57:57 +00:00
|
|
|
<div
|
2021-05-26 20:33:12 +00:00
|
|
|
:class="{ 'is-loading': taskCollectionService.loading }"
|
|
|
|
class="loader-container is-max-width-desktop list-view"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="filter-container"
|
|
|
|
v-if="list.isSavedFilter && !list.isSavedFilter()"
|
|
|
|
>
|
2020-06-11 15:34:13 +00:00
|
|
|
<div class="items">
|
|
|
|
<div class="search">
|
2021-05-26 20:33:12 +00:00
|
|
|
<div :class="{ hidden: !showTaskSearch }" class="field has-addons">
|
2020-06-11 15:34:13 +00:00
|
|
|
<div class="control has-icons-left has-icons-right">
|
|
|
|
<input
|
2020-09-05 20:35:52 +00:00
|
|
|
@blur="hideSearchBar()"
|
|
|
|
@keyup.enter="searchTasks"
|
|
|
|
class="input"
|
|
|
|
placeholder="Search"
|
|
|
|
type="text"
|
|
|
|
v-focus
|
2021-05-26 20:33:12 +00:00
|
|
|
v-model="searchTerm"
|
|
|
|
/>
|
2020-06-11 15:34:13 +00:00
|
|
|
<span class="icon is-left">
|
2021-05-26 20:33:12 +00:00
|
|
|
<icon icon="search" />
|
2020-06-11 15:34:13 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
2021-01-17 17:57:57 +00:00
|
|
|
<x-button
|
|
|
|
:loading="taskCollectionService.loading"
|
2020-09-05 20:35:52 +00:00
|
|
|
@click="searchTasks"
|
2021-01-17 17:57:57 +00:00
|
|
|
:shadow="false"
|
|
|
|
>
|
2020-06-11 15:34:13 +00:00
|
|
|
Search
|
2021-01-17 17:57:57 +00:00
|
|
|
</x-button>
|
2020-06-11 15:34:13 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-17 17:57:57 +00:00
|
|
|
<x-button
|
|
|
|
@click="showTaskSearch = !showTaskSearch"
|
|
|
|
icon="search"
|
|
|
|
type="secondary"
|
|
|
|
v-if="!showTaskSearch"
|
|
|
|
/>
|
2020-01-31 10:05:53 +00:00
|
|
|
</div>
|
2021-01-17 17:57:57 +00:00
|
|
|
<x-button
|
|
|
|
@click.prevent.stop="showTaskFilter = !showTaskFilter"
|
|
|
|
type="secondary"
|
|
|
|
icon="filter"
|
|
|
|
>
|
2020-06-11 15:34:13 +00:00
|
|
|
Filters
|
2021-01-17 17:57:57 +00:00
|
|
|
</x-button>
|
2020-01-31 10:05:53 +00:00
|
|
|
</div>
|
2021-01-17 10:36:57 +00:00
|
|
|
<filter-popup
|
|
|
|
@change="loadTasks(1)"
|
|
|
|
:visible="showTaskFilter"
|
|
|
|
v-model="params"
|
|
|
|
/>
|
2020-01-31 10:05:53 +00:00
|
|
|
</div>
|
2020-03-04 19:27:27 +00:00
|
|
|
|
2021-01-24 14:37:19 +00:00
|
|
|
<card :padding="false" :has-content="false" class="has-overflow">
|
2021-05-26 20:33:12 +00:00
|
|
|
<div
|
|
|
|
class="field task-add"
|
|
|
|
v-if="!list.isArchived && canWrite && list.id > 0"
|
|
|
|
>
|
|
|
|
<add-task
|
|
|
|
:listId="Number($route.params.listId)"
|
|
|
|
@taskAdded="updateTaskList"
|
2021-06-03 00:21:39 +00:00
|
|
|
ref="newTaskInput"
|
2021-05-26 20:33:12 +00:00
|
|
|
/>
|
2021-01-24 13:00:21 +00:00
|
|
|
<p class="help is-danger" v-if="showError && newTaskText === ''">
|
|
|
|
Please specify a list title.
|
2019-04-29 21:41:39 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2021-06-03 00:21:39 +00:00
|
|
|
<nothing v-if="ctaVisible && tasks.length === 0 && !taskCollectionService.loading">
|
2021-01-24 13:00:21 +00:00
|
|
|
This list is currently empty.
|
2021-06-03 00:21:39 +00:00
|
|
|
<a @click="focusNewTaskInput()">Create a new task.</a>
|
2021-01-30 16:17:04 +00:00
|
|
|
</nothing>
|
2020-07-04 17:12:15 +00:00
|
|
|
|
2021-01-24 13:00:21 +00:00
|
|
|
<div class="tasks-container">
|
2021-05-26 20:33:12 +00:00
|
|
|
<div
|
|
|
|
:class="{ short: isTaskEdit }"
|
|
|
|
class="tasks mt-0"
|
|
|
|
v-if="tasks && tasks.length > 0"
|
|
|
|
>
|
2020-09-05 20:16:17 +00:00
|
|
|
<single-task-in-list
|
2021-02-20 14:54:12 +00:00
|
|
|
:show-list-color="false"
|
2020-09-05 20:35:52 +00:00
|
|
|
:disabled="!canWrite"
|
2020-09-05 20:16:17 +00:00
|
|
|
:key="t.id"
|
|
|
|
:the-task="t"
|
|
|
|
@taskUpdated="updateTasks"
|
|
|
|
task-detail-route="task.detail"
|
2020-09-05 20:35:52 +00:00
|
|
|
v-for="t in tasks"
|
2020-09-05 20:16:17 +00:00
|
|
|
>
|
2021-05-26 20:33:12 +00:00
|
|
|
<div
|
|
|
|
@click="editTask(t.id)"
|
|
|
|
class="icon settings"
|
|
|
|
v-if="!list.isArchived && canWrite"
|
|
|
|
>
|
|
|
|
<icon icon="pencil-alt" />
|
2020-09-05 20:35:52 +00:00
|
|
|
</div>
|
2020-09-05 20:16:17 +00:00
|
|
|
</single-task-in-list>
|
2019-04-29 21:41:39 +00:00
|
|
|
</div>
|
2021-01-24 13:00:21 +00:00
|
|
|
<card
|
|
|
|
v-if="isTaskEdit"
|
2021-05-26 20:33:12 +00:00
|
|
|
class="taskedit mt-0"
|
|
|
|
title="Edit Task"
|
|
|
|
:has-close="true"
|
|
|
|
@close="() => (isTaskEdit = false)"
|
|
|
|
:shadow="false"
|
|
|
|
>
|
|
|
|
<edit-task :task="taskEditTask" />
|
2021-01-17 17:57:57 +00:00
|
|
|
</card>
|
2019-04-29 21:41:39 +00:00
|
|
|
</div>
|
2019-12-03 18:09:12 +00:00
|
|
|
|
2021-01-24 13:00:21 +00:00
|
|
|
<nav
|
|
|
|
aria-label="pagination"
|
|
|
|
class="pagination is-centered p-4"
|
|
|
|
role="navigation"
|
2021-05-26 20:33:12 +00:00
|
|
|
v-if="taskCollectionService.totalPages > 1"
|
|
|
|
>
|
2021-01-24 13:00:21 +00:00
|
|
|
<router-link
|
|
|
|
:disabled="currentPage === 1"
|
|
|
|
:to="getRouteForPagination(currentPage - 1)"
|
|
|
|
class="pagination-previous"
|
2021-05-26 20:33:12 +00:00
|
|
|
tag="button"
|
|
|
|
>
|
2021-01-24 13:00:21 +00:00
|
|
|
Previous
|
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
:disabled="currentPage === taskCollectionService.totalPages"
|
|
|
|
:to="getRouteForPagination(currentPage + 1)"
|
|
|
|
class="pagination-next"
|
2021-05-26 20:33:12 +00:00
|
|
|
tag="button"
|
|
|
|
>
|
2021-01-24 13:00:21 +00:00
|
|
|
Next page
|
|
|
|
</router-link>
|
|
|
|
<ul class="pagination-list">
|
|
|
|
<template v-for="(p, i) in pages">
|
2021-05-26 20:33:12 +00:00
|
|
|
<li :key="'page' + i" v-if="p.isEllipsis">
|
|
|
|
<span class="pagination-ellipsis">…</span>
|
|
|
|
</li>
|
|
|
|
<li :key="'page' + i" v-else>
|
2021-01-24 13:00:21 +00:00
|
|
|
<router-link
|
|
|
|
:aria-label="'Goto page ' + p.number"
|
2021-05-26 20:33:12 +00:00
|
|
|
:class="{ 'is-current': p.number === currentPage }"
|
2021-01-24 13:00:21 +00:00
|
|
|
:to="getRouteForPagination(p.number)"
|
2021-05-26 20:33:12 +00:00
|
|
|
class="pagination-link"
|
|
|
|
>
|
2021-01-24 13:00:21 +00:00
|
|
|
{{ p.number }}
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</card>
|
2020-04-25 23:11:34 +00:00
|
|
|
|
|
|
|
<!-- This router view is used to show the task popup while keeping the kanban board itself -->
|
|
|
|
<transition name="modal">
|
2021-05-26 20:33:12 +00:00
|
|
|
<router-view />
|
2020-04-25 23:11:34 +00:00
|
|
|
</transition>
|
2019-04-29 21:41:39 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-06-02 22:32:13 +00:00
|
|
|
import TaskService from '../../../services/task'
|
|
|
|
import TaskModel from '../../../models/task'
|
|
|
|
import LabelTaskService from '../../../services/labelTask'
|
2020-07-24 16:39:38 +00:00
|
|
|
|
2021-06-02 22:32:13 +00:00
|
|
|
import EditTask from '../../../components/tasks/edit-task'
|
|
|
|
import AddTask from '../../../components/tasks/add-task'
|
|
|
|
import SingleTaskInList from '../../../components/tasks/partials/singleTaskInList'
|
|
|
|
import taskList from '../../../components/tasks/mixins/taskList'
|
|
|
|
import { saveListView } from '@/helpers/saveListView'
|
|
|
|
import Rights from '../../../models/rights.json'
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
import FilterPopup from '@/components/list/partials/filter-popup'
|
|
|
|
import { HAS_TASKS } from '@/store/mutation-types'
|
|
|
|
import Nothing from '@/components/misc/nothing'
|
2019-04-29 21:41:39 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
export default {
|
2021-06-02 18:35:59 +00:00
|
|
|
name: 'List',
|
2020-09-05 20:35:52 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
taskService: TaskService,
|
|
|
|
isTaskEdit: false,
|
|
|
|
taskEditTask: TaskModel,
|
2021-06-02 18:35:59 +00:00
|
|
|
newTaskText: '',
|
2020-01-31 10:05:53 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
showError: false,
|
|
|
|
labelTaskService: LabelTaskService,
|
2021-01-20 21:09:40 +00:00
|
|
|
|
2021-06-02 18:40:31 +00:00
|
|
|
ctaVisible: false,
|
2021-06-02 22:32:13 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
2021-05-26 20:33:12 +00:00
|
|
|
mixins: [taskList],
|
2020-09-05 20:35:52 +00:00
|
|
|
components: {
|
2021-01-30 16:17:04 +00:00
|
|
|
Nothing,
|
2021-01-17 10:36:57 +00:00
|
|
|
FilterPopup,
|
2020-09-05 20:35:52 +00:00
|
|
|
SingleTaskInList,
|
|
|
|
EditTask,
|
2021-06-02 18:40:31 +00:00
|
|
|
AddTask,
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
created() {
|
2021-06-02 22:32:13 +00:00
|
|
|
this.taskService = new TaskService()
|
|
|
|
this.labelTaskService = new LabelTaskService()
|
2020-05-21 09:12:59 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
// Save the current list view to local storage
|
|
|
|
// We use local storage and not vuex here to make it persistent across reloads.
|
2021-06-02 22:32:13 +00:00
|
|
|
saveListView(this.$route.params.listId, this.$route.name)
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
computed: mapState({
|
|
|
|
canWrite: state => state.currentList.maxRight > Rights.READ,
|
2021-06-02 18:40:31 +00:00
|
|
|
list: state => state.currentList,
|
2020-09-05 20:35:52 +00:00
|
|
|
}),
|
2021-01-20 21:09:40 +00:00
|
|
|
mounted() {
|
2021-06-02 22:32:13 +00:00
|
|
|
this.$nextTick(() => (this.ctaVisible = true))
|
2021-01-20 21:09:40 +00:00
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
methods: {
|
|
|
|
// This function initializes the tasks page and loads the first page of tasks
|
2021-06-02 18:35:59 +00:00
|
|
|
initTasks(page, search = '') {
|
2021-06-02 22:32:13 +00:00
|
|
|
this.taskEditTask = null
|
|
|
|
this.isTaskEdit = false
|
|
|
|
this.loadTasks(page, search)
|
2019-04-29 21:41:39 +00:00
|
|
|
},
|
2021-06-03 00:21:39 +00:00
|
|
|
focusNewTaskInput() {
|
|
|
|
this.$refs.newTaskInput.$refs.newTaskInput.focus()
|
|
|
|
},
|
2021-05-26 20:33:12 +00:00
|
|
|
updateTaskList(task) {
|
2021-06-02 22:32:13 +00:00
|
|
|
this.tasks.push(task)
|
|
|
|
this.sortTasks()
|
|
|
|
this.$store.commit(HAS_TASKS, true)
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
editTask(id) {
|
|
|
|
// Find the selected task and set it to the current object
|
2021-06-02 22:32:13 +00:00
|
|
|
let theTask = this.getTaskById(id) // Somehow this does not work if we directly assign this to this.taskEditTask
|
|
|
|
this.taskEditTask = theTask
|
|
|
|
this.isTaskEdit = true
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
getTaskById(id) {
|
|
|
|
for (const t in this.tasks) {
|
|
|
|
if (this.tasks[t].id === parseInt(id)) {
|
2021-06-02 22:32:13 +00:00
|
|
|
return this.tasks[t]
|
2019-12-07 16:35:42 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
2021-06-02 22:32:13 +00:00
|
|
|
return {} // FIXME: This should probably throw something to make it clear to the user noting was found
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
updateTasks(updatedTask) {
|
|
|
|
for (const t in this.tasks) {
|
|
|
|
if (this.tasks[t].id === updatedTask.id) {
|
2021-06-02 22:32:13 +00:00
|
|
|
this.$set(this.tasks, t, updatedTask)
|
|
|
|
break
|
2020-03-23 22:24:14 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
2021-06-02 22:32:13 +00:00
|
|
|
this.sortTasks()
|
2021-06-02 18:40:31 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-02 22:32:13 +00:00
|
|
|
}
|
2021-05-26 20:33:12 +00:00
|
|
|
</script>
|