-
Notifications
You must be signed in to change notification settings - Fork 14
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
#2741 - Ministry Filter Search Programs and Offerings [Location Search] #3819
base: main
Are you sure you want to change the base?
#2741 - Ministry Filter Search Programs and Offerings [Location Search] #3819
Conversation
Quality Gate passedIssues Measures |
); | ||
queryParams.push(`%${paginationOptions.locationNameSearch}%`); | ||
} | ||
if (paginationOptions.status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -331,6 +331,33 @@ export class EducationProgramService extends RecordDataModelService<EducationPro | |||
}); | |||
queryParams.push(`%${paginationOptions.searchCriteria}%`); | |||
} | |||
if (paginationOptions.programNameSearch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct me if i am wrong, the paginationOptions, if searched with only one criteria, paginationOptions.searchCriteria is used else the paginationOptions.programNameSearch and paginationOptions.locationNameSearch is pushed. If that is the case, either paginationOptions.searchCriteria should be pushed or the paginationOptions.programNameSearch and paginationOptions.locationNameSearch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
searchCriteria
should not be used for programs.
@sh16011993 what if we change the service models as below to ensure the searchCriteria
will not be present.
export interface BasePaginationOptions {
sortField?: string;
sortOrder?: FieldSortOrder;
page: number;
pageLimit: number;
}
/**
* Pagination option.
*/
export interface PaginationOptions extends BasePaginationOptions {
searchCriteria?: string;
}
export interface ProgramPaginationOptions extends BasePaginationOptions {
programNameSearch?: string;
locationNameSearch?: string;
status?: string;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please have a look on the comment
@MaxLength(PAGINATION_SEARCH_MAX_LENGTH) | ||
locationNameSearch?: string; | ||
@IsOptional() | ||
@IsIn([ProgramStatus.Approved, ProgramStatus.Declined, ProgramStatus.Pending]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that it is safe to replace the @IsIn
by @IsEnum(ProgramStatus)
.
locationNameSearch?: string; | ||
@IsOptional() | ||
@IsIn([ProgramStatus.Approved, ProgramStatus.Declined, ProgramStatus.Pending]) | ||
status?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the naming pattern from the others: statusSearch
.
} | ||
if (paginationOptions.status) { | ||
paginatedProgramQuery.andWhere( | ||
"programs.programStatus Ilike :programStatusSearchCriteria", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
programStatus
does not require Ilike
.
@@ -11,6 +11,12 @@ export interface PaginationOptions { | |||
pageLimit: number; | |||
} | |||
|
|||
export interface ProgramPaginationOptions extends PaginationOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see suggested changes here: https://github.com/bcgov/SIMS/pull/3819/files#r1813295340
if ( | ||
paginationOptions.searchCriteria && | ||
typeof paginationOptions.searchCriteria === "object" | ||
) { | ||
const searchCriteria = paginationOptions.searchCriteria; | ||
for (const searchCriterion in searchCriteria) { | ||
parameters.push(`${searchCriterion}=${searchCriteria[searchCriterion]}`); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
if (!paginationOptions.searchCriteria) {
return parameters.join("&");
}
// Search criteria.
if (typeof paginationOptions.searchCriteria === "string") {
// Single search criteria.
parameters.push(
`${PaginationParams.SearchCriteria}=${paginationOptions.searchCriteria}`,
);
return parameters.join("&");
}
// Multiple search criteria.
const searchCriteria = paginationOptions.searchCriteria;
for (const searchCriterion in paginationOptions.searchCriteria) {
parameters.push(`${searchCriterion}=${searchCriteria[searchCriterion]}`);
}
return parameters.join("&");
@@ -123,7 +123,7 @@ export enum PaginationParams { | |||
* todo: remove sortOrder: DataTableSortOrder when all primevue datatables are removed. | |||
*/ | |||
export interface PaginationOptions { | |||
searchCriteria?: string; | |||
searchCriteria?: string | Record<string, string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment to this parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason why the dropdown for statuses was not included in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as discussed in call with you, there was some confusion related to the status search
element's position in the UI and therefore I felt like it might be a little too much work in the same PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. Please take a look at the comments.
As a part of the PR, the following were completed:
&&
operation.api
to include thelocation
in the pagination for the search and updated thesql
query fetching the result.Note: Status search is not a part of this PR. Though, I have added the status as a part of the DTOs and interfaces.
Screenshots:
Location Search added:
Location Search with Program Search Empty:
Both Location and Program Search: