mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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
|
* Perform a search for authorized collections with the current query and page
|
||||||
* @param query Query to search objects for
|
* @param query Query to search objects for
|
||||||
* @param page Page to retrieve
|
* @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;
|
let searchListService$: Observable<RemoteData<PaginatedList<Collection>>> = null;
|
||||||
const findOptions: FindListOptions = {
|
const findOptions: FindListOptions = {
|
||||||
currentPage: page,
|
currentPage: page,
|
||||||
@@ -69,7 +70,7 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
|
|||||||
findOptions);
|
findOptions);
|
||||||
} else {
|
} else {
|
||||||
searchListService$ = this.collectionDataService
|
searchListService$ = this.collectionDataService
|
||||||
.getAuthorizedCollection(query, findOptions, true, false, followLink('parentCommunity'));
|
.getAuthorizedCollection(query, findOptions, useCache, false, followLink('parentCommunity'));
|
||||||
}
|
}
|
||||||
return searchListService$.pipe(
|
return searchListService$.pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
|
@@ -186,23 +186,27 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
).subscribe((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => {
|
).subscribe((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => {
|
||||||
this.loading = false;
|
this.updateList(rd);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
* 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
|
* Perform a search for the current query and page
|
||||||
* @param query Query to search objects for
|
* @param query Query to search objects for
|
||||||
* @param page Page to retrieve
|
* @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(
|
return this.searchService.search(
|
||||||
new PaginatedSearchOptions({
|
new PaginatedSearchOptions({
|
||||||
query: query,
|
query: query,
|
||||||
@@ -223,7 +228,9 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
|
|||||||
pagination: Object.assign({}, this.defaultPagination, {
|
pagination: Object.assign({}, this.defaultPagination, {
|
||||||
currentPage: page
|
currentPage: page
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
|
null,
|
||||||
|
useCache,
|
||||||
).pipe(
|
).pipe(
|
||||||
getFirstCompletedRemoteData()
|
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
|
* @param listableObject The {@link ListableObject} to evaluate
|
||||||
*/
|
*/
|
||||||
onClick(listableObject: ListableObject): void {
|
onClick(listableObject: ListableObject): void {
|
||||||
if (listableObject.getRenderTypes().includes(LISTABLE_NOTIFICATION_OBJECT.value)) {
|
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);
|
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.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 }}",
|
"confirmation-modal.export-metadata.header": "Export metadata for {{ dsoName }}",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user