mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
97065: Make the error clickable and resend request if it failed
This commit is contained in:
@@ -53,8 +53,9 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
|
||||
* Perform a search for authorized collections with the current query and page
|
||||
* @param query Query to search objects for
|
||||
* @param page Page to retrieve
|
||||
* @param useCache Whether or not to use the cache
|
||||
*/
|
||||
search(query: string, page: number): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||
search(query: string, page: number, useCache: boolean = true): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||
let searchListService$: Observable<RemoteData<PaginatedList<Collection>>> = null;
|
||||
const findOptions: FindListOptions = {
|
||||
currentPage: page,
|
||||
@@ -69,7 +70,7 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
|
||||
findOptions);
|
||||
} else {
|
||||
searchListService$ = this.collectionDataService
|
||||
.getAuthorizedCollection(query, findOptions, true, false, followLink('parentCommunity'));
|
||||
.getAuthorizedCollection(query, findOptions, useCache, false, followLink('parentCommunity'));
|
||||
}
|
||||
return searchListService$.pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
|
@@ -186,23 +186,27 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
})
|
||||
).subscribe((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => {
|
||||
this.loading = false;
|
||||
const currentEntries = this.listEntries$.getValue();
|
||||
if (rd.hasSucceeded) {
|
||||
if (hasNoValue(currentEntries)) {
|
||||
this.listEntries$.next(rd.payload.page);
|
||||
} else {
|
||||
this.listEntries$.next([...currentEntries, ...rd.payload.page]);
|
||||
}
|
||||
// Check if there are more pages available after the current one
|
||||
this.hasNextPage = rd.payload.totalElements > this.listEntries$.getValue().length;
|
||||
} else {
|
||||
this.listEntries$.next([...(hasNoValue(currentEntries) ? [] : this.listEntries$.getValue()), new ListableNotificationObject(NotificationType.Error, 'dso-selector.results-could-not-be-retrieved', LISTABLE_NOTIFICATION_OBJECT.value)]);
|
||||
this.hasNextPage = false;
|
||||
}
|
||||
this.updateList(rd);
|
||||
}));
|
||||
}
|
||||
|
||||
updateList(rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) {
|
||||
this.loading = false;
|
||||
const currentEntries = this.listEntries$.getValue();
|
||||
if (rd.hasSucceeded) {
|
||||
if (hasNoValue(currentEntries)) {
|
||||
this.listEntries$.next(rd.payload.page);
|
||||
} else {
|
||||
this.listEntries$.next([...currentEntries, ...rd.payload.page]);
|
||||
}
|
||||
// Check if there are more pages available after the current one
|
||||
this.hasNextPage = rd.payload.totalElements > this.listEntries$.getValue().length;
|
||||
} else {
|
||||
this.listEntries$.next([...(hasNoValue(currentEntries) ? [] : this.listEntries$.getValue()), new ListableNotificationObject(NotificationType.Error, 'dso-selector.results-could-not-be-retrieved', LISTABLE_NOTIFICATION_OBJECT.value)]);
|
||||
this.hasNextPage = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a query to send for retrieving the current DSO
|
||||
*/
|
||||
@@ -214,8 +218,9 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
|
||||
* Perform a search for the current query and page
|
||||
* @param query Query to search objects for
|
||||
* @param page Page to retrieve
|
||||
* @param useCache Whether or not to use the cache
|
||||
*/
|
||||
search(query: string, page: number): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||
search(query: string, page: number, useCache: boolean = true): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||
return this.searchService.search(
|
||||
new PaginatedSearchOptions({
|
||||
query: query,
|
||||
@@ -223,7 +228,9 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
|
||||
pagination: Object.assign({}, this.defaultPagination, {
|
||||
currentPage: page
|
||||
})
|
||||
})
|
||||
}),
|
||||
null,
|
||||
useCache,
|
||||
).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
);
|
||||
@@ -266,12 +273,21 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits only when the {@link listableObject} is a {@link DSpaceObject}.
|
||||
* Handles the user clicks on the {@link ListableObject}s. When the {@link listableObject} is a
|
||||
* {@link ListableObject} it will retry the error when the user clicks it. Otherwise it will emit the {@link onSelect}.
|
||||
*
|
||||
* @param listableObject The {@link ListableObject} to evaluate
|
||||
*/
|
||||
onClick(listableObject: ListableObject): void {
|
||||
if (listableObject.getRenderTypes().includes(LISTABLE_NOTIFICATION_OBJECT.value)) {
|
||||
this.listEntries$.value.pop();
|
||||
this.hasNextPage = true;
|
||||
this.search(this.input.value ? this.input.value : '', this.currentPage$.value, false).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
).subscribe((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => {
|
||||
this.updateList(rd);
|
||||
});
|
||||
} else {
|
||||
this.onSelect.emit((listableObject as SearchResult<DSpaceObject>).indexableObject);
|
||||
}
|
||||
}
|
||||
|
@@ -1397,7 +1397,7 @@
|
||||
|
||||
"dso-selector.claim.item.create-from-scratch": "Create a new one",
|
||||
|
||||
"dso-selector.results-could-not-be-retrieved": "Something went wrong, please refresh the page to try again",
|
||||
"dso-selector.results-could-not-be-retrieved": "Something went wrong, please refresh again ↻",
|
||||
|
||||
"confirmation-modal.export-metadata.header": "Export metadata for {{ dsoName }}",
|
||||
|
||||
|
Reference in New Issue
Block a user