Skip to content

Commit a26c718

Browse files
Fix to set Edit Collection to utilize findAdminAuthorized instead of findSubmitAuthorized
1 parent 93d43bc commit a26c718

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

src/app/core/data/collection-data.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export class CollectionDataService extends ComColDataService<Collection> {
7777
* requested after the response becomes stale
7878
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
7979
* {@link HALLink}s should be automatically resolved
80+
* @param searchHref The backend search endpoint to use (default to submit)
8081
* @return Observable<RemoteData<PaginatedList<Collection>>>
8182
* collection list
8283
*/
83-
getAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
84-
const searchHref = 'findSubmitAuthorized';
84+
getAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, searchHref: string = 'findSubmitAuthorized', ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
8585
options = Object.assign({}, options, {
8686
searchParams: [new RequestParam('query', query)],
8787
});

src/app/shared/collection-dropdown/collection-dropdown.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
144144
*/
145145
@Input() entityType: string;
146146

147+
/**
148+
* Search endpoint to use for finding authorized collections.
149+
* Defaults to 'findSubmitAuthorized', but can be overridden (e.g. to 'findAdminAuthorized')
150+
*/
151+
@Input() searchHref = 'findSubmitAuthorized';
152+
147153
/**
148154
* Emit to notify whether search is complete
149155
*/
@@ -252,7 +258,7 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
252258
followLink('parentCommunity'));
253259
} else {
254260
searchListService$ = this.collectionDataService
255-
.getAuthorizedCollection(query, findOptions, true, true, followLink('parentCommunity'));
261+
.getAuthorizedCollection(query, findOptions, true, true, this.searchHref, followLink('parentCommunity'));
256262
}
257263
this.searchListCollection$ = searchListService$.pipe(
258264
getFirstCompletedRemoteData(),

src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,19 @@ describe('AuthorizedCollectionSelectorComponent', () => {
8383
});
8484
});
8585
});
86+
87+
describe('when using searchHref', () => {
88+
it('should call getAuthorizedCollection with "findAdminAuthorized" when overridden', (done) => {
89+
component.searchHref = 'findAdminAuthorized';
90+
91+
component.search('', 1).subscribe(() => {
92+
expect(collectionService.getAuthorizedCollection).toHaveBeenCalledWith(
93+
'', jasmine.any(Object), true, false, 'findAdminAuthorized', jasmine.anything()
94+
);
95+
done();
96+
});
97+
});
98+
});
99+
86100
});
87101
});

src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
6666
*/
6767
@Input() entityType: string;
6868

69+
/**
70+
* Search endpoint to use for finding authorized collections.
71+
* Defaults to 'findSubmitAuthorized', but can be overridden (e.g. to 'findAdminAuthorized')
72+
*/
73+
@Input() searchHref = 'findSubmitAuthorized';
74+
6975
constructor(
7076
protected searchService: SearchService,
7177
protected collectionDataService: CollectionDataService,
@@ -104,7 +110,7 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
104110
findOptions);
105111
} else {
106112
searchListService$ = this.collectionDataService
107-
.getAuthorizedCollection(query, findOptions, useCache, false, followLink('parentCommunity'));
113+
.getAuthorizedCollection(query, findOptions, useCache, false, this.searchHref, followLink('parentCommunity'));
108114
}
109115
return searchListService$.pipe(
110116
getFirstCompletedRemoteData(),

src/app/shared/dso-selector/dso-selector/authorized-community-selector/authorized-community-selector.component.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,13 @@ describe('AuthorizedCommunitySelectorComponent', () => {
5959
});
6060

6161
describe('search', () => {
62-
describe('when has no entity type', () => {
63-
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
64-
component.search('', 1).subscribe((resultRD) => {
65-
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
66-
expect(resultRD.payload.page.length).toEqual(1);
67-
expect(resultRD.payload.page[0].indexableObject).toEqual(community);
68-
done();
69-
});
62+
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
63+
component.search('', 1).subscribe((resultRD) => {
64+
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
65+
expect(resultRD.payload.page.length).toEqual(1);
66+
expect(resultRD.payload.page[0].indexableObject).toEqual(community);
67+
done();
7068
});
7169
});
72-
7370
});
7471
});

src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
}
1010
<ds-authorized-collection-selector [currentDSOId]="dsoRD?.payload.uuid"
1111
[types]="selectorTypes"
12+
searchHref="findAdminAuthorized"
1213
(onSelect)="selectObject($event)"></ds-authorized-collection-selector>
1314
</div>
1415
</div>

0 commit comments

Comments
 (0)