mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-18 10:43:18 +01:00
Add sorting to tasks table
This commit is contained in:
committed by
Gregor Vostrak
parent
b2849ec04a
commit
d29f5706ce
@@ -15,6 +15,7 @@ import {
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import TaskCreateModal from '@/Components/Common/Task/TaskCreateModal.vue';
|
||||
import TaskTable from '@/Components/Common/Task/TaskTable.vue';
|
||||
import type { SortColumn, SortDirection } from '@/Components/Common/Task/TaskTable.vue';
|
||||
import CardTitle from '@/packages/ui/src/CardTitle.vue';
|
||||
import Card from '@/Components/Common/Card.vue';
|
||||
import ProjectMemberTable from '@/Components/Common/ProjectMember/ProjectMemberTable.vue';
|
||||
@@ -29,6 +30,7 @@ import { formatCents } from '../packages/ui/src/utils/money';
|
||||
import { getOrganizationCurrencyString } from '../utils/money';
|
||||
import { useOrganizationQuery } from '@/utils/useOrganizationQuery';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
|
||||
const { projects } = useProjectsQuery();
|
||||
|
||||
@@ -65,6 +67,26 @@ const activeTab = ref<'active' | 'done'>('active');
|
||||
|
||||
const { tasks } = useTasksQuery();
|
||||
|
||||
interface TaskTableState {
|
||||
sortColumn: SortColumn;
|
||||
sortDirection: SortDirection;
|
||||
}
|
||||
|
||||
const tableState = useStorage<TaskTableState>(
|
||||
'task-table-state',
|
||||
{
|
||||
sortColumn: 'name',
|
||||
sortDirection: 'asc',
|
||||
},
|
||||
undefined,
|
||||
{ mergeDefaults: true }
|
||||
);
|
||||
|
||||
function handleSort(column: SortColumn, direction: SortDirection) {
|
||||
tableState.value.sortColumn = column;
|
||||
tableState.value.sortDirection = direction;
|
||||
}
|
||||
|
||||
const shownTasks = computed(() => {
|
||||
return tasks.value.filter((task) => {
|
||||
if (activeTab.value === 'active') {
|
||||
@@ -159,7 +181,12 @@ const shownTasks = computed(() => {
|
||||
</template>
|
||||
</CardTitle>
|
||||
<Card>
|
||||
<TaskTable :tasks="shownTasks" :project-id="projectId"></TaskTable>
|
||||
<TaskTable
|
||||
:tasks="shownTasks"
|
||||
:project-id="projectId"
|
||||
:sort-column="tableState.sortColumn"
|
||||
:sort-direction="tableState.sortDirection"
|
||||
@sort="handleSort"></TaskTable>
|
||||
</Card>
|
||||
</div>
|
||||
<div v-if="canViewProjectMembers()">
|
||||
|
||||
Reference in New Issue
Block a user