Enhance Process Management with Improved Filtering and Pagination
- Updated the items per page default to 20 for better data visibility in process management. - Implemented comprehensive filtering options for processes, including search by name, description, category, and creator, enhancing user experience and data retrieval. - Adjusted pagination logic to handle high limits, allowing for client-side pagination when necessary. - Enhanced API response handling to accommodate new pagination and filtering features, ensuring accurate data representation and navigation.
This commit is contained in:
parent
77e3b8601f
commit
a006b66d02
@ -31,7 +31,7 @@ const currentView = ref('dashboard'); // 'dashboard', 'list', 'analytics'
|
|||||||
|
|
||||||
// Pagination state
|
// Pagination state
|
||||||
const currentPage = ref(1);
|
const currentPage = ref(1);
|
||||||
const itemsPerPage = ref(5); // Set to 5 to test pagination
|
const itemsPerPage = ref(20); // Default to 20 items per page
|
||||||
const totalItems = ref(0);
|
const totalItems = ref(0);
|
||||||
|
|
||||||
// Dashboard metrics and data
|
// Dashboard metrics and data
|
||||||
@ -75,6 +75,28 @@ const categoryOptions = [
|
|||||||
const filteredProcesses = computed(() => {
|
const filteredProcesses = computed(() => {
|
||||||
let filtered = processStore.processes;
|
let filtered = processStore.processes;
|
||||||
|
|
||||||
|
// Apply search filter
|
||||||
|
if (searchQuery.value.trim()) {
|
||||||
|
const query = searchQuery.value.toLowerCase().trim();
|
||||||
|
filtered = filtered.filter(process =>
|
||||||
|
process.name?.toLowerCase().includes(query) ||
|
||||||
|
process.description?.toLowerCase().includes(query) ||
|
||||||
|
process.category?.toLowerCase().includes(query) ||
|
||||||
|
process.creator?.userFullName?.toLowerCase().includes(query) ||
|
||||||
|
process.creator?.userUsername?.toLowerCase().includes(query)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply status filter
|
||||||
|
if (statusFilter.value) {
|
||||||
|
filtered = filtered.filter(process => process.status === statusFilter.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply category filter
|
||||||
|
if (categoryFilter.value) {
|
||||||
|
filtered = filtered.filter(process => process.category === categoryFilter.value);
|
||||||
|
}
|
||||||
|
|
||||||
// Update total items for pagination
|
// Update total items for pagination
|
||||||
totalItems.value = filtered.length;
|
totalItems.value = filtered.length;
|
||||||
|
|
||||||
@ -230,7 +252,8 @@ const loadProcesses = async () => {
|
|||||||
try {
|
try {
|
||||||
const options = {
|
const options = {
|
||||||
sortBy: sortBy.value,
|
sortBy: sortBy.value,
|
||||||
sortOrder: sortOrder.value
|
sortOrder: sortOrder.value,
|
||||||
|
limit: 1000 // Set a high limit to get all processes
|
||||||
};
|
};
|
||||||
|
|
||||||
if (statusFilter.value) {
|
if (statusFilter.value) {
|
||||||
@ -861,7 +884,8 @@ const copyWorkflowLink = async (processId) => {
|
|||||||
{ label: '5', value: 5 },
|
{ label: '5', value: 5 },
|
||||||
{ label: '10', value: 10 },
|
{ label: '10', value: 10 },
|
||||||
{ label: '20', value: 20 },
|
{ label: '20', value: 20 },
|
||||||
{ label: '50', value: 50 }
|
{ label: '50', value: 50 },
|
||||||
|
{ label: '100', value: 100 }
|
||||||
]"
|
]"
|
||||||
:classes="{
|
:classes="{
|
||||||
outer: 'mb-0',
|
outer: 'mb-0',
|
||||||
|
@ -53,6 +53,10 @@ export default defineEventHandler(async (event) => {
|
|||||||
// Calculate pagination
|
// Calculate pagination
|
||||||
const skip = (parseInt(page) - 1) * parseInt(limit);
|
const skip = (parseInt(page) - 1) * parseInt(limit);
|
||||||
const take = parseInt(limit);
|
const take = parseInt(limit);
|
||||||
|
|
||||||
|
// If limit is very high (like 1000), return all processes without pagination
|
||||||
|
// This allows the frontend to handle client-side pagination
|
||||||
|
const shouldReturnAll = parseInt(limit) >= 1000;
|
||||||
|
|
||||||
// Build orderBy clause
|
// Build orderBy clause
|
||||||
const orderBy = {};
|
const orderBy = {};
|
||||||
@ -63,8 +67,8 @@ export default defineEventHandler(async (event) => {
|
|||||||
prisma.process.findMany({
|
prisma.process.findMany({
|
||||||
where,
|
where,
|
||||||
orderBy,
|
orderBy,
|
||||||
skip,
|
skip: shouldReturnAll ? 0 : skip,
|
||||||
take,
|
take: shouldReturnAll ? undefined : take,
|
||||||
select: {
|
select: {
|
||||||
processID: true,
|
processID: true,
|
||||||
processUUID: true,
|
processUUID: true,
|
||||||
@ -93,9 +97,9 @@ export default defineEventHandler(async (event) => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Calculate pagination info
|
// Calculate pagination info
|
||||||
const totalPages = Math.ceil(totalCount / take);
|
const totalPages = shouldReturnAll ? 1 : Math.ceil(totalCount / take);
|
||||||
const hasNextPage = parseInt(page) < totalPages;
|
const hasNextPage = shouldReturnAll ? false : parseInt(page) < totalPages;
|
||||||
const hasPrevPage = parseInt(page) > 1;
|
const hasPrevPage = shouldReturnAll ? false : parseInt(page) > 1;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user