mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Bug fix for browse.
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
import { ChangeDetectorRef, Component, Inject } from '@angular/core';
|
import { ChangeDetectorRef, Component, Inject } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
BrowseByMetadataPageComponent,
|
BrowseByMetadataPageComponent,
|
||||||
browseParamsToOptions
|
browseParamsToOptions, getBrowseSearchOptions
|
||||||
} from '../browse-by-metadata-page/browse-by-metadata-page.component';
|
} from '../browse-by-metadata-page/browse-by-metadata-page.component';
|
||||||
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
|
||||||
import { combineLatest as observableCombineLatest } from 'rxjs';
|
import { combineLatest as observableCombineLatest } from 'rxjs';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
@@ -51,8 +50,8 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
||||||
this.startsWithType = StartsWithType.date;
|
this.startsWithType = StartsWithType.date;
|
||||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, null,
|
// include the thumbnail configuration in browse search options
|
||||||
null));
|
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, this.fetchThumbnails));
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
@@ -65,7 +64,7 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
|
|||||||
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
|
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.startsWith = +params.startsWith || params.startsWith;
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail);
|
const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails);
|
||||||
this.updatePageWithItems(searchOptions, this.value, undefined);
|
this.updatePageWithItems(searchOptions, this.value, undefined);
|
||||||
this.updateParent(params.scope);
|
this.updateParent(params.scope);
|
||||||
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);
|
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);
|
||||||
|
@@ -1,4 +1,8 @@
|
|||||||
import { BrowseByMetadataPageComponent, browseParamsToOptions } from './browse-by-metadata-page.component';
|
import {
|
||||||
|
BrowseByMetadataPageComponent,
|
||||||
|
browseParamsToOptions,
|
||||||
|
getBrowseSearchOptions
|
||||||
|
} from './browse-by-metadata-page.component';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { BrowseService } from '../../core/browse/browse.service';
|
import { BrowseService } from '../../core/browse/browse.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
@@ -127,7 +131,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set embed thumbnail property to true', () => {
|
it('should set embed thumbnail property to true', () => {
|
||||||
expect(comp.embedThumbnail).toBeTrue();
|
expect(comp.fetchThumbnails).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when a value is provided', () => {
|
describe('when a value is provided', () => {
|
||||||
@@ -164,7 +168,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
field: 'fake-field',
|
field: 'fake-field',
|
||||||
};
|
};
|
||||||
|
|
||||||
result = browseParamsToOptions(paramsScope, paginationOptions, sortOptions, 'author', comp.embedThumbnail);
|
result = browseParamsToOptions(paramsScope, paginationOptions, sortOptions, 'author', comp.fetchThumbnails);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return BrowseEntrySearchOptions with the correct properties', () => {
|
it('should return BrowseEntrySearchOptions with the correct properties', () => {
|
||||||
@@ -175,7 +179,36 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
expect(result.sort.direction).toEqual(SortDirection.ASC);
|
expect(result.sort.direction).toEqual(SortDirection.ASC);
|
||||||
expect(result.sort.field).toEqual('fake-field');
|
expect(result.sort.field).toEqual('fake-field');
|
||||||
expect(result.scope).toEqual('fake-scope');
|
expect(result.scope).toEqual('fake-scope');
|
||||||
expect(result.embedThumbnail).toBeTrue();
|
expect(result.fetchThumbnail).toBeTrue();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('calling getBrowseSearchOptions', () => {
|
||||||
|
let result: BrowseEntrySearchOptions;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const paramsScope = {
|
||||||
|
scope: 'fake-scope'
|
||||||
|
};
|
||||||
|
const paginationOptions = Object.assign(new PaginationComponentOptions(), {
|
||||||
|
currentPage: 5,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
const sortOptions = {
|
||||||
|
direction: SortDirection.ASC,
|
||||||
|
field: 'fake-field',
|
||||||
|
};
|
||||||
|
|
||||||
|
result = getBrowseSearchOptions('title', paginationOptions, sortOptions, comp.fetchThumbnails);
|
||||||
|
});
|
||||||
|
it('should return BrowseEntrySearchOptions with the correct properties', () => {
|
||||||
|
|
||||||
|
expect(result.metadataDefinition).toEqual('title');
|
||||||
|
expect(result.pagination.currentPage).toEqual(5);
|
||||||
|
expect(result.pagination.pageSize).toEqual(10);
|
||||||
|
expect(result.sort.direction).toEqual(SortDirection.ASC);
|
||||||
|
expect(result.sort.field).toEqual('fake-field');
|
||||||
|
expect(result.fetchThumbnail).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -115,7 +115,7 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Determines whether to request embedded thumbnail.
|
* Determines whether to request embedded thumbnail.
|
||||||
*/
|
*/
|
||||||
embedThumbnail: boolean;
|
fetchThumbnails: boolean;
|
||||||
|
|
||||||
public constructor(protected route: ActivatedRoute,
|
public constructor(protected route: ActivatedRoute,
|
||||||
protected browseService: BrowseService,
|
protected browseService: BrowseService,
|
||||||
@@ -123,14 +123,13 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
|||||||
protected paginationService: PaginationService,
|
protected paginationService: PaginationService,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
|
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
|
||||||
this.embedThumbnail = this.appConfig.browseBy.showThumbnails;
|
this.fetchThumbnails = this.appConfig.browseBy.showThumbnails;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
||||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, null,
|
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig));
|
||||||
null, false));
|
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
@@ -145,7 +144,7 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
|||||||
this.startsWith = +params.startsWith || params.startsWith;
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
if (isNotEmpty(this.value)) {
|
if (isNotEmpty(this.value)) {
|
||||||
this.updatePageWithItems(
|
this.updatePageWithItems(
|
||||||
browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail), this.value, this.authority);
|
browseParamsToOptions(params, currentPage, currentSort, this.browseId, false), this.value, this.authority);
|
||||||
} else {
|
} else {
|
||||||
this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false));
|
this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false));
|
||||||
}
|
}
|
||||||
@@ -172,7 +171,6 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
|||||||
* scope: string }
|
* scope: string }
|
||||||
*/
|
*/
|
||||||
updatePage(searchOptions: BrowseEntrySearchOptions) {
|
updatePage(searchOptions: BrowseEntrySearchOptions) {
|
||||||
searchOptions.embedThumbnail = this.embedThumbnail;
|
|
||||||
this.browseEntries$ = this.browseService.getBrowseEntriesFor(searchOptions);
|
this.browseEntries$ = this.browseService.getBrowseEntriesFor(searchOptions);
|
||||||
this.items$ = undefined;
|
this.items$ = undefined;
|
||||||
}
|
}
|
||||||
@@ -240,25 +238,44 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates browse entry search options.
|
||||||
|
* @param defaultBrowseId the metadata definition to fetch entries or items for
|
||||||
|
* @param paginationConfig the required pagination configuration
|
||||||
|
* @param sortConfig the required sort configuration
|
||||||
|
* @param fetchThumbnails optional boolean for fetching thumbnails
|
||||||
|
* @returns BrowseEntrySearchOptions instance
|
||||||
|
*/
|
||||||
|
export function getBrowseSearchOptions(defaultBrowseId: string,
|
||||||
|
paginationConfig: PaginationComponentOptions,
|
||||||
|
sortConfig: SortOptions,
|
||||||
|
fetchThumbnails?: boolean) {
|
||||||
|
if (!hasValue(fetchThumbnails)) {
|
||||||
|
fetchThumbnails = false;
|
||||||
|
}
|
||||||
|
return new BrowseEntrySearchOptions(defaultBrowseId, paginationConfig, sortConfig, null,
|
||||||
|
null, fetchThumbnails);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to transform query and url parameters into searchOptions used to fetch browse entries or items
|
* Function to transform query and url parameters into searchOptions used to fetch browse entries or items
|
||||||
* @param params URL and query parameters
|
* @param params URL and query parameters
|
||||||
* @param paginationConfig Pagination configuration
|
* @param paginationConfig Pagination configuration
|
||||||
* @param sortConfig Sorting configuration
|
* @param sortConfig Sorting configuration
|
||||||
* @param metadata Optional metadata definition to fetch browse entries/items for
|
* @param metadata Optional metadata definition to fetch browse entries/items for
|
||||||
* @param embedThumbnails Optional parameter for requesting thumbnail images
|
* @param fetchThumbnail Optional parameter for requesting thumbnail images
|
||||||
*/
|
*/
|
||||||
export function browseParamsToOptions(params: any,
|
export function browseParamsToOptions(params: any,
|
||||||
paginationConfig: PaginationComponentOptions,
|
paginationConfig: PaginationComponentOptions,
|
||||||
sortConfig: SortOptions,
|
sortConfig: SortOptions,
|
||||||
metadata?: string,
|
metadata?: string,
|
||||||
embedThumbnails?: boolean): BrowseEntrySearchOptions {
|
fetchThumbnail?: boolean): BrowseEntrySearchOptions {
|
||||||
return new BrowseEntrySearchOptions(
|
return new BrowseEntrySearchOptions(
|
||||||
metadata,
|
metadata,
|
||||||
paginationConfig,
|
paginationConfig,
|
||||||
sortConfig,
|
sortConfig,
|
||||||
+params.startsWith || params.startsWith,
|
+params.startsWith || params.startsWith,
|
||||||
params.scope,
|
params.scope,
|
||||||
embedThumbnails
|
fetchThumbnail
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -4,9 +4,8 @@ import { ActivatedRoute, Params, Router } from '@angular/router';
|
|||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue } from '../../shared/empty.util';
|
||||||
import {
|
import {
|
||||||
BrowseByMetadataPageComponent,
|
BrowseByMetadataPageComponent,
|
||||||
browseParamsToOptions
|
browseParamsToOptions, getBrowseSearchOptions
|
||||||
} from '../browse-by-metadata-page/browse-by-metadata-page.component';
|
} from '../browse-by-metadata-page/browse-by-metadata-page.component';
|
||||||
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { BrowseService } from '../../core/browse/browse.service';
|
import { BrowseService } from '../../core/browse/browse.service';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||||
@@ -38,8 +37,8 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, null,
|
// include the thumbnail configuration in browse search options
|
||||||
null));
|
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, this.fetchThumbnails));
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
@@ -50,7 +49,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
|||||||
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
||||||
this.startsWith = +params.startsWith || params.startsWith;
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail), undefined, undefined);
|
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
|
||||||
this.updateParent(params.scope);
|
this.updateParent(params.scope);
|
||||||
}));
|
}));
|
||||||
this.updateStartsWithTextOptions();
|
this.updateStartsWithTextOptions();
|
||||||
|
@@ -8,7 +8,7 @@ import { SortOptions } from '../cache/models/sort-options.model';
|
|||||||
* - sort: Optional sorting options to use
|
* - sort: Optional sorting options to use
|
||||||
* - startsWith An optional value to use to filter the browse results
|
* - startsWith An optional value to use to filter the browse results
|
||||||
* - scope: An optional scope to limit the results within a specific collection or community
|
* - scope: An optional scope to limit the results within a specific collection or community
|
||||||
* - embedThumbnail An optional boolean to request thumbnail for items
|
* - fetchThumbnail An optional boolean to request thumbnail for items
|
||||||
*/
|
*/
|
||||||
export class BrowseEntrySearchOptions {
|
export class BrowseEntrySearchOptions {
|
||||||
constructor(public metadataDefinition: string,
|
constructor(public metadataDefinition: string,
|
||||||
@@ -16,6 +16,6 @@ export class BrowseEntrySearchOptions {
|
|||||||
public sort?: SortOptions,
|
public sort?: SortOptions,
|
||||||
public startsWith?: string,
|
public startsWith?: string,
|
||||||
public scope?: string,
|
public scope?: string,
|
||||||
public embedThumbnail?: boolean) {
|
public fetchThumbnail?: boolean) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,7 @@ export class BrowseService {
|
|||||||
return href;
|
return href;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (options.embedThumbnail) {
|
if (options.fetchThumbnail ) {
|
||||||
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$, {}, null, null, ...BROWSE_LINKS_TO_FOLLOW);
|
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$, {}, null, null, ...BROWSE_LINKS_TO_FOLLOW);
|
||||||
}
|
}
|
||||||
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$);
|
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$);
|
||||||
@@ -150,7 +150,7 @@ export class BrowseService {
|
|||||||
return href;
|
return href;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (options.embedThumbnail) {
|
if (options.fetchThumbnail) {
|
||||||
return this.hrefOnlyDataService.findListByHref<Item>(href$, {}, null, null, ...BROWSE_LINKS_TO_FOLLOW);
|
return this.hrefOnlyDataService.findListByHref<Item>(href$, {}, null, null, ...BROWSE_LINKS_TO_FOLLOW);
|
||||||
}
|
}
|
||||||
return this.hrefOnlyDataService.findListByHref<Item>(href$);
|
return this.hrefOnlyDataService.findListByHref<Item>(href$);
|
||||||
|
@@ -11,5 +11,5 @@ export class FindListOptions {
|
|||||||
sort?: SortOptions;
|
sort?: SortOptions;
|
||||||
searchParams?: RequestParam[];
|
searchParams?: RequestParam[];
|
||||||
startsWith?: string;
|
startsWith?: string;
|
||||||
embedThumbnail?: boolean;
|
fetchThumbnail?: boolean;
|
||||||
}
|
}
|
||||||
|
@@ -202,7 +202,7 @@ describe('RelationshipDataService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call getItemRelationshipsByLabel with the correct params', (done) => {
|
it('should call getItemRelationshipsByLabel with the correct params', (done) => {
|
||||||
mockOptions = Object.assign(mockOptions, { embedThumbnail: true });
|
mockOptions = Object.assign(mockOptions, { fetchThumbnail: true });
|
||||||
service.getRelatedItemsByLabel(
|
service.getRelatedItemsByLabel(
|
||||||
mockItem,
|
mockItem,
|
||||||
mockLabel,
|
mockLabel,
|
||||||
|
@@ -45,6 +45,7 @@ import { SearchData, SearchDataImpl } from './base/search-data';
|
|||||||
import { PutData, PutDataImpl } from './base/put-data';
|
import { PutData, PutDataImpl } from './base/put-data';
|
||||||
import { IdentifiableDataService } from './base/identifiable-data.service';
|
import { IdentifiableDataService } from './base/identifiable-data.service';
|
||||||
import { dataService } from './base/data-service.decorator';
|
import { dataService } from './base/data-service.decorator';
|
||||||
|
import { itemLinksToFollow } from '../../shared/utils/relation-query.utils';
|
||||||
|
|
||||||
const relationshipListsStateSelector = (state: AppState) => state.relationshipLists;
|
const relationshipListsStateSelector = (state: AppState) => state.relationshipLists;
|
||||||
|
|
||||||
@@ -185,7 +186,7 @@ export class RelationshipDataService extends IdentifiableDataService<Relationshi
|
|||||||
]).pipe(
|
]).pipe(
|
||||||
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
||||||
take(1),
|
take(1),
|
||||||
).subscribe(() => this.itemService.findByHref(item._links.self.href, false, true, followLink('thumbnail')));
|
).subscribe(() => this.itemService.findByHref(item._links.self.href));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,15 +259,9 @@ export class RelationshipDataService extends IdentifiableDataService<Relationshi
|
|||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
getRelatedItemsByLabel(item: Item, label: string, options?: FindListOptions): Observable<RemoteData<PaginatedList<Item>>> {
|
getRelatedItemsByLabel(item: Item, label: string, options?: FindListOptions): Observable<RemoteData<PaginatedList<Item>>> {
|
||||||
let linksToFollow: FollowLinkConfig<Relationship>[];
|
let linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(options.fetchThumbnail);
|
||||||
if (options.embedThumbnail) {
|
linksToFollow.push(followLink('relationshipType'));
|
||||||
linksToFollow = [
|
|
||||||
followLink('leftItem',{}, followLink('thumbnail')),
|
|
||||||
followLink('rightItem',{}, followLink('thumbnail')),
|
|
||||||
followLink('relationshipType') ];
|
|
||||||
} else {
|
|
||||||
linksToFollow = [followLink('leftItem'), followLink('rightItem'), followLink('relationshipType')];
|
|
||||||
}
|
|
||||||
return this.getItemRelationshipsByLabel(item, label, options, true, true, ...linksToFollow).pipe(this.paginatedRelationsToItems(item.uuid));
|
return this.getItemRelationshipsByLabel(item, label, options, true, true, ...linksToFollow).pipe(this.paginatedRelationsToItems(item.uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ import { DsDynamicLookupRelationModalComponent } from '../../../../shared/form/b
|
|||||||
import { RelationshipOptions } from '../../../../shared/form/builder/models/relationship-options.model';
|
import { RelationshipOptions } from '../../../../shared/form/builder/models/relationship-options.model';
|
||||||
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
||||||
import { SearchResult } from '../../../../shared/search/models/search-result.model';
|
import { SearchResult } from '../../../../shared/search/models/search-result.model';
|
||||||
import { followLink, FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
||||||
import { PaginatedList } from '../../../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
@@ -40,6 +40,7 @@ import { FieldUpdate } from '../../../../core/data/object-updates/field-update.m
|
|||||||
import { FieldUpdates } from '../../../../core/data/object-updates/field-updates.model';
|
import { FieldUpdates } from '../../../../core/data/object-updates/field-updates.model';
|
||||||
import { FieldChangeType } from '../../../../core/data/object-updates/field-change-type.model';
|
import { FieldChangeType } from '../../../../core/data/object-updates/field-change-type.model';
|
||||||
import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface';
|
||||||
|
import { itemLinksToFollow } from '../../../../shared/utils/relation-query.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-edit-relationship-list',
|
selector: 'ds-edit-relationship-list',
|
||||||
@@ -142,7 +143,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* Determines whether to ask for the embedded item thumbnail.
|
* Determines whether to ask for the embedded item thumbnail.
|
||||||
*/
|
*/
|
||||||
embedThumbnail: boolean;
|
fetchThumbnail: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected objectUpdatesService: ObjectUpdatesService,
|
protected objectUpdatesService: ObjectUpdatesService,
|
||||||
@@ -154,7 +155,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
|||||||
protected selectableListService: SelectableListService,
|
protected selectableListService: SelectableListService,
|
||||||
@Inject(APP_CONFIG) protected appConfig: AppConfig
|
@Inject(APP_CONFIG) protected appConfig: AppConfig
|
||||||
) {
|
) {
|
||||||
this.embedThumbnail = this.appConfig.browseBy.showThumbnails;
|
this.fetchThumbnail = this.appConfig.browseBy.showThumbnails;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -492,15 +493,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// this adds thumbnail images when required by configuration
|
// this adds thumbnail images when required by configuration
|
||||||
let linksToFollow: FollowLinkConfig<Relationship>[];
|
let linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(this.fetchThumbnail);
|
||||||
if (this.embedThumbnail) {
|
|
||||||
linksToFollow = [
|
|
||||||
followLink('leftItem',{}, followLink('thumbnail')),
|
|
||||||
followLink('rightItem',{}, followLink('thumbnail')),
|
|
||||||
followLink('relationshipType') ];
|
|
||||||
} else {
|
|
||||||
linksToFollow = [followLink('leftItem'), followLink('rightItem'), followLink('relationshipType')];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest([
|
observableCombineLatest([
|
||||||
|
@@ -59,14 +59,14 @@ export class RelatedItemsComponent extends AbstractIncrementalListComponent<Obse
|
|||||||
/**
|
/**
|
||||||
* Determines whether to request embedded thumbnail.
|
* Determines whether to request embedded thumbnail.
|
||||||
*/
|
*/
|
||||||
embedThumbnail: boolean;
|
fetchThumbnail: boolean;
|
||||||
|
|
||||||
constructor(public relationshipService: RelationshipDataService,
|
constructor(public relationshipService: RelationshipDataService,
|
||||||
protected elementRef: ElementRef,
|
protected elementRef: ElementRef,
|
||||||
@Inject(APP_CONFIG) protected appConfig: AppConfig
|
@Inject(APP_CONFIG) protected appConfig: AppConfig
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.embedThumbnail = this.appConfig.browseBy.showThumbnails;
|
this.fetchThumbnail = this.appConfig.browseBy.showThumbnails;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -81,6 +81,6 @@ export class RelatedItemsComponent extends AbstractIncrementalListComponent<Obse
|
|||||||
*/
|
*/
|
||||||
getPage(page: number): Observable<RemoteData<PaginatedList<Item>>> {
|
getPage(page: number): Observable<RemoteData<PaginatedList<Item>>> {
|
||||||
return this.relationshipService.getRelatedItemsByLabel(this.parentItem, this.relationType, Object.assign(this.options,
|
return this.relationshipService.getRelatedItemsByLabel(this.parentItem, this.relationType, Object.assign(this.options,
|
||||||
{ elementsPerPage: this.incrementBy, currentPage: page, embedThumbnail: this.embedThumbnail }));
|
{ elementsPerPage: this.incrementBy, currentPage: page, fetchThumbnail: this.fetchThumbnail }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ describe('RelatedItemsComponent', () => {
|
|||||||
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, {
|
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, {
|
||||||
elementsPerPage: comp.incrementBy,
|
elementsPerPage: comp.incrementBy,
|
||||||
currentPage: 2,
|
currentPage: 2,
|
||||||
embedThumbnail: true
|
fetchThumbnail: true
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ describe('RelatedItemsComponent', () => {
|
|||||||
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, {
|
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, {
|
||||||
elementsPerPage: comp.incrementBy,
|
elementsPerPage: comp.incrementBy,
|
||||||
currentPage: 2,
|
currentPage: 2,
|
||||||
embedThumbnail: false
|
fetchThumbnail: false
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
import { followLink, FollowLinkConfig } from './follow-link-config.model';
|
||||||
|
import { Relationship } from '../../core/shared/item-relationships/relationship.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the query for looking up items by relation type
|
* Get the query for looking up items by relation type
|
||||||
* @param {string} relationType Relation type
|
* @param {string} relationType Relation type
|
||||||
@@ -16,3 +19,21 @@ export function getQueryByRelations(relationType: string, itemUUID: string): str
|
|||||||
export function getFilterByRelation(relationType: string, itemUUID: string): string {
|
export function getFilterByRelation(relationType: string, itemUUID: string): string {
|
||||||
return `f.${relationType}=${itemUUID},equals`;
|
return `f.${relationType}=${itemUUID},equals`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates links to follow for the leftItem and rightItem. Links will include
|
||||||
|
* @param showThumbnail thumbnail image configuration
|
||||||
|
* @returns followLink array
|
||||||
|
*/
|
||||||
|
export function itemLinksToFollow(showThumbnail: boolean): FollowLinkConfig<Relationship>[] {
|
||||||
|
let linksToFollow: FollowLinkConfig<Relationship>[];
|
||||||
|
if (showThumbnail) {
|
||||||
|
linksToFollow = [
|
||||||
|
followLink('leftItem',{}, followLink('thumbnail')),
|
||||||
|
followLink('rightItem',{}, followLink('thumbnail'))
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
linksToFollow = [followLink('leftItem'), followLink('rightItem')];
|
||||||
|
}
|
||||||
|
return linksToFollow;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user