Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint Mayne release #175

Merged
merged 4 commits into from
Sep 24, 2024
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
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"vue.volar",
"vue.vscode-typescript-vue-plugin"
"42crunch.vscode-openapi"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BackButton from '@/components/common/BackButton.vue';
import {
EditableDropdown,
Dropdown,
FormNavigationGuard,
InputMask,
InputText,
RadioList,
Expand Down Expand Up @@ -293,9 +294,6 @@ async function emailConfirmation(activityId: string, enquiryId: string) {
<div v-if="!assignedActivityId">
<div class="mb-2 p-0">
<BackButton
:confirm-leave="editable && !!formUpdated"
confirm-message="Are you sure you want to leave this page?
Any unsaved changes will be lost. Please save as draft first."
:route-name="getBackButtonConfig.routeName"
:text="getBackButtonConfig.text"
/>
Expand All @@ -317,6 +315,8 @@ async function emailConfirmation(activityId: string, enquiryId: string) {
@submit="confirmSubmit"
@change="formUpdated = true"
>
<FormNavigationGuard v-if="editable && !!formUpdated" />

<input
type="hidden"
name="activityId"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';

import { Spinner } from '@/components/layout';
import {
Expand All @@ -17,10 +18,19 @@ import { enquiryService } from '@/services';
import { RouteName } from '@/utils/enums/application';
import { IntakeStatus } from '@/utils/enums/housing';
import { formatDate } from '@/utils/formatters';
import { toNumber } from '@/utils/utils';

import type { Ref } from 'vue';
import type { Enquiry } from '@/types';

// Types
type Pagination = {
rows?: number;
order?: number;
field?: string;
page?: number;
};

// Props
const { loading, enquiries } = defineProps<{
loading: boolean;
Expand All @@ -31,11 +41,27 @@ const { loading, enquiries } = defineProps<{
const emit = defineEmits(['enquiry:delete']);

// State
const route = useRoute();
const selection: Ref<Enquiry | undefined> = ref(undefined);
const pagination: Ref<Pagination> = ref({
rows: 10,
order: -1,
field: 'submittedAt',
page: 0
});

// read from query params if tab is set to enquiry otherwise use default values
if (route.query.tab === '1') {
pagination.value.rows = toNumber(route.query.rows as string) ?? 10;
pagination.value.order = toNumber(route.query.order as string) ?? -1;
pagination.value.field = (route.query.field as string) ?? 'submittedAt';
pagination.value.page = toNumber(route.query.page as string) ?? 0;
}

// Actions
const confirm = useConfirm();
const toast = useToast();
const router = useRouter();

function onDelete(enquiryId: string, activityId: string) {
confirm.require({
Expand All @@ -61,6 +87,20 @@ function onDelete(enquiryId: string, activityId: string) {
const filters = ref({
global: { value: null, matchMode: FilterMatchMode.CONTAINS }
});

// Actions
function updateQueryParams() {
router.replace({
name: RouteName.HOUSING_SUBMISSIONS,
query: {
rows: pagination.value.rows ?? undefined,
order: pagination.value.order ?? undefined,
field: pagination.value.field ?? undefined,
page: pagination.value.page ?? undefined,
tab: route.query.tab ?? 1
}
});
}
</script>

<template>
Expand All @@ -73,13 +113,35 @@ const filters = ref({
scrollable
responsive-layout="scroll"
:paginator="true"
:rows="10"
sort-field="submittedAt"
:sort-order="-1"
:rows="pagination.rows"
:sort-field="pagination.field"
:sort-order="pagination.order"
paginator-template="RowsPerPageDropdown CurrentPageReport PrevPageLink NextPageLink "
current-page-report-template="{first}-{last} of {totalRecords}"
:rows-per-page-options="[10, 20, 50]"
selection-mode="single"
:first="pagination.page && pagination.rows ? pagination.page * pagination.rows : 0"
@update:sort-field="
(e) => {
pagination.field = e;
pagination.page = 0;
updateQueryParams();
}
"
@update:sort-order="
(e) => {
pagination.order = e ?? -1;
pagination.page = 0;
updateQueryParams();
}
"
@page="
(e) => {
pagination.page = e.page;
pagination.rows = e.rows;
updateQueryParams();
}
"
>
<template #empty>
<div class="flex justify-content-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Calendar,
Checkbox,
Dropdown,
FormNavigationGuard,
InputMask,
InputNumber,
RadioList,
Expand Down Expand Up @@ -490,12 +491,10 @@ onBeforeMount(async () => {
<template>
<div v-if="!assignedActivityId && !assistanceAssignedActivityId">
<BackButton
:confirm-leave="editable && !!formUpdated"
confirm-message="Are you sure you want to leave this page?
Any unsaved changes will be lost. Please save as draft first."
:route-name="getBackButtonConfig.routeName"
:text="getBackButtonConfig.text"
/>

<div class="flex justify-content-center app-primary-color mt-3">
<h3>Project Investigation Form</h3>
</div>
Expand All @@ -511,6 +510,8 @@ onBeforeMount(async () => {
@submit="confirmSubmit"
@change="() => (formUpdated = true)"
>
<FormNavigationGuard v-if="editable && !!formUpdated" />

<SubmissionAssistance
v-if="editable && values?.applicant"
:form-errors="errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';

import { Spinner } from '@/components/layout';
import {
Expand All @@ -18,10 +18,19 @@ import { submissionService } from '@/services';
import { useAuthZStore } from '@/store';
import { Action, BasicResponse, Initiative, Resource, RouteName } from '@/utils/enums/application';
import { formatDate } from '@/utils/formatters';
import { toNumber } from '@/utils/utils';

import type { Ref } from 'vue';
import type { Submission } from '@/types';

// Types
type Pagination = {
rows?: number;
order?: number;
field?: string;
page?: number;
};

// Props
const { loading, submissions } = defineProps<{
loading: boolean;
Expand All @@ -35,7 +44,23 @@ const emit = defineEmits(['submission:delete']);
const authzStore = useAuthZStore();

// State
const route = useRoute();
const selection: Ref<Submission | undefined> = ref(undefined);
const dataTable = ref(null);
const pagination: Ref<Pagination> = ref({
rows: 10,
order: -1,
field: 'submittedAt',
page: 0
});

// read from query params if tab is set to enquiry otherwise use default values
if (!route.query.tab || route.query.tab === '0') {
pagination.value.rows = toNumber(route.query.rows as string) ?? 10;
pagination.value.order = toNumber(route.query.order as string) ?? -1;
pagination.value.field = (route.query.field as string) ?? 'submittedAt';
pagination.value.page = toNumber(route.query.page as string) ?? 0;
}

// Actions
const confirmDialog = useConfirm();
Expand Down Expand Up @@ -101,10 +126,25 @@ function isFinanciallySupported(data: Submission) {
return BasicResponse.NO;
}
}

// Actions
function updateQueryParams() {
router.replace({
name: RouteName.HOUSING_SUBMISSIONS,
query: {
rows: pagination.value.rows ?? undefined,
order: pagination.value.order ?? undefined,
field: pagination.value.field ?? undefined,
page: pagination.value.page ?? undefined,
tab: route.query.tab ?? 0
}
});
}
</script>

<template>
<DataTable
ref="dataTable"
v-model:filters="filters"
v-model:selection="selection"
:loading="loading"
Expand All @@ -113,13 +153,35 @@ function isFinanciallySupported(data: Submission) {
scrollable
responsive-layout="scroll"
:paginator="true"
:rows="10"
sort-field="submittedAt"
:sort-order="-1"
:rows="pagination.rows"
:sort-field="pagination.field"
:sort-order="pagination.order"
paginator-template="RowsPerPageDropdown CurrentPageReport PrevPageLink NextPageLink "
current-page-report-template="{first}-{last} of {totalRecords}"
:rows-per-page-options="[10, 20, 50]"
selection-mode="single"
:first="pagination.page && pagination.rows ? pagination.page * pagination.rows : 0"
@update:sort-field="
(e) => {
pagination.field = e;
pagination.page = 0;
updateQueryParams();
}
"
@update:sort-order="
(e) => {
pagination.order = e ?? -1;
pagination.page = 0;
updateQueryParams();
}
"
@page="
(e) => {
pagination.page = e.page;
pagination.rows = e.rows;
updateQueryParams();
}
"
>
<template #empty>
<div class="flex justify-content-center">
Expand Down
Loading
Loading