Skip to content

Commit

Permalink
Implement Project List View
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwong89 committed Jul 23, 2024
1 parent b0bd1fa commit a170cc2
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/src/controllers/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,10 @@ const controller = {
never,
{
activityId?: Array<string>;
submissionId?: Array<string>;
intakeStatus?: Array<string>;
includeUser?: string;
submissionId?: Array<string>;
submissionType?: Array<string>;
}
>,
res: Response,
Expand Down
1 change: 1 addition & 0 deletions app/src/routes/v1/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ router.delete(
router.get('/search', (req: Request, res: Response, next: NextFunction): void => {
submissionController.searchSubmissions(req, res, next);
});

router.get(
'/:submissionId',
submissionValidator.getSubmission,
Expand Down
8 changes: 6 additions & 2 deletions app/src/services/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ const service = {
* @function searchSubmissions
* Search and filter for specific submission
* @param {string[]} [params.activityId] Optional array of uuids representing the activity ID
* @param {string[]} [params.submissionId] Optional array of uuids representing the submission ID
* @param {string[]} [params.intakeStatus] Optional array of strings representing the intake status
* @param {boolean} [params.includeUser] Optional boolean representing whether the linked user should be included
* @param {string[]} [params.submissionId] Optional array of uuids representing the submission ID
* @param {string[]} [params.submissionType] Optional array of strings representing the submission type
* @returns {Promise<(Submission | null)[]>} The result of running the findMany operation
*/
searchSubmissions: async (params: SubmissionSearchParameters) => {
Expand All @@ -228,11 +229,14 @@ const service = {
{
activity_id: { in: params.activityId }
},
{
intake_status: { in: params.intakeStatus }
},
{
submission_id: { in: params.submissionId }
},
{
intake_status: { in: params.intakeStatus }
submission_type: { in: params.submissionType }
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/types/SubmissionSearchParameters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export type SubmissionSearchParameters = {
activityId?: Array<string>;
submissionId?: Array<string>;
intakeStatus?: Array<string>;
includeUser?: boolean;
submissionId?: Array<string>;
submissionType?: Array<string>;
includeDeleted?: boolean;
};
8 changes: 7 additions & 1 deletion app/src/utils/constants/housing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ export const PROJECT_LOCATION_LIST = [ProjectLocation.LOCATION_COORDINATES, Proj

export const QUEUE_PRIORITY = [1, 2, 3];

export const SUBMISSION_TYPE_LIST = [SubmissionType.GUIDANCE, SubmissionType.INAPPLICABLE];
export const SUBMISSION_TYPE_LIST = [
SubmissionType.ESCALATION,
SubmissionType.GENERAL_ENQUIRY,
SubmissionType.GUIDANCE,
SubmissionType.INAPPLICABLE,
SubmissionType.STATUS_REQUEST
];
5 changes: 3 additions & 2 deletions app/src/validators/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ const schema = {
searchSubmissions: {
query: Joi.object({
activityId: Joi.array().items(Joi.string()),
submissionId: Joi.array().items(uuidv4),
intakeStatus: Joi.array().items(...INTAKE_STATUS_LIST),
includeUser: Joi.boolean()
includeUser: Joi.boolean(),
submissionId: Joi.array().items(uuidv4),
submissionType: Joi.array().items(...SUBMISSION_TYPE_LIST)
})
},
updateIsDeletedFlag: {
Expand Down
98 changes: 98 additions & 0 deletions frontend/src/components/housing/projects/ProjectsList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<script setup lang="ts">
import { ref } from 'vue';
import { Spinner } from '@/components/layout';
import { Button, Column, DataTable, useConfirm, useToast } from '@/lib/primevue';

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'Button' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'useConfirm' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'useToast' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'Button' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'useConfirm' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'useToast' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'Button' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'useConfirm' is defined but never used

Check warning on line 5 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'useToast' is defined but never used
import { submissionService } from '@/services';

Check warning on line 6 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'submissionService' is defined but never used

Check warning on line 6 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'submissionService' is defined but never used

Check warning on line 6 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'submissionService' is defined but never used
import { RouteName } from '@/utils/enums/application';
import { IntakeStatus } from '@/utils/enums/housing';

Check warning on line 8 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'IntakeStatus' is defined but never used

Check warning on line 8 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'IntakeStatus' is defined but never used

Check warning on line 8 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'IntakeStatus' is defined but never used
import { formatDate } from '@/utils/formatters';

Check warning on line 9 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'formatDate' is defined but never used

Check warning on line 9 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'formatDate' is defined but never used

Check warning on line 9 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'formatDate' is defined but never used
import type { Ref } from 'vue';
import type { Submission } from '@/types';
// Props
type Props = {
loading: boolean;
submissions: Array<Submission> | undefined;
};
const props = withDefaults(defineProps<Props>(), {});
// State
const selection: Ref<Submission | undefined> = ref(undefined);
// Actions
// const confirm = useConfirm();
// const toast = useToast();
const sortTest = (e = 'meh') => {

Check warning on line 29 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'sortTest' is assigned a value but never used

Check warning on line 29 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'sortTest' is assigned a value but never used

Check warning on line 29 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'sortTest' is assigned a value but never used
console.log('sorttest', e);

Check warning on line 30 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Unexpected console statement

Check warning on line 30 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 30 in frontend/src/components/housing/projects/ProjectsList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement
return -1;
};
</script>

<template>
<DataTable
v-model:selection="selection"
:loading="loading"
:value="props.submissions"
data-key="submissionId"
scrollable
responsive-layout="scroll"
:paginator="true"
:rows="10"
>
<template #empty>
<div class="flex justify-content-center">
<h3>No active projects</h3>
</div>
</template>
<template #loading>
<Spinner />
</template>
<Column
field="projectName"
header="Project Name"
:sortable="true"
style="min-width: 200px"
>
<template #body="{ data }">
<div :data-activityId="data.activityId">
<router-link
:to="{
name: RouteName.HOUSING_SUBMISSION_INTAKE,
query: { activityId: data.activityId, submissionId: data.submissionId }
}"
>
{{ data.projectName }}
</router-link>
</div>
</template>
</Column>
<Column
field="activityId"
header="Confirmation ID"
/>
<Column
field="applicationStatus"
header="Status"
:sortable="true"
style="min-width: 150px"
/>
<Column
field="user"
header="Navigator"
>
<template #body="{ data }">
<div>{{ data?.user?.firstName }} {{ data?.user?.lastName }}</div>
</template>
</Column>
<Column
field="submittedAt"
header="date"
:sortable="true"
style="min-width: 150px"
/>
</DataTable>
</template>
2 changes: 1 addition & 1 deletion frontend/src/components/layout/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ onMounted(() => {
},
{
label: 'Status of application/permit',
route: RouteName.COMING_SOON,
route: RouteName.HOUSING_PROJECTS,
access: Permissions.NAVIGATION_HOUSING_STATUS_TRACKER
}
],
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ const routes: Array<RouteRecordRaw> = [
}
]
},
{
path: 'projects',
name: RouteName.HOUSING_PROJECTS,
component: () => import('@/views/housing/ProjectsView.vue'),
meta: {
access: [Permissions.NAVIGATION_HOUSING]
}
},
{
path: 'submissions',
name: RouteName.HOUSING_SUBMISSIONS,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/utils/enums/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export enum RouteName {
HOUSING_ENQUIRY = 'housing_enquiry',
HOUSING_ENQUIRY_INTAKE = 'housing_enquiry_intake',
HOUSING_GUIDE = 'housing_guide',
HOUSING_PROJECTS = 'housing_projects',
HOUSING_SUBMISSION = 'housing_submission',
HOUSING_SUBMISSION_INTAKE = 'housing_submission_intake',
HOUSING_SUBMISSIONS = 'housing_submissions',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/housing/HousingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const items = ref([
{
top: 'Check the status of your applications and/or permits',
icon: 'fa-bars-progress',
route: RouteName.COMING_SOON,
route: RouteName.HOUSING_PROJECTS,
access: Permissions.NAVIGATION_HOUSING_STATUS_TRACKER
}
]);
Expand Down
94 changes: 94 additions & 0 deletions frontend/src/views/housing/ProjectsView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { Button } from '@/lib/primevue';
import { RouteName } from '@/utils/enums/application';
import { ApplicationStatus, IntakeStatus, SubmissionType } from '@/utils/enums/housing';
import ProjectsList from '@/components/housing/projects/ProjectsList.vue';
import { submissionService } from '@/services';
import type { Ref } from 'vue';
import type { Submission } from '@/types';
const router = useRouter();
// Enums
const IntakeSearchParams: String[] = [IntakeStatus.ASSIGNED, IntakeStatus.COMPLETED];
const SubmissionSearchParams: String[] = [SubmissionType.GUIDANCE];
// State
const loading: Ref<boolean> = ref(true);
const submissions: Ref<Array<Submission>> = ref([]);
// Actions
// Sort ApplicationStatus "completed" to the bottom of list, then sort by submission date
function customSort(a: Submission, b: Submission): number {
if (a.applicationStatus == ApplicationStatus.COMPLETED) {
if (b.applicationStatus == ApplicationStatus.COMPLETED) {
return a.submittedAt > b.submittedAt ? -1 : 1;
} else {
return 1;
}
}
if (b.applicationStatus == ApplicationStatus.COMPLETED) {
return -1;
}
return a.submittedAt > b.submittedAt ? -1 : 1;
}
onMounted(async () => {
const [unsorted] = (
await Promise.all([
submissionService.searchSubmissions({
includeUser: true,
intakeStatus: IntakeSearchParams,
submissionType: SubmissionSearchParams
})
])
).map((r) => r.data);
submissions.value = unsorted.sort(customSort);
loading.value = false;
});
</script>

<template>
<div>
<Button
class="p-0"
text
>
<router-link :to="{ name: RouteName.HOUSING }">
<span class="app-primary-color">Housing</span>
</router-link>
</Button>
/
<span class="font-bold">Applications and Permits</span>
</div>
<h1>Application and Permits</h1>
<div class="mt-1 mb-3 flex justify-content-between">
<h3 class="mb-0">My Projects</h3>
<Button
class="p-button-sm"
outlined
label="+ New project investigation"
@click="router.push({ name: RouteName.HOUSING_SUBMISSION_INTAKE })"
/>
</div>
<ProjectsList
:loading="loading"
:submissions="submissions"
/>
<div>{{ submissions.map((x) => x.submittedAt) }}</div>
</template>

<style scoped lang="scss">
a {
text-decoration: none;
}
</style>

0 comments on commit a170cc2

Please sign in to comment.