fix(documents): sort newest rows first
This commit is contained in:
@@ -250,6 +250,7 @@ import { useMinimumVisibleState } from '../composables/useMinimumVisibleState.js
|
||||
import { mapExpenseClaimToRequest } from '../composables/useRequests.js'
|
||||
import { fetchApprovalExpenseClaims, fetchArchivedExpenseClaims } from '../services/reimbursements.js'
|
||||
import { countNewDocuments, isNewDocument, markDocumentViewed, markDocumentsViewed, readDocumentScope, readViewedDocumentKeys, writeDocumentScope } from '../utils/documentCenterNewState.js'
|
||||
import { sortDocumentRowsByLatestTime } from '../utils/documentCenterSort.js'
|
||||
import { extractDateText, formatDocumentListTime, resolveDocumentSortTime, resolveDocumentStayTimeDisplay } from '../utils/documentCenterTime.js'
|
||||
import { excludeArchivedDocumentRows, filterApplicationScopeNewRows, isArchivedDocumentRow, prepareApplicationScopeRows } from '../utils/documentCenterRows.js'
|
||||
import { normalizeRequestForUi } from '../utils/requestViewModel.js'
|
||||
@@ -535,7 +536,7 @@ const statusFilterLabel = computed(() =>
|
||||
const filteredRows = computed(() => {
|
||||
const keyword = listKeyword.value.trim().toLowerCase()
|
||||
|
||||
return activeScopeRows.value.filter((row) => {
|
||||
return sortDocumentRowsByLatestTime(activeScopeRows.value.filter((row) => {
|
||||
const matchesKeyword = !keyword || [
|
||||
row.documentNo,
|
||||
row.documentTypeLabel,
|
||||
@@ -556,7 +557,7 @@ const filteredRows = computed(() => {
|
||||
const matchesDateRange = matchesAppliedDateRange(row)
|
||||
|
||||
return matchesKeyword && matchesDocumentType && matchesScene && matchesStatus && matchesDateRange
|
||||
})
|
||||
}))
|
||||
})
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredRows.value.length / pageSize.value)))
|
||||
@@ -653,6 +654,8 @@ function buildDocumentRow(request, options = {}) {
|
||||
const claimId = normalized.claimId || normalized.id || documentNo
|
||||
const createdAtSource = normalized.createdAt || normalized.submittedAt || normalized.applyTime || normalized.updatedAt
|
||||
const updatedAtSource = normalized.updatedAt || normalized.submittedAt || normalized.createdAt || normalized.applyTime
|
||||
const createdSortTime = resolveDocumentSortTime(createdAtSource)
|
||||
const updatedSortTime = resolveDocumentSortTime(updatedAtSource)
|
||||
const documentTypeCode = normalized.documentTypeCode || DOCUMENT_TYPE_REIMBURSEMENT
|
||||
const documentTypeLabel =
|
||||
normalized.documentTypeLabel
|
||||
@@ -689,7 +692,9 @@ function buildDocumentRow(request, options = {}) {
|
||||
? false
|
||||
: isNewDocument({ ...normalized, source: options.source || 'owned', claimId, documentNo }, viewedDocumentKeys.value),
|
||||
updatedAtDisplay: formatDocumentListTime(updatedAtSource),
|
||||
sortTime: resolveDocumentSortTime(updatedAtSource)
|
||||
createdSortTime,
|
||||
updatedSortTime,
|
||||
sortTime: Math.max(createdSortTime, updatedSortTime)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,7 +756,7 @@ function mergeDocumentRows(rows) {
|
||||
}
|
||||
})
|
||||
|
||||
return Array.from(rowMap.values()).sort((left, right) => right.sortTime - left.sortTime)
|
||||
return sortDocumentRowsByLatestTime(Array.from(rowMap.values()))
|
||||
}
|
||||
|
||||
function resolveSourcePriority(row) {
|
||||
|
||||
Reference in New Issue
Block a user