Thumbnails fixed for relationships and added styling.

This commit is contained in:
Michael Spalti
2022-09-15 11:40:00 -07:00
parent abe19b12bb
commit 46ecf287a4
8 changed files with 45 additions and 11 deletions

View File

@@ -121,6 +121,8 @@ describe('RelationshipService', () => {
findByHref: createSuccessfulRemoteDataObject$(relatedItems[0]) findByHref: createSuccessfulRemoteDataObject$(relatedItems[0])
}); });
const appConfig = Object.assign({browseBy: {showThumbnails: true}})
function initTestService() { function initTestService() {
return new RelationshipService( return new RelationshipService(
itemService, itemService,
@@ -133,6 +135,7 @@ describe('RelationshipService', () => {
null, null,
null, null,
null, null,
appConfig,
jasmine.createSpy('paginatedRelationsToItems').and.returnValue((v) => v), jasmine.createSpy('paginatedRelationsToItems').and.returnValue((v) => v),
); );
} }
@@ -210,8 +213,8 @@ describe('RelationshipService', () => {
mockOptions, mockOptions,
true, true,
true, true,
followLink('leftItem'), followLink('leftItem',{}, followLink('thumbnail')),
followLink('rightItem'), followLink('rightItem',{}, followLink('thumbnail')),
followLink('relationshipType') followLink('relationshipType')
); );
done(); done();

View File

@@ -46,6 +46,7 @@ import { sendRequest } from '../shared/request.operators';
import { RestRequest } from './rest-request.model'; import { RestRequest } from './rest-request.model';
import { CoreState } from '../core-state.model'; import { CoreState } from '../core-state.model';
import { FindListOptions } from './find-list-options.model'; import { FindListOptions } from './find-list-options.model';
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
const relationshipListsStateSelector = (state: AppState) => state.relationshipLists; const relationshipListsStateSelector = (state: AppState) => state.relationshipLists;
@@ -89,6 +90,7 @@ export class RelationshipService extends DataService<Relationship> {
protected http: HttpClient, protected http: HttpClient,
protected comparator: DefaultChangeAnalyzer<Relationship>, protected comparator: DefaultChangeAnalyzer<Relationship>,
protected appStore: Store<AppState>, protected appStore: Store<AppState>,
@Inject(APP_CONFIG) private appConfig: AppConfig,
@Inject(PAGINATED_RELATIONS_TO_ITEMS_OPERATOR) private paginatedRelationsToItems: (thisId: string) => (source: Observable<RemoteData<PaginatedList<Relationship>>>) => Observable<RemoteData<PaginatedList<Item>>>) { @Inject(PAGINATED_RELATIONS_TO_ITEMS_OPERATOR) private paginatedRelationsToItems: (thisId: string) => (source: Observable<RemoteData<PaginatedList<Relationship>>>) => Observable<RemoteData<PaginatedList<Item>>>) {
super(); super();
} }
@@ -183,7 +185,7 @@ export class RelationshipService extends DataService<Relationship> {
]).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)); ).subscribe(() => this.itemService.findByHref(item._links.self.href, false, true, followLink('thumbnail')));
} }
/** /**
@@ -256,7 +258,16 @@ export class RelationshipService extends DataService<Relationship> {
* @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>>> {
return this.getItemRelationshipsByLabel(item, label, options, true, true, followLink('leftItem'), followLink('rightItem'), followLink('relationshipType')).pipe(this.paginatedRelationsToItems(item.uuid)); let linksToFollow: FollowLinkConfig<Relationship>[];
if (this.appConfig.browseBy.showThumbnails) {
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));
} }
/** /**

View File

@@ -36,7 +36,7 @@
[label]="'orgunit.page.id'"> [label]="'orgunit.page.id'">
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-7">
<ds-related-items <ds-related-items
[parentItem]="object" [parentItem]="object"
[relationType]="'isPublicationOfOrgUnit'" [relationType]="'isPublicationOfOrgUnit'"

View File

@@ -29,7 +29,7 @@
[label]="'person.page.birthdate'"> [label]="'person.page.birthdate'">
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-7">
<ds-related-items <ds-related-items
[parentItem]="object" [parentItem]="object"
[relationType]="'isProjectOfPerson'" [relationType]="'isProjectOfPerson'"

View File

@@ -42,7 +42,7 @@
<!--[label]="'project.page.expectedcompletion'">--> <!--[label]="'project.page.expectedcompletion'">-->
<!--</ds-generic-item-page-field>--> <!--</ds-generic-item-page-field>-->
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-7">
<ds-related-items <ds-related-items
[parentItem]="object" [parentItem]="object"
[relationType]="'isPersonOfProject'" [relationType]="'isPersonOfProject'"

View File

@@ -53,7 +53,7 @@
[label]="'publication.page.publisher'"> [label]="'publication.page.publisher'">
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-7">
<ds-related-items <ds-related-items
[parentItem]="object" [parentItem]="object"
[relationType]="'isProjectOfPublication'" [relationType]="'isProjectOfPublication'"

View File

@@ -3,7 +3,9 @@
* placeholder font size in lists. * placeholder font size in lists.
*/ */
export function setPlaceHolderFontSize(width: number): string { export function setPlaceHolderFontSize(width: number): string {
if (width < 750) { if (width < 400) {
return 'thumb-font-0'
} else if (width < 750) {
return 'thumb-font-1'; return 'thumb-font-1';
} else if (width < 1000) { } else if (width < 1000) {
return 'thumb-font-2'; return 'thumb-font-2';

View File

@@ -139,14 +139,32 @@ ds-dynamic-form-control-container.d-none {
background-color: var(--ds-admin-sidebar-bg); background-color: var(--ds-admin-sidebar-bg);
} }
/* The font sizes used in "no thumbnail" placeholder */ /* The font sizes used in "no thumbnail" placeholder */
.thumb-font-0 {
.thumbnail-placeholder {
@media screen and (max-width: map-get($grid-breakpoints, lg)) {
font-size: 0.7rem !important;
padding: 0.2rem;
}
@media screen and (max-width: map-get($grid-breakpoints, sm)) {
font-size: 0.6rem !important;
padding: 0.1rem;
}
font-size: 0.4rem !important;
padding: 0.1rem;
}
}
.thumb-font-1 { .thumb-font-1 {
.thumbnail-placeholder { .thumbnail-placeholder {
font-size: 0.7rem !important;
padding: 0.125rem;
@media screen and (max-width: map-get($grid-breakpoints, sm)) { @media screen and (max-width: map-get($grid-breakpoints, sm)) {
font-size: 0.9rem !important;
padding: 0.1rem;
}
@media screen and (max-width: 950px) {
font-size: 0.5rem !important; font-size: 0.5rem !important;
padding: 0.1rem; padding: 0.1rem;
} }
font-size: 0.7rem !important;
padding: 0.125rem;
visibility: inherit; visibility: inherit;
} }
} }