164 lines
5.6 KiB
Vue
164 lines
5.6 KiB
Vue
<template>
|
|
<div class="table-view">
|
|
<div class="column-filter">
|
|
<button class="button" @click="showActiveColumnsFilter = !showActiveColumnsFilter">
|
|
<span class="icon is-small">
|
|
<icon icon="th"/>
|
|
</span>
|
|
Columns
|
|
</button>
|
|
<transition name="fade">
|
|
<div class="card" v-if="showActiveColumnsFilter">
|
|
<div class="card-content">
|
|
<fancycheckbox v-model="activeColumns.id">#</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.done">Done</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.text">Name</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.priority">Priority</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.labels">Labels</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.assignees">Assignees</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.dueDate">Due Date</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.startDate">Start Date</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.endDate">End Date</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.percentDone">% Done</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.created">Created</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.updated">Updated</fancycheckbox>
|
|
<fancycheckbox v-model="activeColumns.createdBy">Created By</fancycheckbox>
|
|
</div>
|
|
</div>
|
|
</transition>
|
|
</div>
|
|
|
|
<table class="table is-hoverable is-fullwidth">
|
|
<thead>
|
|
<tr>
|
|
<th v-if="activeColumns.id">#</th>
|
|
<th v-if="activeColumns.done">Done</th>
|
|
<th v-if="activeColumns.text">Name</th>
|
|
<th v-if="activeColumns.priority">Priority</th>
|
|
<th v-if="activeColumns.labels">Labels</th>
|
|
<th v-if="activeColumns.assignees">Assignees</th>
|
|
<th v-if="activeColumns.dueDate">Due Date</th>
|
|
<th v-if="activeColumns.startDate">Start Date</th>
|
|
<th v-if="activeColumns.endDate">End Date</th>
|
|
<th v-if="activeColumns.percentDone">% Done</th>
|
|
<th v-if="activeColumns.created">Created</th>
|
|
<th v-if="activeColumns.updated">Updated</th>
|
|
<th v-if="activeColumns.createdBy">Created By</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="t in tasks" :key="t.id">
|
|
<td v-if="activeColumns.id">
|
|
<router-link :to="{name: 'taskDetailView', params: { id: t.id }}">{{ t.id }}</router-link>
|
|
</td>
|
|
<td v-if="activeColumns.done">
|
|
<div class="is-done" v-if="t.done">Done</div>
|
|
</td>
|
|
<td v-if="activeColumns.text">
|
|
<router-link :to="{name: 'taskDetailView', params: { id: t.id }}">{{ t.text }}</router-link>
|
|
</td>
|
|
<td v-if="activeColumns.priority">
|
|
<priority-label :priority="t.priority" :show-all="true"/>
|
|
</td>
|
|
<td v-if="activeColumns.labels">
|
|
<labels :labels="t.labels"/>
|
|
</td>
|
|
<td v-if="activeColumns.assignees">
|
|
<user
|
|
:user="a"
|
|
:avatar-size="27"
|
|
:show-username="false"
|
|
:is-inline="true"
|
|
v-for="(a, i) in t.assignees"
|
|
:key="t.id + 'assignee' + a.id + i"
|
|
/>
|
|
</td>
|
|
<date-table-cell :date="t.dueDate" v-if="activeColumns.dueDate"/>
|
|
<date-table-cell :date="t.startDate" v-if="activeColumns.startDate"/>
|
|
<date-table-cell :date="t.endDate" v-if="activeColumns.endDate"/>
|
|
<td v-if="activeColumns.percentDone">{{ t.percentDone }}%</td>
|
|
<date-table-cell :date="t.created" v-if="activeColumns.created"/>
|
|
<date-table-cell :date="t.updated" v-if="activeColumns.updated"/>
|
|
<td v-if="activeColumns.createdBy">
|
|
<user
|
|
:user="t.createdBy"
|
|
:show-username="false"
|
|
:avatar-size="27"/>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<nav class="pagination is-centered" role="navigation" aria-label="pagination" v-if="taskCollectionService.totalPages > 1">
|
|
<router-link class="pagination-previous" :to="getRouteForPagination(currentPage - 1, 'table')" tag="button" :disabled="currentPage === 1">Previous</router-link>
|
|
<router-link class="pagination-next" :to="getRouteForPagination(currentPage + 1, 'table')" tag="button" :disabled="currentPage === taskCollectionService.totalPages">Next page</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 :to="getRouteForPagination(p.number, 'table')" :class="{'is-current': p.number === currentPage}" class="pagination-link" :aria-label="'Goto page ' + p.number">{{ p.number }}</router-link>
|
|
</li>
|
|
</template>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import ListModel from '../../models/list'
|
|
import taskList from './helpers/taskList'
|
|
import User from '../global/user'
|
|
import PriorityLabel from './reusable/priorityLabel'
|
|
import Labels from './reusable/labels'
|
|
import DateTableCell from './reusable/date-table-cell'
|
|
import Fancycheckbox from '../global/fancycheckbox'
|
|
|
|
export default {
|
|
name: 'TableView',
|
|
components: {
|
|
Fancycheckbox,
|
|
DateTableCell,
|
|
Labels,
|
|
PriorityLabel,
|
|
User,
|
|
},
|
|
mixins: [
|
|
taskList,
|
|
],
|
|
data() {
|
|
return {
|
|
showActiveColumnsFilter: false,
|
|
activeColumns: {
|
|
id: true,
|
|
done: true,
|
|
text: true,
|
|
priority: false,
|
|
labels: true,
|
|
assignees: true,
|
|
dueDate: true,
|
|
startDate: false,
|
|
endDate: false,
|
|
percentDone: false,
|
|
created: false,
|
|
updated: false,
|
|
createdBy: false,
|
|
}
|
|
}
|
|
},
|
|
props: {
|
|
list: {
|
|
type: ListModel,
|
|
required: true,
|
|
}
|
|
},
|
|
created() {
|
|
this.initTasks(1)
|
|
},
|
|
methods: {
|
|
initTasks(page, search = '') {
|
|
this.loadTasks(page, search, {sort_by: ['id'], order_by: ['desc']})
|
|
},
|
|
},
|
|
}
|
|
</script>
|