Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions web/src/components/case-details/civil/CivilDocumentsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<template v-slot:item="{ props: itemProps, item }">
<v-list-item
v-bind="itemProps"
:title="item.title + ' (' + categoryCount(item.raw) + ')'"
:title="
categoryTitle(item.title) + ' (' + categoryCount(item.raw) + ')'
"
></v-list-item>
</template>
</v-select>
Expand Down Expand Up @@ -142,6 +144,10 @@
throw new Error('Service is undefined.');
}

const SCHEDULED_CATEGORY = 'Scheduled';
const CSR_CATEGORY = 'CSR';
const CSR_CATEGORY_DESC = 'Court Summary';

const selectedItems = ref<civilDocumentType[]>([]);
const selectedBinderItems = ref<civilDocumentType[]>([]);
const showActionbar = computed<boolean>(() => selectedItems.value.length > 1);
Expand Down Expand Up @@ -196,19 +202,24 @@
['judgeId']: commonStore.userInfo?.userId,
};

const documentCategories = ref<any[]>([
...new Map(
props.documents
.filter((d) => d.category)
.map((doc) => [
doc.category,
{ title: doc.category, value: doc.category },
])
).values(),
]);
const scheduledDocuments = props.documents.filter(
(doc) => doc.nextAppearanceDt
);

const documentCategories = ref<string[]>(
(scheduledDocuments.length > 0 ? [SCHEDULED_CATEGORY] : []).concat(
Array.from(
new Set(
props.documents.filter((d) => d.category).map((doc) => doc.category)
)
)
)
);
const filterByCategory = (item: civilDocumentType) =>
!selectedCategory.value ||
item.category?.toLowerCase() === selectedCategory.value?.toLowerCase();
(selectedCategory.value === SCHEDULED_CATEGORY
? item.nextAppearanceDt
: item.category?.toLowerCase() === selectedCategory.value?.toLowerCase());

const filteredDocuments = computed(() =>
props.documents.filter(filterByCategory)
Expand All @@ -235,8 +246,17 @@
return filteredAndSorted;
});

const categoryCount = (type: any): number =>
props.documents.filter((doc) => doc.category === type.value).length;
const categoryCount = (category: string): number =>
category.toLowerCase() === SCHEDULED_CATEGORY.toLowerCase()
? props.documents.filter((doc) => doc.nextAppearanceDt).length
: props.documents.filter(
(doc) => doc.category?.toLowerCase() === category.toLowerCase()
).length;

const categoryTitle = (category: string): string =>
category.toLowerCase() === CSR_CATEGORY.toLowerCase()
? CSR_CATEGORY_DESC
: category;

onMounted(async () => {
try {
Expand Down Expand Up @@ -279,7 +299,7 @@
documents.push({
documentType,
documentData,
groupKeyOne: documentData.fileNumberText,
groupKeyOne: documentData.fileNumberText!,
groupKeyTwo: '',
documentName:
item.documentTypeDescription +
Expand Down
19 changes: 19 additions & 0 deletions web/tests/components/case-details/civil/CivilDocumentsView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ describe('CivilDocumentsView.vue', () => {
issue: [{ issueTypeDesc: 'Issue2' }],
documentSupport: [{ actCd: 'Act2' }],
},
{
civilDocumentId: '3',
category: 'Pleadings',
documentTypeDescription: 'Civil Document 3',
filedDt: '2023-02-01',
nextAppearanceDt: '2023-03-01',
filedBy: [{ roleTypeCode: 'Role3' }],
issue: [{ issueTypeDesc: 'Issue3' }],
documentSupport: [{ actCd: 'Act3' }],
},
];
beforeEach(() => {
wrapper = shallowMount(CivilDocumentsView, {
Expand Down Expand Up @@ -128,4 +138,13 @@ describe('CivilDocumentsView.vue', () => {

expect(wrapper.vm.selectedBinderItems).toEqual([]);
});

it('inserts "Scheduled" option when a document has a next appearance date', async () => {
expect(wrapper.vm.documentCategories).toEqual([
'Scheduled',
mockDocuments[0].category,
mockDocuments[1].category,
mockDocuments[2].category,
]);
});
});
Loading