mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Fix to set Edit Collection to utilize findAdminAuthorized instead of findSubmitAuthorized
This commit is contained in:
@@ -77,11 +77,11 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
|||||||
* requested after the response becomes stale
|
* requested after the response becomes stale
|
||||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
|
||||||
* {@link HALLink}s should be automatically resolved
|
* {@link HALLink}s should be automatically resolved
|
||||||
|
* @param searchHref The backend search endpoint to use (default to submit)
|
||||||
* @return Observable<RemoteData<PaginatedList<Collection>>>
|
* @return Observable<RemoteData<PaginatedList<Collection>>>
|
||||||
* collection list
|
* collection list
|
||||||
*/
|
*/
|
||||||
getAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
|
getAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, searchHref: string = 'findSubmitAuthorized', ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
|
||||||
const searchHref = 'findSubmitAuthorized';
|
|
||||||
options = Object.assign({}, options, {
|
options = Object.assign({}, options, {
|
||||||
searchParams: [new RequestParam('query', query)],
|
searchParams: [new RequestParam('query', query)],
|
||||||
});
|
});
|
||||||
|
@@ -144,6 +144,12 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@Input() entityType: string;
|
@Input() entityType: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search endpoint to use for finding authorized collections.
|
||||||
|
* Defaults to 'findSubmitAuthorized', but can be overridden (e.g. to 'findAdminAuthorized')
|
||||||
|
*/
|
||||||
|
@Input() searchHref = 'findSubmitAuthorized';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emit to notify whether search is complete
|
* Emit to notify whether search is complete
|
||||||
*/
|
*/
|
||||||
@@ -252,7 +258,7 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
|
|||||||
followLink('parentCommunity'));
|
followLink('parentCommunity'));
|
||||||
} else {
|
} else {
|
||||||
searchListService$ = this.collectionDataService
|
searchListService$ = this.collectionDataService
|
||||||
.getAuthorizedCollection(query, findOptions, true, true, followLink('parentCommunity'));
|
.getAuthorizedCollection(query, findOptions, true, true, this.searchHref, followLink('parentCommunity'));
|
||||||
}
|
}
|
||||||
this.searchListCollection$ = searchListService$.pipe(
|
this.searchListCollection$ = searchListService$.pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
|
@@ -83,5 +83,19 @@ describe('AuthorizedCollectionSelectorComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when using searchHref', () => {
|
||||||
|
it('should call getAuthorizedCollection with "findAdminAuthorized" when overridden', (done) => {
|
||||||
|
component.searchHref = 'findAdminAuthorized';
|
||||||
|
|
||||||
|
component.search('', 1).subscribe(() => {
|
||||||
|
expect(collectionService.getAuthorizedCollection).toHaveBeenCalledWith(
|
||||||
|
'', jasmine.any(Object), true, false, 'findAdminAuthorized', jasmine.anything()
|
||||||
|
);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -66,6 +66,12 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
|
|||||||
*/
|
*/
|
||||||
@Input() entityType: string;
|
@Input() entityType: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search endpoint to use for finding authorized collections.
|
||||||
|
* Defaults to 'findSubmitAuthorized', but can be overridden (e.g. to 'findAdminAuthorized')
|
||||||
|
*/
|
||||||
|
@Input() searchHref = 'findSubmitAuthorized';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected searchService: SearchService,
|
protected searchService: SearchService,
|
||||||
protected collectionDataService: CollectionDataService,
|
protected collectionDataService: CollectionDataService,
|
||||||
@@ -104,7 +110,7 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
|
|||||||
findOptions);
|
findOptions);
|
||||||
} else {
|
} else {
|
||||||
searchListService$ = this.collectionDataService
|
searchListService$ = this.collectionDataService
|
||||||
.getAuthorizedCollection(query, findOptions, useCache, false, followLink('parentCommunity'));
|
.getAuthorizedCollection(query, findOptions, useCache, false, this.searchHref, followLink('parentCommunity'));
|
||||||
}
|
}
|
||||||
return searchListService$.pipe(
|
return searchListService$.pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
|
@@ -59,16 +59,13 @@ describe('AuthorizedCommunitySelectorComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('search', () => {
|
describe('search', () => {
|
||||||
describe('when has no entity type', () => {
|
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
|
||||||
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
|
component.search('', 1).subscribe((resultRD) => {
|
||||||
component.search('', 1).subscribe((resultRD) => {
|
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
|
||||||
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
|
expect(resultRD.payload.page.length).toEqual(1);
|
||||||
expect(resultRD.payload.page.length).toEqual(1);
|
expect(resultRD.payload.page[0].indexableObject).toEqual(community);
|
||||||
expect(resultRD.payload.page[0].indexableObject).toEqual(community);
|
done();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
}
|
}
|
||||||
<ds-authorized-collection-selector [currentDSOId]="dsoRD?.payload.uuid"
|
<ds-authorized-collection-selector [currentDSOId]="dsoRD?.payload.uuid"
|
||||||
[types]="selectorTypes"
|
[types]="selectorTypes"
|
||||||
|
searchHref="findAdminAuthorized"
|
||||||
(onSelect)="selectObject($event)"></ds-authorized-collection-selector>
|
(onSelect)="selectObject($event)"></ds-authorized-collection-selector>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user