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

[BI-1202] Germplasm Table: Add sorting to all columns #197

Merged
merged 4 commits into from
Mar 3, 2022

Conversation

ctucker3
Copy link
Contributor

Description

Story: https://breedinginsight.atlassian.net/jira/software/c/projects/BI/boards/1?modal=detail&selectedIssue=BI-1202

Made all germplasm table columns sortable and hooked them up to the backend sorting. Test was added on backend.

Dependencies

biapi: BI-1202

Testing

See bi-api PR for testing details.

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: <link to TAF run>

@ctucker3 ctucker3 changed the base branch from develop to v1.0-working February 28, 2022 19:02
@ctucker3 ctucker3 marked this pull request as ready for review February 28, 2022 19:05
Comment on lines 60 to 61
// program table
germplasmSort: new GermplasmSort(GermplasmSortField.AccessionNumber, SortOrder.Ascending)
Copy link
Contributor

Choose a reason for hiding this comment

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

just a code comment left over from the copy/paste that should be changed to read germplasm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 43 to 44
// germplasm tbale
export const UPDATE_GERMPLASM_SORT = 'updateGermplasmSort';
Copy link
Contributor

Choose a reason for hiding this comment

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

not a big deal, but another typo to fix if you are already updating the previous code comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 89 to 92
//program table
[UPDATE_GERMPLASM_SORT](state: SortState, sort: GermplasmSort) {
state.germplasmSort.field = sort.field;
state.germplasmSort.order = sort.order;
Copy link
Contributor

Choose a reason for hiding this comment

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

another code comment correction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@dmeidlin dmeidlin left a comment

Choose a reason for hiding this comment

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

Just sharing some thoughts on ways to better check for type when using the BrAPIService. What do you think?

Comment on lines 131 to 138
// Set sort
const params = {
sortField: this.germplasmSort.field,
sortOrder: this.germplasmSort.order
};
// GET call
const response = await BrAPIService.get(BrAPIType.GERMPLASM, params, this.activeProgram!.id!,
this.paginationController.pageSize, this.paginationController.currentPage - 1);
Copy link
Contributor

@dmeidlin dmeidlin Mar 1, 2022

Choose a reason for hiding this comment

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

Using a BrAPIService and passing in the enum to specify the BrAPI variable makes a lot of sense. Since we already have the PaginationQuery and Sort models it would also be good to type the service args to use these, too.
A generic could be used for the sort params type, so the call would look like this await BrAPIService.get<GermplasmSort>(BrAPIType.GERMPLASM, params, this.activeProgram!.id!, {this.paginationController.pageSize, this.pagnationCOntroller.currentPage - 1}); where const params: GermplasmSort = {...}; is as in line 132.

Also, instead of throwing errors if either the pagination query or sort query is undefined, default values could be used. For example, like in ProgramLocationService.ts,
static getAll(programId: string, paginationQuery: PaginationQuery = new PaginationQuery(1, 50, true), sort: LocationSort = new LocationSort(LocationSortField.Name, SortOrder.Ascending)): Promise<[ProgramLocation[], Metadata]> {...}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I made the sort params generic and made the pagination be passed in as an object.

I removed those pagination checks, but didn't add defaults. Default sort fields and default pagination is handled on the backend so it might be best to have only one place for defaults.

@ctucker3 ctucker3 requested a review from dmeidlin March 2, 2022 14:25
Copy link
Contributor

@dmeidlin dmeidlin left a comment

Choose a reason for hiding this comment

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

just a reminder for the change we talked about.

Comment on lines 28 to 29
public static async get(type: BrAPIType, programId: string, sort: { field: string, order: SortOrder },
pagination: {pageSize: number, page: number}): Promise<BiResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

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

just use here a generic T for the sort field type.
public static async get<T>(type: BrAPIType, programId: string, sort: { field: T, order: SortOrder }, pagination: {pageSize: number, page: number}): Promise<BiResponse> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 131 to 133
// GET call
const response = await BrAPIService.get(BrAPIType.GERMPLASM, this.activeProgram!.id!, this.germplasmSort,
{ pageSize: this.paginationController.pageSize, page: this.paginationController.currentPage - 1 });
Copy link
Contributor

Choose a reason for hiding this comment

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

and assign the GermplasmSortField type at the method call.
const response = await BrAPIService.get<GermplasmSortField>(BrAPIType.GERMPLASM, this.activeProgram!.id!, this.germplasmSort, { pageSize: this.paginationController.pageSize, page: this.paginationController.currentPage - 1 });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@ctucker3 ctucker3 requested a review from dmeidlin March 3, 2022 13:43
@ctucker3 ctucker3 merged commit c9d1ef7 into v1.0-working Mar 3, 2022
@ctucker3 ctucker3 deleted the feature/BI-1202 branch March 3, 2022 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants