Skip to content

680 Fix change event reference for recent submission#979

Merged
tdonohue merged 4 commits intoDSpace:mainfrom
atmire:680-recent-submision-pagination-reload
Jan 27, 2021
Merged

680 Fix change event reference for recent submission#979
tdonohue merged 4 commits intoDSpace:mainfrom
atmire:680-recent-submision-pagination-reload

Conversation

@AndrewZachWood
Copy link
Copy Markdown
Contributor

@AndrewZachWood AndrewZachWood commented Jan 5, 2021

Fixes #680
I've updated the event change references to valid ones so the onPaginationChange(event) functions properly. Tested my additions in my local environment.

NOTE: The following error was reported before my changes but seems rather strange that this particular error is still present in my console given I've seen the pattern I used elsewhere in the code base without such an error. It's unclear to me why paginationConfig properties throw an error when attempting to be set. Would be great to get some insight on this:
core.js:4002 ERROR TypeError: Cannot read property 'currentPage' of undefined at CollectionPageComponent.push../src/app/+collection-page/collection-page.component.ts.CollectionPageComponent.onPaginationChange (collection-page.component.ts:112) at SafeSubscriber._next (collection-page.component.ts:102) at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:194) at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:132) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:76) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53) at TakeSubscriber.push../node_modules/rxjs/_esm5/internal/operators/take.js.TakeSubscriber._next (take.js:40) at TakeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53) at BehaviorSubject.push../node_modules/rxjs/_esm5/internal/BehaviorSubject.js.BehaviorSubject._subscribe (BehaviorSubject.js:22) at BehaviorSubject.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:43)

@AndrewZachWood AndrewZachWood linked an issue Jan 5, 2021 that may be closed by this pull request
@tdonohue tdonohue added this to the 7.0beta5 milestone Jan 5, 2021
@tdonohue tdonohue added bug component: Discovery related to discovery search or browse system labels Jan 5, 2021
@tdonohue tdonohue added the 1 APPROVAL pull request only requires a single approval to merge label Jan 5, 2021
@tdonohue tdonohue self-requested a review January 7, 2021 15:52
Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@AndrewZWood : I've looked at this and the code seems to work. I do still see the TypeError you mentioned. It seems to ONLY occur on the initial page load (for a Collection page) and not after clicking to the next page or similar. Here's the error I see:

ERROR TypeError: Cannot read property 'currentPage' of undefined
    at n.onPaginationChange (collection-page.component.ts:112)
    at t._next (collection-page.component.ts:102)
    at t.__tryOrUnsub (Subscriber.js.pre-build-optimizer.js:194)
    at t.next (Subscriber.js.pre-build-optimizer.js:132)
    at t._next (Subscriber.js.pre-build-optimizer.js:76)
    at t.next (Subscriber.js.pre-build-optimizer.js:53)
    at t._next (take.js.pre-build-optimizer.js:40)
    at t.next (Subscriber.js.pre-build-optimizer.js:53)
    at t._subscribe (BehaviorSubject.js.pre-build-optimizer.js:22)
    at t.e._trySubscribe (Observable.js.pre-build-optimizer.js:43)

If you look closely at that message, it looks to be calling out line 102 in the ngOnInit() function here:

So, while your new code seems correct, I think the ngOnInit() needs updates. The ngOnInit() code in that area seems odd to me...I'm not very familiar with this code, but in other components using similar pagination (e.g. top-level-community-list.component.ts) I'm not seeing that same ngOnInit() code.

This might be something @artlowel could answer more quickly than I could...but I'm wondering myself if that ngOnInit() code is needed or simply needs larger refactoring.

@artlowel
Copy link
Copy Markdown
Member

The issue here is this line. It passes the route params as an onPaginationChange event, but that's no longer valid. The structure of those events has changed. That change is the reason for this PR: it fixes the logic inside onPaginationChange.

If you create an interface for onPaginationChange events (they have a pagination: PaginationComponentOptions and a sort: SortOptions property), and add that as a type to the event param for onPaginationChange the compiler will point out these kinds of errors.

For now, that call using the route params can just be removed. The pagination component itself will parse the route for now. The ticket Tim mentioned above will ensure it moves to a more suitable location later.

@AndrewZachWood
Copy link
Copy Markdown
Contributor Author

AndrewZachWood commented Jan 20, 2021

@tdonohue Updated code to reflect on @artlowel 's input. Error is no longer present and I have tested functionality in my local environment.

@tdonohue
Copy link
Copy Markdown
Member

@AndrewZWood : It looks like you need to rebase on the latest main code as there are merge conflicts now. Keep in mind that we recently merged an update to Angular 10, which also changed some of the lint settings...so you may need to make minor formatting changes too after rebasing (if yarn lint throws errors).

@AndrewZachWood AndrewZachWood force-pushed the 680-recent-submision-pagination-reload branch 2 times, most recently from c704e47 to ba0b6f8 Compare January 20, 2021 19:27
@AndrewZachWood
Copy link
Copy Markdown
Contributor Author

AndrewZachWood commented Jan 20, 2021

@tdonohue Sorry about that....rebased and checked against the newer lint settings.

@tdonohue tdonohue self-requested a review January 21, 2021 15:52
Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 @AndrewZWood , I tested this today & it fixes the bug! The code also looks good to me, although we do need TypeDocs/comments to describe the new interface you are creating. Once those comments are added, this is ready to merge. Thanks!

import {PaginationComponentOptions} from './pagination-component-options.model';
import {SortOptions} from '../../core/cache/models/sort-options.model';

export interface PaginationChangeEvent {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tiny thing, please add TypeDocs to describe this new interface. We require TypeDocs/comments for any public classes/interfaces/methods.

@AndrewZachWood AndrewZachWood force-pushed the 680-recent-submision-pagination-reload branch from 85580f4 to b143ea7 Compare January 26, 2021 17:06
@tdonohue
Copy link
Copy Markdown
Member

Thanks @AndrewZWood ! Looks good now. Merging

@tdonohue tdonohue merged commit a64cb63 into DSpace:main Jan 27, 2021
abollini pushed a commit to 4Science/dspace-angular that referenced this pull request Nov 4, 2023
CST-12481

Approved-by: Andrea Bollini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug component: Discovery related to discovery search or browse system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recent Submissions pagination is not reloading properly

3 participants