2019-04-29 21:41:39 +00:00
|
|
|
<template>
|
2021-01-17 17:57:57 +00:00
|
|
|
<div
|
|
|
|
:class="{ 'is-loading': taskCollectionService.loading}"
|
|
|
|
class="loader-container is-max-width-desktop list-view">
|
2020-12-24 00:33:25 +00:00
|
|
|
<div class="filter-container" v-if="list.isSavedFilter && !list.isSavedFilter()">
|
2020-06-11 15:34:13 +00:00
|
|
|
<div class="items">
|
|
|
|
<div class="search">
|
2020-09-05 20:35:52 +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"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('misc.search')"
|
2020-09-05 20:35:52 +00:00
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="searchTerm"/>
|
2020-06-11 15:34:13 +00:00
|
|
|
<span class="icon is-left">
|
|
|
|
<icon icon="search"/>
|
|
|
|
</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"
|
|
|
|
>
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('misc.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"
|
|
|
|
>
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('filters.title') }}
|
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-01-24 13:27:52 +00:00
|
|
|
<div class="field task-add" v-if="!list.isArchived && canWrite && list.id > 0">
|
2021-01-24 13:00:21 +00:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<p :class="{ 'is-loading': taskService.loading}" class="control has-icons-left is-expanded">
|
|
|
|
<input
|
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
@keyup.enter="addTask()"
|
|
|
|
class="input"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('list.list.addPlaceholder')"
|
2021-01-24 13:00:21 +00:00
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="newTaskText"
|
|
|
|
ref="newTaskInput"
|
|
|
|
/>
|
|
|
|
<span class="icon is-small is-left">
|
2019-04-29 21:41:39 +00:00
|
|
|
<icon icon="tasks"/>
|
|
|
|
</span>
|
2021-01-24 13:00:21 +00:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
|
|
|
<x-button
|
|
|
|
:disabled="newTaskText.length === 0"
|
|
|
|
@click="addTask()"
|
|
|
|
icon="plus"
|
|
|
|
>
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('list.list.add') }}
|
2021-01-24 13:00:21 +00:00
|
|
|
</x-button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<p class="help is-danger" v-if="showError && newTaskText === ''">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('list.list.addTitleRequired') }}
|
2019-04-29 21:41:39 +00:00
|
|
|
</p>
|
2021-07-05 10:29:04 +00:00
|
|
|
<quick-add-magic v-if="!showError"/>
|
2019-04-29 21:41:39 +00:00
|
|
|
</div>
|
|
|
|
|
2021-01-30 16:17:04 +00:00
|
|
|
<nothing v-if="ctaVisible && tasks.length === 0 && !taskCollectionService.loading">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('list.list.empty') }}
|
|
|
|
<a @click="$refs.newTaskInput.focus()">
|
|
|
|
{{ $t('list.list.newTaskCta') }}
|
|
|
|
</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">
|
|
|
|
<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
|
|
|
>
|
2020-09-05 20:35:52 +00:00
|
|
|
<div @click="editTask(t.id)" class="icon settings" v-if="!list.isArchived && canWrite">
|
|
|
|
<icon icon="pencil-alt"/>
|
|
|
|
</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-07-05 10:29:04 +00:00
|
|
|
class="taskedit mt-0" :title="$t('list.list.editTask')" :has-close="true"
|
|
|
|
@close="() => isTaskEdit = false"
|
2021-01-24 13:00:21 +00:00
|
|
|
:shadow="false">
|
2021-01-17 17:57:57 +00:00
|
|
|
<edit-task :task="taskEditTask"/>
|
|
|
|
</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"
|
|
|
|
v-if="taskCollectionService.totalPages > 1">
|
|
|
|
<router-link
|
|
|
|
:disabled="currentPage === 1"
|
|
|
|
:to="getRouteForPagination(currentPage - 1)"
|
|
|
|
class="pagination-previous"
|
|
|
|
tag="button">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('misc.previous') }}
|
2021-01-24 13:00:21 +00:00
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
:disabled="currentPage === taskCollectionService.totalPages"
|
|
|
|
:to="getRouteForPagination(currentPage + 1)"
|
|
|
|
class="pagination-next"
|
|
|
|
tag="button">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('misc.next') }}
|
2021-01-24 13:00:21 +00:00
|
|
|
</router-link>
|
|
|
|
<ul class="pagination-list">
|
|
|
|
<template v-for="(p, i) in pages">
|
|
|
|
<li :key="'page'+i" v-if="p.isEllipsis"><span class="pagination-ellipsis">…</span></li>
|
|
|
|
<li :key="'page'+i" v-else>
|
|
|
|
<router-link
|
|
|
|
:aria-label="'Goto page ' + p.number"
|
|
|
|
:class="{'is-current': p.number === currentPage}"
|
|
|
|
:to="getRouteForPagination(p.number)"
|
|
|
|
class="pagination-link">
|
|
|
|
{{ 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">
|
|
|
|
<router-view/>
|
|
|
|
</transition>
|
|
|
|
|
2021-07-05 10:29:04 +00:00
|
|
|
|
2019-04-29 21:41:39 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 20:35:52 +00:00
|
|
|
import TaskService from '../../../services/task'
|
|
|
|
import TaskModel from '../../../models/task'
|
2020-07-24 16:39:38 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
import EditTask from '../../../components/tasks/edit-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'
|
2021-01-17 10:36:57 +00:00
|
|
|
import FilterPopup from '@/components/list/partials/filter-popup'
|
2021-01-30 16:17:04 +00:00
|
|
|
import Nothing from '@/components/misc/nothing'
|
2021-07-05 10:29:04 +00:00
|
|
|
import createTask from '@/components/tasks/mixins/createTask'
|
|
|
|
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic'
|
2019-04-29 21:41:39 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
export default {
|
|
|
|
name: 'List',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
taskService: TaskService,
|
|
|
|
isTaskEdit: false,
|
|
|
|
taskEditTask: TaskModel,
|
|
|
|
newTaskText: '',
|
|
|
|
showError: false,
|
2021-01-20 21:09:40 +00:00
|
|
|
ctaVisible: false,
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mixins: [
|
|
|
|
taskList,
|
2021-07-05 10:29:04 +00:00
|
|
|
createTask,
|
2020-09-05 20:35:52 +00:00
|
|
|
],
|
|
|
|
components: {
|
2021-07-05 10:29:04 +00:00
|
|
|
QuickAddMagic,
|
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,
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.taskService = new TaskService()
|
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.
|
|
|
|
saveListView(this.$route.params.listId, this.$route.name)
|
|
|
|
},
|
|
|
|
computed: mapState({
|
|
|
|
canWrite: state => state.currentList.maxRight > Rights.READ,
|
2020-09-26 21:02:37 +00:00
|
|
|
list: state => state.currentList,
|
2020-09-05 20:35:52 +00:00
|
|
|
}),
|
2021-01-20 21:09:40 +00:00
|
|
|
mounted() {
|
|
|
|
this.$nextTick(() => this.ctaVisible = true)
|
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
methods: {
|
|
|
|
// This function initializes the tasks page and loads the first page of tasks
|
|
|
|
initTasks(page, search = '') {
|
|
|
|
this.taskEditTask = null
|
|
|
|
this.isTaskEdit = false
|
|
|
|
this.loadTasks(page, search)
|
2019-04-29 21:41:39 +00:00
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
addTask() {
|
|
|
|
if (this.newTaskText === '') {
|
|
|
|
this.showError = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.showError = false
|
2020-03-04 19:27:27 +00:00
|
|
|
|
2021-07-05 10:29:04 +00:00
|
|
|
this.createNewTask(this.newTaskText)
|
2020-09-05 20:35:52 +00:00
|
|
|
.then(task => {
|
|
|
|
this.tasks.push(task)
|
|
|
|
this.sortTasks()
|
|
|
|
this.newTaskText = ''
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-06-22 20:07:57 +00:00
|
|
|
this.error(e)
|
2020-09-05 20:35:52 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
editTask(id) {
|
|
|
|
// Find the selected task and set it to the current object
|
|
|
|
let theTask = this.getTaskById(id) // Somehow this does not work if we directly assign this to this.taskEditTask
|
|
|
|
this.taskEditTask = theTask
|
|
|
|
this.isTaskEdit = true
|
|
|
|
},
|
|
|
|
getTaskById(id) {
|
|
|
|
for (const t in this.tasks) {
|
|
|
|
if (this.tasks[t].id === parseInt(id)) {
|
|
|
|
return this.tasks[t]
|
2019-12-07 16:35:42 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
|
|
|
return {} // FIXME: This should probably throw something to make it clear to the user noting was found
|
|
|
|
},
|
|
|
|
updateTasks(updatedTask) {
|
|
|
|
for (const t in this.tasks) {
|
|
|
|
if (this.tasks[t].id === updatedTask.id) {
|
|
|
|
this.$set(this.tasks, t, updatedTask)
|
|
|
|
break
|
2020-03-23 22:24:14 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
|
|
|
this.sortTasks()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2019-04-29 21:41:39 +00:00
|
|
|
</script>
|