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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
IsArray,
IsBoolean,
IsDateString,
IsEnum,
IsIn,
IsOptional,
Expand All @@ -19,7 +20,7 @@ import {
import { Transform } from "class-transformer";
import { ToBoolean } from "../../utilities/class-transform";
import { AppealType } from "../../services";

import { AllowIf, IsDateAfter } from "../../utilities/class-validation";
/**
* Common parameters used when an API result
* must enable pagination and search options.
Expand Down Expand Up @@ -137,7 +138,34 @@ export class ProgramsPaginationOptionsAPIInDTO extends PaginationOptionsAPIInDTO

export class OfferingsPaginationOptionsAPIInDTO extends PaginationOptionsAPIInDTO {
@IsOptional()
@IsIn(["name"])
@IsEnum(OfferingIntensity)
intensityFilter?: OfferingIntensity;

@IsOptional()
@IsDateString()
@AllowIf(
(paginationOptions: OfferingsPaginationOptionsAPIInDTO) =>
!!paginationOptions.studyStartDateToFilter,
"studyStartDateFromFilter",
)
studyStartDateFromFilter?: string;

@IsOptional()
@IsDateString()
@AllowIf(
(paginationOptions: OfferingsPaginationOptionsAPIInDTO) =>
!!paginationOptions.studyStartDateFromFilter,
"studyStartDateToFilter",
)
@IsDateAfter(
(paginationOptions: OfferingsPaginationOptionsAPIInDTO) =>
paginationOptions.studyStartDateFromFilter,
"studyStartDateToFilter",
)
studyStartDateToFilter?: string;

@IsOptional()
@IsIn(["name", "offeringDelivered", "studyStartDate", "studyEndDate"])
sortField?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import {
} from "./education-program-offering.service.models";
import {
sortOfferingsColumnMap,
PaginationOptions,
PaginatedResults,
OFFERING_STUDY_BREAK_MAX_DAYS,
OFFERING_VALIDATIONS_STUDY_BREAK_COMBINED_PERCENTAGE_THRESHOLD,
OfferingPaginationOptions,
} from "../../utilities";
import {
CustomNamedError,
Expand Down Expand Up @@ -341,18 +341,18 @@ export class EducationProgramOfferingService extends RecordDataModelService<Educ
}

/**
* This is to fetch all the Education Offering
* that are associated with the Location and Program
* @param locationId location id
* @param programId program id
* @param offeringTypes offering type
* @param paginationOptions pagination options
* @returns offering summary and total offering count
* Fetches all the Education Offering
* that are associated with the Location and Program.
* @param locationId the offering location id to be fetched.
* @param programId the program id to be fetched.
* @param paginationOptions the pagination and filter options.
* @param offeringTypes the offering types to be filtered.
* @returns offering summary and total offering count.
*/
async getAllEducationProgramOffering(
locationId: number,
programId: number,
paginationOptions: PaginationOptions,
paginationOptions: OfferingPaginationOptions,
offeringTypes?: OfferingTypes[],
): Promise<PaginatedResults<EducationProgramOffering>> {
const DEFAULT_SORT_FIELD = "name";
Expand Down Expand Up @@ -384,6 +384,26 @@ export class EducationProgramOfferingService extends RecordDataModelService<Educ
searchCriteria: `%${paginationOptions.searchCriteria}%`,
});
}
if (paginationOptions.intensityFilter) {
offeringsQuery.andWhere(
"offerings.offeringIntensity = :intensityFilter",
{
intensityFilter: paginationOptions.intensityFilter,
},
);
}
if (
paginationOptions.studyStartDateFromFilter &&
paginationOptions.studyStartDateToFilter
) {
offeringsQuery.andWhere(
"offerings.studyStartDate BETWEEN :startDate AND :endDate",
{
startDate: paginationOptions.studyStartDateFromFilter,
endDate: paginationOptions.studyStartDateToFilter,
},
);
}
// sorting
if (paginationOptions.sortField && paginationOptions.sortOrder) {
offeringsQuery.orderBy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export interface CASInvoicePaginationOptions extends BasePaginationOptions {
/**
* CAS invoice batches specific parameters.
*/
export interface CASInvoiceBatchesPaginationOptions
extends BasePaginationOptions {
export interface CASInvoiceBatchesPaginationOptions extends BasePaginationOptions {
approvalStatusSearch?: CASInvoiceBatchApprovalStatus[];
}

Expand Down Expand Up @@ -75,3 +74,21 @@ export interface COEPaginationOptions extends PaginationOptions {
export interface StudentAppealPaginationOptions extends PaginationOptions {
appealType: AppealType;
}

/**
* Offering Pagination options.
*/
export interface OfferingPaginationOptions extends PaginationOptions {
/**
* Offering intensity to filter the offerings.
*/
intensityFilter?: OfferingIntensity;
/**
* Study start date from filter.
*/
studyStartDateFromFilter?: string;
/**
* Study start date to filter.
*/
studyStartDateToFilter?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ export const sortApplicationsColumnMap = (fieldName: string): string => {
export const sortOfferingsColumnMap = (fieldName: string): string => {
const offeringSortOptions = {
name: "offerings.name",
offeringDelivered: "offerings.offeringDelivered",
studyStartDate: "offerings.studyStartDate",
studyEndDate: "offerings.studyEndDate",
};
return offeringSortOptions[fieldName] ?? null;

if (!offeringSortOptions[fieldName]) {
throw new Error(`Sorting by ${fieldName} is not supported.`);
}
return offeringSortOptions[fieldName];
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
<v-card>
<v-container :fluid="true">
<program-details
:programId="programId"
:locationId="locationId"
:educationProgram="educationProgram"
:program-id="programId"
:location-id="locationId"
:education-program="educationProgram"
:allow-edit="allowEdit && isProgramEditable"
:allow-deactivate="allowDeactivate && isProgramEditable"
@program-data-updated="$emit('programDataUpdated')"
/>
<hr class="horizontal-divider" />
<offering-summary
:programId="programId"
:locationId="locationId"
:isEditAllowed="
educationProgram.isActive && !educationProgram.isExpired
"
:institutionId="institutionId"
:program-id="programId"
:location-id="locationId"
:allow-edit="allowEdit && isProgramEditable"
:institution-id="institutionId"
/>
</v-container>
</v-card>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { computed, defineComponent, PropType } from "vue";
import ProgramDetails from "@/components/common/ProgramDetails.vue";
import OfferingSummary from "@/components/common/OfferingSummary.vue";
import { EducationProgramAPIOutDTO } from "@/services/http/dto";
Expand All @@ -41,14 +41,34 @@ export default defineComponent({
required: true,
},
educationProgram: {
type: Object,
type: Object as PropType<EducationProgramAPIOutDTO>,
required: true,
default: {} as EducationProgramAPIOutDTO,
},
institutionId: {
type: Number,
required: false,
default: undefined,
},
allowEdit: {
type: Boolean,
required: false,
default: true,
},
allowDeactivate: {
type: Boolean,
required: false,
default: true,
},
},
setup(props) {
const isProgramEditable = computed(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This doesn't need to be computed as it's not used in the template.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it actually caused a bug after I removed the computed, I don't know much about why but I ended up adding it back

() =>
props.educationProgram.isActive && !props.educationProgram.isExpired,
);
return {
isProgramEditable,
};
},
});
</script>
Loading
Loading