From e584489eafead6ce473215aa6796c4a420373443 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 27 Sep 2019 11:22:55 +0200 Subject: [PATCH 01/17] 65195: removed duplicate view mode, renamed existing modes from SetViewMode --- .../my-dspace-page.component.ts | 2 +- .../+my-dspace-page/my-dspace-page.module.ts | 2 +- src/app/+search-page/search-options.model.ts | 4 +-- .../search-results.component.ts | 4 +-- .../search-service/search.service.spec.ts | 25 ++++++++----------- .../search-service/search.service.ts | 4 +-- src/app/core/shared/view-mode.model.ts | 6 ++--- .../object-collection.component.html | 6 ++--- .../object-collection.component.spec.ts | 6 ++--- .../object-collection.component.ts | 8 +++--- .../shared/dso-element-decorator.spec.ts | 6 ++--- .../shared/dso-element-decorator.ts | 6 ++--- ...-dspace-result-detail-element.component.ts | 5 ++-- ...-dspace-result-detail-element.component.ts | 3 +-- ...ce-result-detail-element.component.spec.ts | 3 +-- ...dspace-result-detail-element.component.ts} | 6 ++--- ...-dspace-result-detail-element.component.ts | 5 ++-- ...-dspace-result-detail-element.component.ts | 6 ++--- .../wrapper-detail-element.component.ts | 3 +-- .../collection-grid-element.component.ts | 4 +-- .../community-grid-element.component.ts | 8 +++--- .../item-grid-element.component.ts | 4 +-- ...on-search-result-grid-element.component.ts | 4 +-- ...ty-search-result-grid-element.component.ts | 4 +-- ...em-search-result-grid-element.component.ts | 6 ++--- .../wrapper-grid-element.component.ts | 4 +-- .../browse-entry-list-element.component.ts | 3 +-- .../collection-list-element.component.ts | 4 +-- .../community-list-element.component.ts | 4 +-- .../item-list-element.component.ts | 4 +-- ...my-dspace-result-list-element.component.ts | 5 ++-- ...my-dspace-result-list-element.component.ts | 4 +-- ...my-dspace-result-list-element.component.ts | 5 ++-- ...my-dspace-result-list-element.component.ts | 5 ++-- ...my-dspace-result-list-element.component.ts | 3 +-- ...on-search-result-list-element.component.ts | 4 +-- ...ty-search-result-list-element.component.ts | 4 +-- ...em-search-result-list-element.component.ts | 6 ++--- .../wrapper-list-element.component.ts | 4 +-- src/app/shared/testing/search-service-stub.ts | 14 +++++------ .../view-mode-switch.component.html | 18 ++++++------- .../view-mode-switch.component.spec.ts | 10 ++++---- .../view-mode-switch.component.ts | 4 +-- src/app/shared/view-mode.ts | 15 ----------- 44 files changed, 115 insertions(+), 145 deletions(-) rename src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/{pool-my-dspace-result-detail-lement.component.ts => pool-my-dspace-result-detail-element.component.ts} (92%) delete mode 100644 src/app/shared/view-mode.ts diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index 251bf50bd1..e05f43d56e 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -93,7 +93,7 @@ export class MyDSpacePageComponent implements OnInit { /** * List of available view mode */ - viewModeList = [ViewMode.List, ViewMode.Detail]; + viewModeList = [ViewMode.ListElement, ViewMode.DetailedListElement]; constructor(private service: SearchService, private sidebarService: SearchSidebarService, diff --git a/src/app/+my-dspace-page/my-dspace-page.module.ts b/src/app/+my-dspace-page/my-dspace-page.module.ts index 4b8cf37b7a..448699504e 100644 --- a/src/app/+my-dspace-page/my-dspace-page.module.ts +++ b/src/app/+my-dspace-page/my-dspace-page.module.ts @@ -17,7 +17,7 @@ import { ItemMyDSpaceResultDetailElementComponent } from '../shared/object-detai import { WorkspaceitemMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component'; import { WorkflowitemMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component'; import { ClaimedMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component'; -import { PoolMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-lement.component'; +import { PoolMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component'; import { MyDSpaceGuard } from './my-dspace.guard'; import { MyDSpaceConfigurationService } from './my-dspace-configuration.service'; diff --git a/src/app/+search-page/search-options.model.ts b/src/app/+search-page/search-options.model.ts index 2b18854e1e..4117c13347 100644 --- a/src/app/+search-page/search-options.model.ts +++ b/src/app/+search-page/search-options.model.ts @@ -3,14 +3,14 @@ import { URLCombiner } from '../core/url-combiner/url-combiner'; import 'core-js/library/fn/object/entries'; import { SearchFilter } from './search-filter.model'; import { DSpaceObjectType } from '../core/shared/dspace-object-type.model'; -import { SetViewMode } from '../shared/view-mode'; +import { ViewMode } from '../core/shared/view-mode.model'; /** * This model class represents all parameters needed to request information about a certain search request */ export class SearchOptions { configuration?: string; - view?: SetViewMode = SetViewMode.List; + view?: ViewMode = ViewMode.ListElement; scope?: string; query?: string; dsoType?: DSpaceObjectType; diff --git a/src/app/+search-page/search-results/search-results.component.ts b/src/app/+search-page/search-results/search-results.component.ts index 0ad1fd46bf..8ec7b1cae4 100644 --- a/src/app/+search-page/search-results/search-results.component.ts +++ b/src/app/+search-page/search-results/search-results.component.ts @@ -2,12 +2,12 @@ import { Component, Input } from '@angular/core'; import { RemoteData } from '../../core/data/remote-data'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { fadeIn, fadeInOut } from '../../shared/animations/fade'; -import { SetViewMode } from '../../shared/view-mode'; import { SearchOptions } from '../search-options.model'; import { SearchResult } from '../search-result.model'; import { PaginatedList } from '../../core/data/paginated-list'; import { hasNoValue, isNotEmpty } from '../../shared/empty.util'; import { SortOptions } from '../../core/cache/models/sort-options.model'; +import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ selector: 'ds-search-results', @@ -42,7 +42,7 @@ export class SearchResultsComponent { /** * The current view-mode of the list */ - @Input() viewMode: SetViewMode; + @Input() viewMode: ViewMode; /** * An optional configuration to filter the result on one type diff --git a/src/app/+search-page/search-service/search.service.spec.ts b/src/app/+search-page/search-service/search.service.spec.ts index 798670a0e0..4f91dde312 100644 --- a/src/app/+search-page/search-service/search.service.spec.ts +++ b/src/app/+search-page/search-service/search.service.spec.ts @@ -5,9 +5,6 @@ import { CommonModule } from '@angular/common'; import { Component } from '@angular/core'; import { SearchService } from './search.service'; -import { ItemDataService } from './../../core/data/item-data.service'; -import { SetViewMode } from '../../shared/view-mode'; -import { GLOBAL_CONFIG } from '../../../config'; import { RemoteDataBuildService } from '../../core/cache/builders/remote-data-build.service'; import { Router, UrlTree } from '@angular/router'; import { RequestService } from '../../core/data/request.service'; @@ -66,7 +63,7 @@ describe('SearchService', () => { it('should return list view mode', () => { searchService.getViewMode().subscribe((viewMode) => { - expect(viewMode).toBe(ViewMode.List); + expect(viewMode).toBe(ViewMode.ListElement); }); }); }); @@ -125,38 +122,38 @@ describe('SearchService', () => { }); it('should call the navigate method on the Router with view mode list parameter as a parameter when setViewMode is called', () => { - searchService.setViewMode(ViewMode.List); + searchService.setViewMode(ViewMode.ListElement); expect(router.navigate).toHaveBeenCalledWith(['/search'], { - queryParams: { view: ViewMode.List, page: 1 }, + queryParams: { view: ViewMode.ListElement, page: 1 }, queryParamsHandling: 'merge' }); }); it('should call the navigate method on the Router with view mode grid parameter as a parameter when setViewMode is called', () => { - searchService.setViewMode(ViewMode.Grid); + searchService.setViewMode(ViewMode.GridElement); expect(router.navigate).toHaveBeenCalledWith(['/search'], { - queryParams: { view: ViewMode.Grid, page: 1 }, + queryParams: { view: ViewMode.GridElement, page: 1 }, queryParamsHandling: 'merge' }); }); it('should return ViewMode.List when the viewMode is set to ViewMode.List in the ActivatedRoute', () => { - let viewMode = ViewMode.Grid; + let viewMode = ViewMode.GridElement; spyOn(routeService, 'getQueryParamMap').and.returnValue(observableOf(new Map([ - [ 'view', ViewMode.List ], + [ 'view', ViewMode.ListElement ], ]))); searchService.getViewMode().subscribe((mode) => viewMode = mode); - expect(viewMode).toEqual(ViewMode.List); + expect(viewMode).toEqual(ViewMode.ListElement); }); it('should return ViewMode.Grid when the viewMode is set to ViewMode.Grid in the ActivatedRoute', () => { - let viewMode = ViewMode.List; + let viewMode = ViewMode.ListElement; spyOn(routeService, 'getQueryParamMap').and.returnValue(observableOf(new Map([ - [ 'view', ViewMode.Grid ], + [ 'view', ViewMode.GridElement ], ]))); searchService.getViewMode().subscribe((mode) => viewMode = mode); - expect(viewMode).toEqual(ViewMode.Grid); + expect(viewMode).toEqual(ViewMode.GridElement); }); describe('when search is called', () => { diff --git a/src/app/+search-page/search-service/search.service.ts b/src/app/+search-page/search-service/search.service.ts index e2b24200df..7adf4d83c5 100644 --- a/src/app/+search-page/search-service/search.service.ts +++ b/src/app/+search-page/search-service/search.service.ts @@ -339,7 +339,7 @@ export class SearchService implements OnDestroy { if (isNotEmpty(params.get('view')) && hasValue(params.get('view'))) { return params.get('view'); } else { - return ViewMode.List; + return ViewMode.ListElement; } })); } @@ -352,7 +352,7 @@ export class SearchService implements OnDestroy { this.routeService.getQueryParameterValue('pageSize').pipe(first()) .subscribe((pageSize) => { let queryParams = { view: viewMode, page: 1 }; - if (viewMode === ViewMode.Detail) { + if (viewMode === ViewMode.DetailedListElement) { queryParams = Object.assign(queryParams, {pageSize: '1'}); } else if (pageSize === '1') { queryParams = Object.assign(queryParams, {pageSize: '10'}); diff --git a/src/app/core/shared/view-mode.model.ts b/src/app/core/shared/view-mode.model.ts index 9c8d086097..78b55771e2 100644 --- a/src/app/core/shared/view-mode.model.ts +++ b/src/app/core/shared/view-mode.model.ts @@ -3,7 +3,7 @@ */ export enum ViewMode { - List = 'list', - Grid = 'grid', - Detail = 'detail' + ListElement = 'listElement', + GridElement = 'gridElement', + DetailedListElement = 'detailedListElement' } diff --git a/src/app/shared/object-collection/object-collection.component.html b/src/app/shared/object-collection/object-collection.component.html index a0878efa24..b3175aef2b 100644 --- a/src/app/shared/object-collection/object-collection.component.html +++ b/src/app/shared/object-collection/object-collection.component.html @@ -8,7 +8,7 @@ (pageSizeChange)="onPageSizeChange($event)" (sortDirectionChange)="onSortDirectionChange($event)" (sortFieldChange)="onSortFieldChange($event)" - *ngIf="(currentMode$ | async) === viewModeEnum.List"> + *ngIf="(currentMode$ | async) === viewModeEnum.ListElement"> + *ngIf="(currentMode$ | async) === viewModeEnum.GridElement"> + *ngIf="(currentMode$ | async) === viewModeEnum.DetailedListElement"> diff --git a/src/app/shared/object-collection/object-collection.component.spec.ts b/src/app/shared/object-collection/object-collection.component.spec.ts index 3b30666757..ceea03c367 100644 --- a/src/app/shared/object-collection/object-collection.component.spec.ts +++ b/src/app/shared/object-collection/object-collection.component.spec.ts @@ -1,11 +1,11 @@ import { ObjectCollectionComponent } from './object-collection.component'; -import { SetViewMode } from '../view-mode'; import { By } from '@angular/platform-browser'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { of as observableOf } from 'rxjs'; import { RouterStub } from '../testing/router-stub'; +import { ViewMode } from '../../core/shared/view-mode.model'; describe('ObjectCollectionComponent', () => { let fixture: ComponentFixture; @@ -36,14 +36,14 @@ describe('ObjectCollectionComponent', () => { })); it('should only show the grid component when the viewmode is set to grid', () => { - objectCollectionComponent.currentMode$ = observableOf(SetViewMode.Grid); + objectCollectionComponent.currentMode$ = observableOf(ViewMode.GridElement); expect(fixture.debugElement.query(By.css('ds-object-grid'))).toBeDefined(); expect(fixture.debugElement.query(By.css('ds-object-list'))).toBeNull(); }); it('should only show the list component when the viewmode is set to list', () => { - objectCollectionComponent.currentMode$ = observableOf(SetViewMode.List); + objectCollectionComponent.currentMode$ = observableOf(ViewMode.ListElement); expect(fixture.debugElement.query(By.css('ds-object-list'))).toBeDefined(); expect(fixture.debugElement.query(By.css('ds-object-grid'))).toBeNull(); diff --git a/src/app/shared/object-collection/object-collection.component.ts b/src/app/shared/object-collection/object-collection.component.ts index 526fc95781..f90842d58a 100644 --- a/src/app/shared/object-collection/object-collection.component.ts +++ b/src/app/shared/object-collection/object-collection.component.ts @@ -18,8 +18,8 @@ import { PageInfo } from '../../core/shared/page-info.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { ListableObject } from './shared/listable-object.model'; -import { SetViewMode } from '../view-mode'; import { hasValue, isEmpty, isNotEmpty } from '../empty.util'; +import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ selector: 'ds-viewable-collection', @@ -60,8 +60,8 @@ export class ObjectCollectionComponent implements OnInit { */ @Output() sortFieldChange: EventEmitter = new EventEmitter(); data: any = {}; - currentMode$: Observable; - viewModeEnum = SetViewMode; + currentMode$: Observable; + viewModeEnum = ViewMode; ngOnInit(): void { this.currentMode$ = this.route @@ -69,7 +69,7 @@ export class ObjectCollectionComponent implements OnInit { .pipe( filter((params) => isNotEmpty(params.view)), map((params) => params.view), - startWith(SetViewMode.List) + startWith(ViewMode.ListElement) ); } diff --git a/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts b/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts index 12da0f5b36..836ddf727d 100644 --- a/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts +++ b/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts @@ -1,10 +1,10 @@ -import { SetViewMode } from '../../view-mode'; import { renderElementsFor } from './dso-element-decorator'; import { Item } from '../../../core/shared/item.model'; +import { ViewMode } from '../../../core/shared/view-mode.model'; describe('ElementDecorator', () => { - const gridDecorator = renderElementsFor(Item, SetViewMode.Grid); - const listDecorator = renderElementsFor(Item, SetViewMode.List); + const gridDecorator = renderElementsFor(Item, ViewMode.GridElement); + const listDecorator = renderElementsFor(Item, ViewMode.ListElement); it('should have a decorator for both list and grid', () => { expect(listDecorator.length).not.toBeNull(); expect(gridDecorator.length).not.toBeNull(); diff --git a/src/app/shared/object-collection/shared/dso-element-decorator.ts b/src/app/shared/object-collection/shared/dso-element-decorator.ts index 4e4d37579a..98650fd25b 100644 --- a/src/app/shared/object-collection/shared/dso-element-decorator.ts +++ b/src/app/shared/object-collection/shared/dso-element-decorator.ts @@ -1,9 +1,9 @@ import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { ListableObject } from './listable-object.model'; -import { SetViewMode } from '../../view-mode'; +import { ViewMode } from '../../../core/shared/view-mode.model'; const dsoElementMap = new Map(); -export function renderElementsFor(listable: GenericConstructor, viewMode: SetViewMode) { +export function renderElementsFor(listable: GenericConstructor, viewMode: ViewMode) { return function decorator(objectElement: any) { if (!objectElement) { return; @@ -15,6 +15,6 @@ export function renderElementsFor(listable: GenericConstructor, }; } -export function rendersDSOType(listable: GenericConstructor, viewMode: SetViewMode) { +export function rendersDSOType(listable: GenericConstructor, viewMode: ViewMode) { return dsoElementMap.get(viewMode).get(listable); } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts index 581d52c05f..83222e8e20 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts @@ -13,7 +13,6 @@ import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.m import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders claimed task object for the mydspace result in the detail view. @@ -24,8 +23,8 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './claimed-my-dspace-result-detail-element.component.html' }) -@renderElementsFor(ClaimedTaskMyDSpaceResult, SetViewMode.Detail) -@renderElementsFor(ClaimedTask, SetViewMode.Detail) +@renderElementsFor(ClaimedTaskMyDSpaceResult, ViewMode.DetailedListElement) +@renderElementsFor(ClaimedTask, ViewMode.DetailedListElement) export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts index 26f63deb83..51bc44a6ac 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts @@ -6,7 +6,6 @@ import { Item } from '../../../../core/shared/item.model'; import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders item object for the mydspace result in the detail view. @@ -17,7 +16,7 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './item-my-dspace-result-detail-element.component.html' }) -@renderElementsFor(ItemMyDSpaceResult, SetViewMode.Detail) +@renderElementsFor(ItemMyDSpaceResult, ViewMode.DetailedListElement) export class ItemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts index a031ac3a49..456b7dc97a 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts @@ -5,10 +5,9 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { PoolMyDSpaceResultDetailElementComponent } from './pool-my-dspace-result-detail-lement.component'; +import { PoolMyDSpaceResultDetailElementComponent } from './pool-my-dspace-result-detail-element.component'; import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-lement.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts similarity index 92% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-lement.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts index 0b5b6c6524..7dffac9630 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-lement.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts @@ -10,8 +10,8 @@ import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; /** * This component renders pool task object for the mydspace result in the detail view. @@ -22,8 +22,8 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo templateUrl: './pool-my-dspace-result-detail-element.component.html', }) -@renderElementsFor(PoolTaskMyDSpaceResult, SetViewMode.Detail) -@renderElementsFor(PoolTask, SetViewMode.Detail) +@renderElementsFor(PoolTaskMyDSpaceResult, ViewMode.DetailedListElement) +@renderElementsFor(PoolTask, ViewMode.DetailedListElement) export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts index c28f044e6e..10890d9635 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts @@ -12,7 +12,6 @@ import { Observable } from 'rxjs/internal/Observable'; import { RemoteData } from '../../../../core/data/remote-data'; import { find } from 'rxjs/operators'; import { isNotUndefined } from '../../../empty.util'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders workflowitem object for the mydspace result in the detail view. @@ -23,8 +22,8 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './workflowitem-my-dspace-result-detail-element.component.html', }) -@renderElementsFor(WorkflowitemMyDSpaceResult, SetViewMode.Detail) -@renderElementsFor(WorkflowItem, SetViewMode.Detail) +@renderElementsFor(WorkflowitemMyDSpaceResult, ViewMode.DetailedListElement) +@renderElementsFor(WorkflowItem, ViewMode.DetailedListElement) export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts index af735ecb1e..72b68e4e92 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts @@ -14,7 +14,7 @@ import { isNotUndefined } from '../../../empty.util'; import { ListableObject } from '../../../object-collection/shared/listable-object.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; /** * This component renders workspaceitem object for the mydspace result in the detail view. @@ -25,8 +25,8 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './workspaceitem-my-dspace-result-detail-element.component.html', }) -@renderElementsFor(WorkspaceitemMyDSpaceResult, SetViewMode.Detail) -@renderElementsFor(WorkspaceItem, SetViewMode.Detail) +@renderElementsFor(WorkspaceitemMyDSpaceResult, ViewMode.DetailedListElement) +@renderElementsFor(WorkspaceItem, ViewMode.DetailedListElement) export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts b/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts index 2ca8069b16..5b48d4069f 100644 --- a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts +++ b/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts @@ -4,7 +4,6 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { rendersDSOType } from '../../object-collection/shared/dso-element-decorator'; import { ListableObject } from '../../object-collection/shared/listable-object.model'; -import { SetViewMode } from '../../view-mode'; /** * This component renders a wrapper for an object in the detail view. @@ -52,6 +51,6 @@ export class WrapperDetailElementComponent implements OnInit { */ private getDetailElement(): string { const f: GenericConstructor = this.object.constructor as GenericConstructor; - return rendersDSOType(f, SetViewMode.Detail); + return rendersDSOType(f, ViewMode.DetailedListElement); } } diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts index af6027aa1a..c142e4d13e 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts @@ -2,8 +2,8 @@ import { Component, Inject } from '@angular/core'; import { Collection } from '../../../core/shared/collection.model'; import { renderElementsFor} from '../../object-collection/shared/dso-element-decorator'; -import { SetViewMode } from '../../view-mode'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-collection-grid-element', @@ -11,5 +11,5 @@ import { AbstractListableElementComponent } from '../../object-collection/shared templateUrl: './collection-grid-element.component.html' }) -@renderElementsFor(Collection, SetViewMode.Grid) +@renderElementsFor(Collection, ViewMode.GridElement) export class CollectionGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts index 4f69e3e2c7..773b862784 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts @@ -1,9 +1,9 @@ -import { Component, Input, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { Community } from '../../../core/shared/community.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { renderElementsFor} from '../../object-collection/shared/dso-element-decorator'; -import { SetViewMode } from '../../view-mode'; +import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-community-grid-element', @@ -11,5 +11,5 @@ import { SetViewMode } from '../../view-mode'; templateUrl: './community-grid-element.component.html' }) -@renderElementsFor(Community, SetViewMode.Grid) +@renderElementsFor(Community, ViewMode.GridElement) export class CommunityGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts index a4137b3c26..3e083fb973 100644 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts @@ -3,7 +3,7 @@ import { Component, Input, Inject } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; import { renderElementsFor} from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { SetViewMode } from '../../view-mode'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-item-grid-element', @@ -11,5 +11,5 @@ import { SetViewMode } from '../../view-mode'; templateUrl: './item-grid-element.component.html' }) -@renderElementsFor(Item, SetViewMode.Grid) +@renderElementsFor(Item, ViewMode.GridElement) export class ItemGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts index 61cc5dca1c..e61e5375b3 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts @@ -3,8 +3,8 @@ import { Component } from '@angular/core'; import { renderElementsFor} from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; import { Collection } from '../../../../core/shared/collection.model'; -import { SetViewMode } from '../../../view-mode'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-collection-search-result-grid-element', @@ -12,5 +12,5 @@ import { CollectionSearchResult } from '../../../object-collection/shared/collec templateUrl: 'collection-search-result-grid-element.component.html' }) -@renderElementsFor(CollectionSearchResult, SetViewMode.Grid) +@renderElementsFor(CollectionSearchResult, ViewMode.GridElement) export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent {} diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts index d445e27ed6..66c7b11983 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts @@ -2,8 +2,8 @@ import { Component } from '@angular/core'; import { Community } from '../../../../core/shared/community.model'; import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; -import { SetViewMode } from '../../../view-mode'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-community-search-result-grid-element', @@ -11,7 +11,7 @@ import { CommunitySearchResult } from '../../../object-collection/shared/communi templateUrl: 'community-search-result-grid-element.component.html' }) -@renderElementsFor(CommunitySearchResult, SetViewMode.Grid) +@renderElementsFor(CommunitySearchResult, ViewMode.GridElement) export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts index 7bbe41fe60..f0ff124439 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts @@ -4,9 +4,9 @@ import { renderElementsFor } from '../../../object-collection/shared/dso-element import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; import { Item } from '../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { SetViewMode } from '../../../view-mode'; -import { focusShadow } from '../../../../shared/animations/focus'; +import { focusShadow } from '../../../animations/focus'; import { ItemViewMode } from '../../../items/item-type-decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-item-search-result-grid-element', @@ -15,7 +15,7 @@ import { ItemViewMode } from '../../../items/item-type-decorator'; animations: [focusShadow], }) -@renderElementsFor(ItemSearchResult, SetViewMode.Grid) +@renderElementsFor(ItemSearchResult, ViewMode.GridElement) export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent { viewMode = ItemViewMode.Card; } diff --git a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts b/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts index 0a7312484f..2bd1e8bfc8 100644 --- a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts +++ b/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts @@ -1,8 +1,8 @@ import { Component, Injector, Input, OnInit } from '@angular/core'; -import { SetViewMode } from '../../view-mode'; import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { rendersDSOType } from '../../object-collection/shared/dso-element-decorator'; import { ListableObject } from '../../object-collection/shared/listable-object.model'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-wrapper-grid-element', @@ -27,6 +27,6 @@ export class WrapperGridElementComponent implements OnInit { getGridElement(): string { const f: GenericConstructor = this.object.constructor as GenericConstructor; - return rendersDSOType(f, SetViewMode.Grid); + return rendersDSOType(f, ViewMode.GridElement); } } diff --git a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts index a32cfb333e..8732637228 100644 --- a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts +++ b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts @@ -4,7 +4,6 @@ import { AbstractListableElementComponent } from '../../object-collection/shared import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { BrowseEntry } from '../../../core/shared/browse-entry.model'; import { ViewMode } from '../../../core/shared/view-mode.model'; -import { SetViewMode } from '../../view-mode'; @Component({ selector: 'ds-browse-entry-list-element', @@ -15,5 +14,5 @@ import { SetViewMode } from '../../view-mode'; /** * This component is automatically used to create a list view for BrowseEntry objects when used in ObjectCollectionComponent */ -@renderElementsFor(BrowseEntry, SetViewMode.List) +@renderElementsFor(BrowseEntry, ViewMode.ListElement) export class BrowseEntryListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts index 3fe64f5bb9..d4d46fdd69 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts @@ -2,8 +2,8 @@ import { Component, Inject } from '@angular/core'; import { Collection } from '../../../core/shared/collection.model'; import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; -import { SetViewMode } from '../../view-mode'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-collection-list-element', @@ -11,5 +11,5 @@ import { AbstractListableElementComponent } from '../../object-collection/shared templateUrl: './collection-list-element.component.html' }) -@renderElementsFor(Collection, SetViewMode.List) +@renderElementsFor(Collection, ViewMode.ListElement) export class CollectionListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/community-list-element/community-list-element.component.ts b/src/app/shared/object-list/community-list-element/community-list-element.component.ts index 5e254cb1ac..c23d35b961 100644 --- a/src/app/shared/object-list/community-list-element/community-list-element.component.ts +++ b/src/app/shared/object-list/community-list-element/community-list-element.component.ts @@ -3,7 +3,7 @@ import { Component, Input, Inject } from '@angular/core'; import { Community } from '../../../core/shared/community.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; -import { SetViewMode } from '../../view-mode'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-community-list-element', @@ -11,5 +11,5 @@ import { SetViewMode } from '../../view-mode'; templateUrl: './community-list-element.component.html' }) -@renderElementsFor(Community, SetViewMode.List) +@renderElementsFor(Community, ViewMode.ListElement) export class CommunityListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.ts index 67a6256d43..2793a41d65 100644 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.ts @@ -3,8 +3,8 @@ import { Component } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { SetViewMode } from '../../view-mode'; import { ItemViewMode } from '../../items/item-type-decorator'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-item-list-element', @@ -16,7 +16,7 @@ import { ItemViewMode } from '../../items/item-type-decorator'; * The component used to list items depending on type * Uses item-type-switcher to determine which components to use for displaying the list */ -@renderElementsFor(Item, SetViewMode.List) +@renderElementsFor(Item, ViewMode.ListElement) export class ItemListElementComponent extends AbstractListableElementComponent { viewMode = ItemViewMode.Element; } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts index 3423df7009..66cdbfb43c 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts @@ -13,7 +13,6 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders claimed task object for the mydspace result in the list view. @@ -25,8 +24,8 @@ import { SetViewMode } from '../../../view-mode'; providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) -@renderElementsFor(ClaimedTaskMyDSpaceResult, SetViewMode.List) -@renderElementsFor(ClaimedTask, SetViewMode.List) +@renderElementsFor(ClaimedTaskMyDSpaceResult, ViewMode.ListElement) +@renderElementsFor(ClaimedTask, ViewMode.ListElement) export class ClaimedMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts index 3f2a439603..a9ceac5da3 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts @@ -5,7 +5,7 @@ import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-el import { Item } from '../../../../core/shared/item.model'; import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; /** * This component renders item object for the mydspace result in the list view. @@ -16,7 +16,7 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './item-my-dspace-result-list-element.component.html' }) -@renderElementsFor(ItemMyDSpaceResult, SetViewMode.List) +@renderElementsFor(ItemMyDSpaceResult, ViewMode.ListElement) export class ItemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts index 0b60c60dc1..62cbdde1c0 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts @@ -13,7 +13,6 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders pool task object for the mydspace result in the list view. @@ -24,8 +23,8 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './pool-my-dspace-result-list-element.component.html', }) -@renderElementsFor(PoolTaskMyDSpaceResult, SetViewMode.List) -@renderElementsFor(PoolTask, SetViewMode.List) +@renderElementsFor(PoolTaskMyDSpaceResult, ViewMode.ListElement) +@renderElementsFor(PoolTask, ViewMode.ListElement) export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent implements OnInit { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts index b5d11b8b13..e03367abce 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts @@ -12,7 +12,6 @@ import { WorkflowitemMyDSpaceResult } from '../../../object-collection/shared/wo import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders workflowitem object for the mydspace result in the list view. @@ -23,8 +22,8 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './workflowitem-my-dspace-result-list-element.component.html', }) -@renderElementsFor(WorkflowitemMyDSpaceResult, SetViewMode.List) -@renderElementsFor(WorkflowItem, SetViewMode.List) +@renderElementsFor(WorkflowitemMyDSpaceResult, ViewMode.ListElement) +@renderElementsFor(WorkflowItem, ViewMode.ListElement) export class WorkflowitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts index 118965c64a..ea5f9d6f6b 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts @@ -12,7 +12,6 @@ import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { SetViewMode } from '../../../view-mode'; /** * This component renders workspaceitem object for the mydspace result in the list view. @@ -23,7 +22,7 @@ import { SetViewMode } from '../../../view-mode'; templateUrl: './workspaceitem-my-dspace-result-list-element.component.html', }) -@renderElementsFor(WorkspaceitemMyDSpaceResult, SetViewMode.List) +@renderElementsFor(WorkspaceitemMyDSpaceResult, ViewMode.ListElement) export class WorkspaceitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts index 2205155bbd..657252c1bd 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts @@ -4,8 +4,8 @@ import { renderElementsFor } from '../../../object-collection/shared/dso-element import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Collection } from '../../../../core/shared/collection.model'; -import { SetViewMode } from '../../../view-mode'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-collection-search-result-list-element', @@ -13,5 +13,5 @@ import { CollectionSearchResult } from '../../../object-collection/shared/collec templateUrl: 'collection-search-result-list-element.component.html' }) -@renderElementsFor(CollectionSearchResult, SetViewMode.List) +@renderElementsFor(CollectionSearchResult, ViewMode.ListElement) export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent {} diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts index 3f7e08d11c..c57e716a2f 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts @@ -4,8 +4,8 @@ import { renderElementsFor } from '../../../object-collection/shared/dso-element import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Community } from '../../../../core/shared/community.model'; -import { SetViewMode } from '../../../view-mode'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-community-search-result-list-element', @@ -13,7 +13,7 @@ import { CommunitySearchResult } from '../../../object-collection/shared/communi templateUrl: 'community-search-result-list-element.component.html' }) -@renderElementsFor(CommunitySearchResult, SetViewMode.List) +@renderElementsFor(CommunitySearchResult, ViewMode.ListElement) export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts index 5bd3c8ff5a..b2f096ff43 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts @@ -1,14 +1,12 @@ import { Component } from '@angular/core'; -import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; import { Item } from '../../../../core/shared/item.model'; import { focusBackground } from '../../../animations/focus'; -import { hasValue } from '../../../empty.util'; import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { SetViewMode } from '../../../view-mode'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { ItemViewMode } from '../../../items/item-type-decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-item-search-result-list-element', @@ -18,7 +16,7 @@ import { ItemViewMode } from '../../../items/item-type-decorator'; }) -@renderElementsFor(ItemSearchResult, SetViewMode.List) +@renderElementsFor(ItemSearchResult, ViewMode.ListElement) export class ItemSearchResultListElementComponent extends SearchResultListElementComponent { viewMode = ItemViewMode.Element; diff --git a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts b/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts index 29b1364a75..8663d37d35 100644 --- a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts +++ b/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts @@ -1,8 +1,8 @@ import { Component, Injector, Input, OnInit } from '@angular/core'; -import { SetViewMode } from '../../view-mode'; import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { rendersDSOType } from '../../object-collection/shared/dso-element-decorator' import { ListableObject } from '../../object-collection/shared/listable-object.model'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-wrapper-list-element', @@ -30,6 +30,6 @@ export class WrapperListElementComponent implements OnInit { private getListElement(): string { const f: GenericConstructor = this.object.constructor as GenericConstructor; - return rendersDSOType(f, SetViewMode.List); + return rendersDSOType(f, ViewMode.ListElement); } } diff --git a/src/app/shared/testing/search-service-stub.ts b/src/app/shared/testing/search-service-stub.ts index d886604ef2..b64fdd1330 100644 --- a/src/app/shared/testing/search-service-stub.ts +++ b/src/app/shared/testing/search-service-stub.ts @@ -1,22 +1,22 @@ import {of as observableOf, Observable , BehaviorSubject } from 'rxjs'; -import { SetViewMode } from '../view-mode'; +import { ViewMode } from '../../core/shared/view-mode.model'; export class SearchServiceStub { - private _viewMode: SetViewMode; + private _viewMode: ViewMode; private subject?: BehaviorSubject = new BehaviorSubject(this.testViewMode); viewMode = this.subject.asObservable(); constructor(private searchLink: string = '/search') { - this.setViewMode(SetViewMode.List); + this.setViewMode(ViewMode.ListElement); } - getViewMode(): Observable { + getViewMode(): Observable { return this.viewMode; } - setViewMode(viewMode: SetViewMode) { + setViewMode(viewMode: ViewMode) { this.testViewMode = viewMode; } @@ -24,11 +24,11 @@ export class SearchServiceStub { return null; } - get testViewMode(): SetViewMode { + get testViewMode(): ViewMode { return this._viewMode; } - set testViewMode(viewMode: SetViewMode) { + set testViewMode(viewMode: ViewMode) { this._viewMode = viewMode; this.subject.next(viewMode); } diff --git a/src/app/shared/view-mode-switch/view-mode-switch.component.html b/src/app/shared/view-mode-switch/view-mode-switch.component.html index 905cf29bac..b4c1c18d4f 100644 --- a/src/app/shared/view-mode-switch/view-mode-switch.component.html +++ b/src/app/shared/view-mode-switch/view-mode-switch.component.html @@ -1,31 +1,31 @@
- - - diff --git a/src/app/shared/view-mode-switch/view-mode-switch.component.spec.ts b/src/app/shared/view-mode-switch/view-mode-switch.component.spec.ts index 2fe405de3f..cc0175231e 100644 --- a/src/app/shared/view-mode-switch/view-mode-switch.component.spec.ts +++ b/src/app/shared/view-mode-switch/view-mode-switch.component.spec.ts @@ -8,8 +8,8 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { SearchService } from '../../+search-page/search-service/search.service'; import { ViewModeSwitchComponent } from './view-mode-switch.component'; -import { SetViewMode } from '../view-mode'; import { SearchServiceStub } from '../testing/search-service-stub'; +import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ template: '' }) class DummyComponent { } @@ -55,19 +55,19 @@ describe('ViewModeSwitchComponent', () => { }); it('should set list button as active when on list mode', fakeAsync(() => { - searchService.setViewMode(SetViewMode.List); + searchService.setViewMode(ViewMode.ListElement); tick(); fixture.detectChanges(); - expect(comp.currentMode).toBe(SetViewMode.List); + expect(comp.currentMode).toBe(ViewMode.ListElement); expect(listButton.classList).toContain('active'); expect(gridButton.classList).not.toContain('active'); })); it('should set grid button as active when on grid mode', fakeAsync(() => { - searchService.setViewMode(SetViewMode.Grid); + searchService.setViewMode(ViewMode.GridElement); tick(); fixture.detectChanges(); - expect(comp.currentMode).toBe(SetViewMode.Grid); + expect(comp.currentMode).toBe(ViewMode.GridElement); expect(listButton.classList).not.toContain('active'); expect(gridButton.classList).toContain('active'); })); diff --git a/src/app/shared/view-mode-switch/view-mode-switch.component.ts b/src/app/shared/view-mode-switch/view-mode-switch.component.ts index dc355c6409..cd0d8ce47d 100644 --- a/src/app/shared/view-mode-switch/view-mode-switch.component.ts +++ b/src/app/shared/view-mode-switch/view-mode-switch.component.ts @@ -22,7 +22,7 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy { */ @Input() inPlaceSearch; - currentMode: ViewMode = ViewMode.List; + currentMode: ViewMode = ViewMode.ListElement; viewModeEnum = ViewMode; private sub: Subscription; @@ -31,7 +31,7 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy { ngOnInit(): void { if (isEmpty(this.viewModeList)) { - this.viewModeList = [ViewMode.List, ViewMode.Grid]; + this.viewModeList = [ViewMode.ListElement, ViewMode.GridElement]; } this.sub = this.searchService.getViewMode().subscribe((viewMode: ViewMode) => { diff --git a/src/app/shared/view-mode.ts b/src/app/shared/view-mode.ts deleted file mode 100644 index 826d467d6f..0000000000 --- a/src/app/shared/view-mode.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Enum used for defining the view-mode of a set of elements - * List Display the elements in a (vertical) list - * Grid Display the elements in a grid - */ -export enum SetViewMode { - List = 'list', - Grid = 'grid', - Detail = 'detail' -} - -/** - * ViewMode refers to either a SetViewMode or ElementViewMode - */ -export type ViewMode = SetViewMode; From 20274bd4afaaee294f544f4052ee55e01a5906d2 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 27 Sep 2019 13:19:26 +0200 Subject: [PATCH 02/17] refactored ItemViewMode to be part of ViewMode and added the Context enum --- .../edit-relationship/edit-relationship.component.ts | 4 ++-- src/app/+item-page/simple/item-page.component.ts | 4 ++-- .../item-types/publication/publication.component.ts | 8 ++++---- .../metadata-representation-list.component.ts | 4 ++-- .../simple/related-items/related-items-component.ts | 4 ++-- src/app/core/shared/context.model.ts | 11 +++++++++++ src/app/core/shared/view-mode.model.ts | 4 +++- .../journal-issue-grid-element.component.ts | 5 +++-- .../journal-volume-grid-element.component.ts | 5 +++-- .../journal/journal-grid-element.component.ts | 5 +++-- .../journal-issue-list-element.component.ts | 5 +++-- .../journal-volume-list-element.component.ts | 5 +++-- .../journal/journal-list-element.component.ts | 5 +++-- .../journal-issue/journal-issue.component.ts | 5 +++-- .../journal-volume/journal-volume.component.ts | 5 +++-- .../item-pages/journal/journal.component.ts | 5 +++-- .../orgunit/orgunit-grid-element.component.ts | 5 +++-- .../person/person-grid-element.component.ts | 5 +++-- .../project/project-grid-element.component.ts | 5 +++-- .../orgunit/orgunit-list-element.component.ts | 5 +++-- .../orgunit-metadata-list-element.component.ts | 5 +++-- .../person/person-list-element.component.ts | 5 +++-- .../person/person-metadata-list-element.component.ts | 5 +++-- .../project/project-list-element.component.ts | 5 +++-- .../item-pages/orgunit/orgunit.component.ts | 5 +++-- .../item-pages/person/person.component.ts | 5 +++-- .../item-pages/project/project.component.ts | 5 +++-- src/app/shared/items/item-type-decorator.ts | 10 ++-------- .../switcher/item-type-switcher.component.spec.ts | 9 +++++---- .../publication/publication-grid-element.component.ts | 7 ++++--- .../item-search-result-grid-element.component.spec.ts | 4 ++-- .../item-search-result-grid-element.component.ts | 3 +-- .../item-list-element/item-list-element.component.ts | 3 +-- .../publication/publication-list-element.component.ts | 7 ++++--- .../item/item-metadata-list-element.component.ts | 7 ++++--- .../plain-text-metadata-list-element.component.ts | 7 ++++--- .../item-search-result-list-element.component.ts | 3 +-- 37 files changed, 114 insertions(+), 85 deletions(-) create mode 100644 src/app/core/shared/context.model.ts diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.ts index 497b06775a..302ebf68a7 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.ts @@ -4,7 +4,7 @@ import { cloneDeep } from 'lodash'; import { Item } from '../../../../core/shared/item.model'; import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service'; import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions'; -import { ItemViewMode } from '../../../../shared/items/item-type-decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ // tslint:disable-next-line:component-selector @@ -31,7 +31,7 @@ export class EditRelationshipComponent implements OnChanges { /** * The view-mode we're currently on */ - viewMode = ItemViewMode.Element; + viewMode = ViewMode.ListElement; constructor(private objectUpdatesService: ObjectUpdatesService) { } diff --git a/src/app/+item-page/simple/item-page.component.ts b/src/app/+item-page/simple/item-page.component.ts index 89d5977583..3b51357e00 100644 --- a/src/app/+item-page/simple/item-page.component.ts +++ b/src/app/+item-page/simple/item-page.component.ts @@ -15,7 +15,7 @@ import { MetadataService } from '../../core/metadata/metadata.service'; import { fadeInOut } from '../../shared/animations/fade'; import { hasValue } from '../../shared/empty.util'; import { redirectToPageNotFoundOn404 } from '../../core/shared/operators'; -import { ItemViewMode } from '../../shared/items/item-type-decorator'; +import { ViewMode } from '../../core/shared/view-mode.model'; /** * This component renders a simple item page. @@ -44,7 +44,7 @@ export class ItemPageComponent implements OnInit { /** * The view-mode we're currently on */ - viewMode = ItemViewMode.Full; + viewMode = ViewMode.StandalonePage; constructor( private route: ActivatedRoute, diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index 81e2726e0c..5cb7734404 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -2,15 +2,15 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { - DEFAULT_ITEM_TYPE, ItemViewMode, - rendersItemType + DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../shared/item.component'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Publication', ItemViewMode.Full) -@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Full) +@rendersItemType('Publication', ViewMode.StandalonePage) +@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.StandalonePage) @Component({ selector: 'ds-publication', styleUrls: ['./publication.component.scss'], diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts index f0dc222bf1..b585c9971b 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemViewMode } from '../../../shared/items/item-type-decorator'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-metadata-representation-list', @@ -25,5 +25,5 @@ export class MetadataRepresentationListComponent { * The view-mode we're currently on * @type {ElementViewMode} */ - viewMode = ItemViewMode.Metadata; + viewMode = ViewMode.MetadataField; } diff --git a/src/app/+item-page/simple/related-items/related-items-component.ts b/src/app/+item-page/simple/related-items/related-items-component.ts index 7b54d7316a..567c9b7112 100644 --- a/src/app/+item-page/simple/related-items/related-items-component.ts +++ b/src/app/+item-page/simple/related-items/related-items-component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import { ItemViewMode } from '../../../shared/items/item-type-decorator'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-related-items', @@ -26,5 +26,5 @@ export class RelatedItemsComponent { * The view-mode we're currently on * @type {ElementViewMode} */ - viewMode = ItemViewMode.Element; + viewMode = ViewMode.ListElement; } diff --git a/src/app/core/shared/context.model.ts b/src/app/core/shared/context.model.ts new file mode 100644 index 0000000000..96452bd5d6 --- /dev/null +++ b/src/app/core/shared/context.model.ts @@ -0,0 +1,11 @@ +/** + * This enumeration represents all possible ways of representing a group of objects in the UI + */ + +export enum Context { + SearchList = 'searchList', + SearchGrid = 'searchGrid', + Submission = 'submission', + AdminMenuList = 'adminMenuList', + SubmissionModal = 'submissionModal', +} diff --git a/src/app/core/shared/view-mode.model.ts b/src/app/core/shared/view-mode.model.ts index 78b55771e2..f49f3b490c 100644 --- a/src/app/core/shared/view-mode.model.ts +++ b/src/app/core/shared/view-mode.model.ts @@ -5,5 +5,7 @@ export enum ViewMode { ListElement = 'listElement', GridElement = 'gridElement', - DetailedListElement = 'detailedListElement' + DetailedListElement = 'detailedListElement', + StandalonePage = 'standalonePage', + MetadataField = 'metadataField' } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts index 06c27ebacf..f989e993b2 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts @@ -1,9 +1,10 @@ -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('JournalIssue', ItemViewMode.Card) +@rendersItemType('JournalIssue', ViewMode.GridElement) @Component({ selector: 'ds-journal-issue-grid-element', styleUrls: ['./journal-issue-grid-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts index e5183536ef..f4c4e8699f 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts @@ -1,9 +1,10 @@ -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('JournalVolume', ItemViewMode.Card) +@rendersItemType('JournalVolume', ViewMode.GridElement) @Component({ selector: 'ds-journal-volume-grid-element', styleUrls: ['./journal-volume-grid-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts index 7f23211538..4af5034a02 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts @@ -1,9 +1,10 @@ -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Journal', ItemViewMode.Card) +@rendersItemType('Journal', ViewMode.GridElement) @Component({ selector: 'ds-journal-grid-element', styleUrls: ['./journal-grid-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts index e1aeb7c4e6..723c4055eb 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('JournalIssue', ItemViewMode.Element) +@rendersItemType('JournalIssue', ViewMode.ListElement) @Component({ selector: 'ds-journal-issue-list-element', styleUrls: ['./journal-issue-list-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts index 42e83ea7bd..272af6fca5 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('JournalVolume', ItemViewMode.Element) +@rendersItemType('JournalVolume', ViewMode.ListElement) @Component({ selector: 'ds-journal-volume-list-element', styleUrls: ['./journal-volume-list-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts index fdcf0ba5b0..93eaae57ea 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Journal', ItemViewMode.Element) +@rendersItemType('Journal', ViewMode.ListElement) @Component({ selector: 'ds-journal-list-element', styleUrls: ['./journal-list-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts index b584fa3285..0db13d8a6f 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts @@ -1,12 +1,13 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('JournalIssue', ItemViewMode.Full) +@rendersItemType('JournalIssue', ViewMode.StandalonePage) @Component({ selector: 'ds-journal-issue', styleUrls: ['./journal-issue.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts index 66df0b8104..6a7db84c43 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts @@ -1,12 +1,13 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('JournalVolume', ItemViewMode.Full) +@rendersItemType('JournalVolume', ViewMode.StandalonePage) @Component({ selector: 'ds-journal-volume', styleUrls: ['./journal-volume.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts index a8f071d78a..5ac378a90b 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts @@ -1,12 +1,13 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Journal', ItemViewMode.Full) +@rendersItemType('Journal', ViewMode.StandalonePage) @Component({ selector: 'ds-journal', styleUrls: ['./journal.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts index 0effc22027..c718d3565b 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts @@ -1,9 +1,10 @@ -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('OrgUnit', ItemViewMode.Card) +@rendersItemType('OrgUnit', ViewMode.GridElement) @Component({ selector: 'ds-orgunit-grid-element', styleUrls: ['./orgunit-grid-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts index bf7b8aa119..374ec323b4 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts @@ -1,9 +1,10 @@ -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { focusShadow } from '../../../../shared/animations/focus'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Person', ItemViewMode.Card) +@rendersItemType('Person', ViewMode.GridElement) @Component({ selector: 'ds-person-grid-element', styleUrls: ['./person-grid-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts index 15d525fcf2..742562cdc9 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts @@ -1,9 +1,10 @@ -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Project', ItemViewMode.Card) +@rendersItemType('Project', ViewMode.GridElement) @Component({ selector: 'ds-project-grid-element', styleUrls: ['./project-grid-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts index 9a56bb6d03..d302af4e84 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('OrgUnit', ItemViewMode.Element) +@rendersItemType('OrgUnit', ViewMode.ListElement) @Component({ selector: 'ds-orgunit-list-element', styleUrls: ['./orgunit-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts index d59e5c6cc3..4643465f06 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts @@ -1,9 +1,10 @@ import { Component } from '@angular/core'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('OrgUnit', ItemViewMode.Element, MetadataRepresentationType.Item) +@rendersItemType('OrgUnit', ViewMode.ListElement, MetadataRepresentationType.Item) @Component({ selector: 'ds-orgunit-metadata-list-element', templateUrl: './orgunit-metadata-list-element.component.html' diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts index 46d90a6f2d..7505eec247 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Person', ItemViewMode.Element) +@rendersItemType('Person', ViewMode.ListElement) @Component({ selector: 'ds-person-list-element', styleUrls: ['./person-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts index b036768d0a..c60a29e41e 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts @@ -1,9 +1,10 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Person', ItemViewMode.Element, MetadataRepresentationType.Item) +@rendersItemType('Person', ViewMode.ListElement, MetadataRepresentationType.Item) @Component({ selector: 'ds-person-metadata-list-element', templateUrl: './person-metadata-list-element.component.html' diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts index 2d3e716ff4..d8765aa254 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Project', ItemViewMode.Element) +@rendersItemType('Project', ViewMode.ListElement) @Component({ selector: 'ds-project-list-element', styleUrls: ['./project-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts index 031ca14ebb..10c210edd0 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts @@ -1,12 +1,13 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('OrgUnit', ItemViewMode.Full) +@rendersItemType('OrgUnit', ViewMode.StandalonePage) @Component({ selector: 'ds-orgunit', styleUrls: ['./orgunit.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts index 8b36175b96..6a61a9cf4a 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts @@ -1,14 +1,15 @@ import { Component, Inject } from '@angular/core'; import { Observable , of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Person', ItemViewMode.Full) +@rendersItemType('Person', ViewMode.StandalonePage) @Component({ selector: 'ds-person', styleUrls: ['./person.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts index 13c2b54ba4..cc995c79e4 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts @@ -2,12 +2,13 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType('Project', ItemViewMode.Full) +@rendersItemType('Project', ViewMode.StandalonePage) @Component({ selector: 'ds-project', styleUrls: ['./project.component.scss'], diff --git a/src/app/shared/items/item-type-decorator.ts b/src/app/shared/items/item-type-decorator.ts index 3a040ae5bf..a3f7c6b6f8 100644 --- a/src/app/shared/items/item-type-decorator.ts +++ b/src/app/shared/items/item-type-decorator.ts @@ -1,15 +1,9 @@ import { hasNoValue, hasValue } from '../empty.util'; import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; - -export enum ItemViewMode { - Element = 'element', - Card = 'card', - Full = 'full', - Metadata = 'metadata' -} +import { ViewMode } from '../../core/shared/view-mode.model'; export const DEFAULT_ITEM_TYPE = 'Default'; -export const DEFAULT_VIEW_MODE = ItemViewMode.Element; +export const DEFAULT_VIEW_MODE = ViewMode.ListElement; export const NO_REPRESENTATION_TYPE = MetadataRepresentationType.None; export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; diff --git a/src/app/shared/items/switcher/item-type-switcher.component.spec.ts b/src/app/shared/items/switcher/item-type-switcher.component.spec.ts index 76389201c5..c564c72564 100644 --- a/src/app/shared/items/switcher/item-type-switcher.component.spec.ts +++ b/src/app/shared/items/switcher/item-type-switcher.component.spec.ts @@ -5,10 +5,11 @@ import { PageInfo } from '../../../core/shared/page-info.model'; import { Item } from '../../../core/shared/item.model'; import { PaginatedList } from '../../../core/data/paginated-list'; import * as decorator from '../item-type-decorator'; -import { getComponentByItemType, ItemViewMode } from '../item-type-decorator'; +import { getComponentByItemType} from '../item-type-decorator'; import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model'; import { createSuccessfulRemoteDataObject$ } from '../../testing/utils'; import createSpy = jasmine.createSpy; +import { ViewMode } from '../../../core/shared/view-mode.model'; const relationType = 'type'; const mockItem: Item = Object.assign(new Item(), { @@ -29,7 +30,7 @@ const mockItem: Item = Object.assign(new Item(), { } }); const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); -let viewMode = ItemViewMode.Full; +let viewMode = ViewMode.StandalonePage; describe('ItemTypeSwitcherComponent', () => { let comp: ItemTypeSwitcherComponent; @@ -52,7 +53,7 @@ describe('ItemTypeSwitcherComponent', () => { describe('when the injected object is of type Item', () => { beforeEach(() => { - viewMode = ItemViewMode.Full; + viewMode = ViewMode.StandalonePage; comp.object = mockItem; comp.viewMode = viewMode; }); @@ -70,7 +71,7 @@ describe('ItemTypeSwitcherComponent', () => { describe('when the injected object is of type MetadataRepresentation', () => { beforeEach(() => { - viewMode = ItemViewMode.Metadata; + viewMode = ViewMode.MetadataField; comp.object = mockItemMetadataRepresentation; comp.viewMode = viewMode; }); diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts index 1bcd028baf..63f5148aec 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts @@ -1,10 +1,11 @@ import { TypedItemSearchResultGridElementComponent } from '../typed-item-search-result-grid-element.component'; -import { DEFAULT_ITEM_TYPE, ItemViewMode, rendersItemType } from '../../../../items/item-type-decorator'; +import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../animations/focus'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; -@rendersItemType('Publication', ItemViewMode.Card) -@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Card) +@rendersItemType('Publication', ViewMode.GridElement) +@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.GridElement) @Component({ selector: 'ds-publication-grid-element', styleUrls: ['./publication-grid-element.component.scss'], diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts index 282478ec33..d757e87583 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts @@ -8,7 +8,7 @@ import { Item } from '../../../../core/shared/item.model'; import { TruncatableService } from '../../../truncatable/truncatable.service'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { ItemViewMode } from '../../../items/item-type-decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent; let fixture: ComponentFixture; @@ -56,6 +56,6 @@ describe('ItemSearchResultGridElementComponent', () => { it('should show send the object to item-type-switcher using viewMode "Card"', () => { const itemTypeSwitcherComp = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance; expect(itemTypeSwitcherComp.object).toBe(mockItemWithRelationshipType); - expect(itemTypeSwitcherComp.viewMode).toEqual(ItemViewMode.Card); + expect(itemTypeSwitcherComp.viewMode).toEqual(ViewMode.GridElement); }); }); diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts index f0ff124439..cb10d0b2db 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts @@ -5,7 +5,6 @@ import { SearchResultGridElementComponent } from '../search-result-grid-element. import { Item } from '../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { focusShadow } from '../../../animations/focus'; -import { ItemViewMode } from '../../../items/item-type-decorator'; import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ @@ -17,5 +16,5 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; @renderElementsFor(ItemSearchResult, ViewMode.GridElement) export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent { - viewMode = ItemViewMode.Card; + viewMode = ViewMode.GridElement; } diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.ts index 2793a41d65..3428c3f68d 100644 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.ts @@ -3,7 +3,6 @@ import { Component } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { ItemViewMode } from '../../items/item-type-decorator'; import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ @@ -18,5 +17,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; */ @renderElementsFor(Item, ViewMode.ListElement) export class ItemListElementComponent extends AbstractListableElementComponent { - viewMode = ItemViewMode.Element; + viewMode = ViewMode.ListElement; } diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 4717ff1df2..46de8ac6cc 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -1,9 +1,10 @@ import { Component } from '@angular/core'; -import { DEFAULT_ITEM_TYPE, ItemViewMode, rendersItemType } from '../../../../items/item-type-decorator'; +import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; -@rendersItemType('Publication', ItemViewMode.Element) -@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Element) +@rendersItemType('Publication', ViewMode.ListElement) +@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.ListElement) @Component({ selector: 'ds-publication-list-element', styleUrls: ['./publication-list-element.component.scss'], diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts index 084567a885..cf2786a2e6 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts @@ -1,9 +1,10 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; -import { DEFAULT_ITEM_TYPE, ItemViewMode, rendersItemType } from '../../../items/item-type-decorator'; +import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../items/item-type-decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Metadata, MetadataRepresentationType.Item) +@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.MetadataField, MetadataRepresentationType.Item) @Component({ selector: 'ds-item-metadata-list-element', templateUrl: './item-metadata-list-element.component.html' @@ -18,5 +19,5 @@ export class ItemMetadataListElementComponent extends MetadataRepresentationList * The view-mode we're currently on * @type {ElementViewMode} */ - viewMode = ItemViewMode.Element; + viewMode = ViewMode.ListElement; } diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts index 7c4785e37c..0ebccc79f8 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts @@ -1,11 +1,12 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; -import { DEFAULT_ITEM_TYPE, ItemViewMode, rendersItemType } from '../../../items/item-type-decorator'; +import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../items/item-type-decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Metadata, MetadataRepresentationType.PlainText) +@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.MetadataField, MetadataRepresentationType.PlainText) // For now, authority controlled fields are rendered the same way as plain text fields -@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Metadata, MetadataRepresentationType.AuthorityControlled) +@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.MetadataField, MetadataRepresentationType.AuthorityControlled) @Component({ selector: 'ds-plain-text-metadata-list-element', templateUrl: './plain-text-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts index b2f096ff43..6acedefdbd 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts @@ -5,7 +5,6 @@ import { focusBackground } from '../../../animations/focus'; import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; -import { ItemViewMode } from '../../../items/item-type-decorator'; import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ @@ -18,6 +17,6 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; @renderElementsFor(ItemSearchResult, ViewMode.ListElement) export class ItemSearchResultListElementComponent extends SearchResultListElementComponent { - viewMode = ItemViewMode.Element; + viewMode = ViewMode.ListElement; } From 5353e889a320a9b75f5531cc356f4eb6ce44aef2 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 27 Sep 2019 16:58:24 +0200 Subject: [PATCH 03/17] added new decorator for metadata representations --- src/app/core/shared/context.model.ts | 1 + src/app/shared/items/item-type-decorator.ts | 34 +++----------- .../switcher/item-type-switcher.component.ts | 7 +-- ...etadata-representation-loader.component.ts | 0 .../metadata-representation.decorator.ts | 44 +++++++++++++++++++ 5 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 src/app/shared/metadata-representation/metadata-representation-loader.component.ts create mode 100644 src/app/shared/metadata-representation/metadata-representation.decorator.ts diff --git a/src/app/core/shared/context.model.ts b/src/app/core/shared/context.model.ts index 96452bd5d6..907210b2f1 100644 --- a/src/app/core/shared/context.model.ts +++ b/src/app/core/shared/context.model.ts @@ -3,6 +3,7 @@ */ export enum Context { + Undefined = 'undefined', SearchList = 'searchList', SearchGrid = 'searchGrid', Submission = 'submission', diff --git a/src/app/shared/items/item-type-decorator.ts b/src/app/shared/items/item-type-decorator.ts index a3f7c6b6f8..e6c7c18150 100644 --- a/src/app/shared/items/item-type-decorator.ts +++ b/src/app/shared/items/item-type-decorator.ts @@ -1,11 +1,9 @@ import { hasNoValue, hasValue } from '../empty.util'; -import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; import { ViewMode } from '../../core/shared/view-mode.model'; export const DEFAULT_ITEM_TYPE = 'Default'; export const DEFAULT_VIEW_MODE = ViewMode.ListElement; -export const NO_REPRESENTATION_TYPE = MetadataRepresentationType.None; -export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; + const map = new Map(); @@ -13,23 +11,16 @@ const map = new Map(); * Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) * @param type * @param viewMode - * @param representationType */ -export function rendersItemType(type: string, viewMode: string, representationType?: MetadataRepresentationType) { +export function rendersItemType(type: string, viewMode: string) { return function decorator(component: any) { if (hasNoValue(map.get(viewMode))) { map.set(viewMode, new Map()); } - if (hasNoValue(map.get(viewMode).get(type))) { - map.get(viewMode).set(type, new Map()); + if (hasValue(map.get(viewMode).get(type))) { + throw new Error(`There can't be more than one component to render Metadata of type "${type}" in view mode "${viewMode}"`); } - if (hasNoValue(representationType)) { - representationType = NO_REPRESENTATION_TYPE; - } - if (hasValue(map.get(viewMode).get(type).get(representationType))) { - throw new Error(`There can't be more than one component to render Metadata of type "${type}" in view mode "${viewMode}" with representation type "${representationType}"`); - } - map.get(viewMode).get(type).set(representationType, component); + map.get(viewMode).set(type, component); }; } @@ -37,24 +28,13 @@ export function rendersItemType(type: string, viewMode: string, representationTy * Get the component used for rendering an item by type and viewMode (and optionally a representationType) * @param type * @param viewMode - * @param representationType */ -export function getComponentByItemType(type: string, viewMode: string, representationType?: MetadataRepresentationType) { - if (hasNoValue(representationType)) { - representationType = NO_REPRESENTATION_TYPE; - } +export function getComponentByItemType(type: string, viewMode: string) { if (hasNoValue(map.get(viewMode))) { viewMode = DEFAULT_VIEW_MODE; } if (hasNoValue(map.get(viewMode).get(type))) { type = DEFAULT_ITEM_TYPE; } - let representationComponent = map.get(viewMode).get(type).get(representationType); - if (hasNoValue(representationComponent)) { - representationComponent = map.get(viewMode).get(type).get(DEFAULT_REPRESENTATION_TYPE); - } - if (hasNoValue(representationComponent)) { - representationComponent = map.get(viewMode).get(type).get(NO_REPRESENTATION_TYPE); - } - return representationComponent; + return map.get(viewMode).get(type); } diff --git a/src/app/shared/items/switcher/item-type-switcher.component.ts b/src/app/shared/items/switcher/item-type-switcher.component.ts index cd061bc1dd..0f31b10c7a 100644 --- a/src/app/shared/items/switcher/item-type-switcher.component.ts +++ b/src/app/shared/items/switcher/item-type-switcher.component.ts @@ -20,7 +20,7 @@ export class ItemTypeSwitcherComponent implements OnInit { /** * The item or metadata to determine the component for */ - @Input() object: Item | SearchResult | MetadataRepresentation; + @Input() object: Item | SearchResult; /** * The preferred view-mode to display @@ -50,11 +50,6 @@ export class ItemTypeSwitcherComponent implements OnInit { * @returns {string} */ private getComponent(): string { - if (hasValue((this.object as any).representationType)) { - const metadataRepresentation = this.object as MetadataRepresentation; - return getComponentByItemType(metadataRepresentation.itemType, this.viewMode, metadataRepresentation.representationType); - } - let item: Item; if (hasValue((this.object as any).indexableObject)) { const searchResult = this.object as ItemSearchResult; diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.ts new file mode 100644 index 0000000000..0eee4f6d2f --- /dev/null +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.ts @@ -0,0 +1,44 @@ +import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; +import { hasNoValue, hasValue } from '../empty.util'; +import { Context } from '../../core/shared/context.model'; +import { DEFAULT_ITEM_TYPE } from '../items/item-type-decorator'; + +const map = new Map(); + +export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; +export const DEFAULT_CONTEXT = Context.Undefined; + +export function metadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { + return function decorator(component: any) { + if (hasNoValue(map.get(entityType))) { + map.set(entityType, new Map()); + } + + if (hasNoValue(map.get(entityType).get(mdRepresentationType))) { + map.get(entityType).set(mdRepresentationType, new Map()); + } + + if (hasValue(map.get(entityType).get(mdRepresentationType).get(context))) { + throw new Error(`There can't be more than one component to render Entity of type "${entityType}" in MetadataRepresentation "${mdRepresentationType}" with context "${context}"`); + } + map.get(entityType).get(mdRepresentationType).set(context, component); + } +} + +export function getMetadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { + if (hasNoValue(entityType) || hasNoValue(map.get(entityType))) { + entityType = DEFAULT_ITEM_TYPE; + } + + if (hasNoValue(map.get(entityType).get(mdRepresentationType))) { + mdRepresentationType = DEFAULT_REPRESENTATION_TYPE; + } + + let representationComponent = map.get(entityType).get(mdRepresentationType).get(context); + + if (hasNoValue(representationComponent)) { + representationComponent = map.get(entityType).get(mdRepresentationType).get(DEFAULT_REPRESENTATION_TYPE); + } + + return representationComponent; +} \ No newline at end of file From 5b6aa951ad283f7c96cce66dafb82af4cbc68d82 Mon Sep 17 00:00:00 2001 From: lotte Date: Wed, 2 Oct 2019 15:43:19 +0200 Subject: [PATCH 04/17] continued refactoring listable objects --- .../publication/publication.component.spec.ts | 2 +- .../publication/publication.component.ts | 8 +-- .../item-types/shared/item.component.spec.ts | 2 +- .../item-types/shared/item.component.ts | 2 +- src/app/core/shared/context.model.ts | 6 +- .../journal-issue-grid-element.component.ts | 4 +- .../journal-volume-grid-element.component.ts | 4 +- .../journal/journal-grid-element.component.ts | 4 +- ...urnal-issue-list-element.component.spec.ts | 2 +- .../journal-issue-list-element.component.ts | 4 +- ...rnal-volume-list-element.component.spec.ts | 2 +- .../journal-volume-list-element.component.ts | 4 +- .../journal-list-element.component.spec.ts | 2 +- .../journal/journal-list-element.component.ts | 4 +- .../journal-issue/journal-issue.component.ts | 4 +- .../journal-volume.component.ts | 4 +- .../journal/journal.component.spec.ts | 2 +- .../item-pages/journal/journal.component.ts | 4 +- .../orgunit/orgunit-grid-element.component.ts | 4 +- .../person/person-grid-element.component.ts | 4 +- .../project/project-grid-element.component.ts | 4 +- ...nit-item-page-list-element.component.html} | 0 ...rgunit-item-page-list-element.component.ts | 16 +++++ .../orgunit-list-element.component.spec.ts | 2 +- .../orgunit/orgunit-list-element.component.ts | 4 +- ...orgunit-metadata-list-element.component.ts | 16 ----- ...son-item-page-list-element.component.html} | 0 ...person-item-page-list-element.component.ts | 16 +++++ .../person-list-element.component.spec.ts | 2 +- .../person/person-list-element.component.ts | 4 +- .../person-metadata-list-element.component.ts | 16 ----- .../project-list-element.component.spec.ts | 2 +- .../project/project-list-element.component.ts | 6 +- .../item-pages/orgunit/orgunit.component.ts | 4 +- .../item-pages/person/person.component.ts | 6 +- .../item-pages/project/project.component.ts | 4 +- .../research-entities.module.ts | 8 +-- src/app/shared/items/item-type-decorator.ts | 40 ------------ .../item-type-switcher.component.html | 1 - .../item-type-switcher.component.scss | 1 - .../switcher/item-type-switcher.component.ts | 64 ------------------- ...adata-representation-loader.component.html | 1 + ...etadata-representation-loader.component.ts | 45 +++++++++++++ .../metadata-representation.decorator.ts | 29 ++++----- .../metadata-representation.directive.ts | 8 +++ .../shared/dso-element-decorator.spec.ts | 16 ----- .../shared/dso-element-decorator.ts | 20 ------ ...ble-object-component-loader.component.html | 1 + ...object-component-loader.component.spec.ts} | 10 +-- ...table-object-component-loader.component.ts | 43 +++++++++++++ .../listable-object.decorator.spec.ts | 16 +++++ .../listable-object.decorator.ts | 50 +++++++++++++++ .../listable-object.directive.ts | 8 +++ ...-dspace-result-detail-element.component.ts | 6 +- ...-dspace-result-detail-element.component.ts | 4 +- ...-dspace-result-detail-element.component.ts | 6 +- ...-dspace-result-detail-element.component.ts | 6 +- ...-dspace-result-detail-element.component.ts | 6 +- .../wrapper-detail-element.component.html | 1 - .../wrapper-detail-element.component.scss | 2 - .../wrapper-detail-element.component.spec.ts | 44 ------------- .../wrapper-detail-element.component.ts | 56 ---------------- .../collection-grid-element.component.ts | 4 +- .../community-grid-element.component.ts | 4 +- .../item-grid-element.component.ts | 6 +- ...publication-grid-element.component.spec.ts | 2 +- .../publication-grid-element.component.ts | 6 +- ...arch-result-grid-element.component.spec.ts | 2 +- ...em-search-result-grid-element.component.ts | 2 +- ...on-search-result-grid-element.component.ts | 4 +- ...ty-search-result-grid-element.component.ts | 4 +- ...em-search-result-grid-element.component.ts | 6 +- .../wrapper-grid-element.component.html | 1 - .../wrapper-grid-element.component.scss | 1 - .../wrapper-grid-element.component.spec.ts | 43 ------------- .../wrapper-grid-element.component.ts | 32 ---------- .../browse-entry-list-element.component.ts | 4 +- .../collection-list-element.component.ts | 4 +- .../community-list-element.component.ts | 4 +- .../item-list-element.component.ts | 4 +- ...publication-list-element.component.spec.ts | 2 +- .../publication-list-element.component.ts | 6 +- ...arch-result-list-element.component.spec.ts | 2 +- ...em-search-result-list-element.component.ts | 2 +- ...em-metadata-list-element.component.spec.ts | 2 +- .../item-metadata-list-element.component.ts | 5 +- ...a-representation-list-element.component.ts | 6 +- ...xt-metadata-list-element.component.spec.ts | 2 +- ...in-text-metadata-list-element.component.ts | 8 +-- ...my-dspace-result-list-element.component.ts | 6 +- ...my-dspace-result-list-element.component.ts | 4 +- ...my-dspace-result-list-element.component.ts | 6 +- ...my-dspace-result-list-element.component.ts | 6 +- ...my-dspace-result-list-element.component.ts | 4 +- ...on-search-result-list-element.component.ts | 4 +- ...ty-search-result-list-element.component.ts | 4 +- ...em-search-result-list-element.component.ts | 4 +- .../wrapper-list-element.component.html | 1 - .../wrapper-list-element.component.scss | 1 - .../wrapper-list-element.component.ts | 35 ---------- src/app/shared/shared.module.ts | 12 ++-- 101 files changed, 369 insertions(+), 552 deletions(-) rename src/app/entity-groups/research-entities/item-list-elements/orgunit/{orgunit-metadata-list-element.component.html => orgunit-item-page-list-element.component.html} (100%) create mode 100644 src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts delete mode 100644 src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts rename src/app/entity-groups/research-entities/item-list-elements/person/{person-metadata-list-element.component.html => person-item-page-list-element.component.html} (100%) create mode 100644 src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts delete mode 100644 src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts delete mode 100644 src/app/shared/items/item-type-decorator.ts delete mode 100644 src/app/shared/items/switcher/item-type-switcher.component.html delete mode 100644 src/app/shared/items/switcher/item-type-switcher.component.scss delete mode 100644 src/app/shared/items/switcher/item-type-switcher.component.ts create mode 100644 src/app/shared/metadata-representation/metadata-representation-loader.component.html create mode 100644 src/app/shared/metadata-representation/metadata-representation.directive.ts delete mode 100644 src/app/shared/object-collection/shared/dso-element-decorator.spec.ts delete mode 100644 src/app/shared/object-collection/shared/dso-element-decorator.ts create mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html rename src/app/shared/{items/switcher/item-type-switcher.component.spec.ts => object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts} (88%) create mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts create mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts create mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts create mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts delete mode 100644 src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.html delete mode 100644 src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.scss delete mode 100644 src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.spec.ts delete mode 100644 src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts delete mode 100644 src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.html delete mode 100644 src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.scss delete mode 100644 src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.spec.ts delete mode 100644 src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts delete mode 100644 src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.html delete mode 100644 src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.scss delete mode 100644 src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts b/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts index eac23a9748..db2c07c63a 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts @@ -3,7 +3,7 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index 5cb7734404..09319a4fa6 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -1,16 +1,14 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { - DEFAULT_ITEM_TYPE, rendersItemType -} from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../shared/item.component'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Publication', ViewMode.StandalonePage) -@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.StandalonePage) +@listableObjectComponent('Publication', ViewMode.StandalonePage) +@listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.StandalonePage) @Component({ selector: 'ds-publication', styleUrls: ['./publication.component.scss'], diff --git a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts index 3f525e6a25..e6880c3c90 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts @@ -7,7 +7,7 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { isNotEmpty } from '../../../../shared/empty.util'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 556496fe49..6ad84ffae2 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -8,7 +8,7 @@ import { RelationshipType } from '../../../../core/shared/item-relationships/rel import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { Item } from '../../../../core/shared/item.model'; import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; diff --git a/src/app/core/shared/context.model.ts b/src/app/core/shared/context.model.ts index 907210b2f1..a0e7f6a967 100644 --- a/src/app/core/shared/context.model.ts +++ b/src/app/core/shared/context.model.ts @@ -4,9 +4,9 @@ export enum Context { Undefined = 'undefined', - SearchList = 'searchList', - SearchGrid = 'searchGrid', + ItemPage = 'itemPage', + Search = 'search', Submission = 'submission', - AdminMenuList = 'adminMenuList', + AdminMenu = 'adminMenu', SubmissionModal = 'submissionModal', } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts index f989e993b2..75e23de21d 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts @@ -1,10 +1,10 @@ -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('JournalIssue', ViewMode.GridElement) +@listableObjectComponent('JournalIssue', ViewMode.GridElement) @Component({ selector: 'ds-journal-issue-grid-element', styleUrls: ['./journal-issue-grid-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts index f4c4e8699f..35f1a6161d 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts @@ -1,10 +1,10 @@ -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('JournalVolume', ViewMode.GridElement) +@listableObjectComponent('JournalVolume', ViewMode.GridElement) @Component({ selector: 'ds-journal-volume-grid-element', styleUrls: ['./journal-volume-grid-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts index 4af5034a02..4596549e3a 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts @@ -1,10 +1,10 @@ -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Journal', ViewMode.GridElement) +@listableObjectComponent('Journal', ViewMode.GridElement) @Component({ selector: 'ds-journal-grid-element', styleUrls: ['./journal-grid-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts index 24498088cb..37234f8140 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { JournalIssueListElementComponent } from './journal-issue-list-element.c import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let journalIssueListElementComponent: JournalIssueListElementComponent; diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts index 723c4055eb..847b8a6978 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('JournalIssue', ViewMode.ListElement) +@listableObjectComponent('JournalIssue', ViewMode.ListElement) @Component({ selector: 'ds-journal-issue-list-element', styleUrls: ['./journal-issue-list-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts index 15f5424960..4872d47c31 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { JournalVolumeListElementComponent } from './journal-volume-list-element import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let journalVolumeListElementComponent: JournalVolumeListElementComponent; diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts index 272af6fca5..e1bc178b5e 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('JournalVolume', ViewMode.ListElement) +@listableObjectComponent('JournalVolume', ViewMode.ListElement) @Component({ selector: 'ds-journal-volume-list-element', styleUrls: ['./journal-volume-list-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts index 204672dfe9..469549821e 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { JournalListElementComponent } from './journal-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let journalListElementComponent: JournalListElementComponent; diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts index 93eaae57ea..05e1576219 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Journal', ViewMode.ListElement) +@listableObjectComponent('Journal', ViewMode.ListElement) @Component({ selector: 'ds-journal-list-element', styleUrls: ['./journal-list-element.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts index 0db13d8a6f..631ec64490 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts @@ -1,13 +1,13 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('JournalIssue', ViewMode.StandalonePage) +@listableObjectComponent('JournalIssue', ViewMode.StandalonePage) @Component({ selector: 'ds-journal-issue', styleUrls: ['./journal-issue.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts index 6a7db84c43..72cfc103fa 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts @@ -1,13 +1,13 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('JournalVolume', ViewMode.StandalonePage) +@listableObjectComponent('JournalVolume', ViewMode.StandalonePage) @Component({ selector: 'ds-journal-volume', styleUrls: ['./journal-volume.component.scss'], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts index c66c3a2462..29398befb5 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts index 5ac378a90b..32b2648477 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts @@ -1,13 +1,13 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Journal', ViewMode.StandalonePage) +@listableObjectComponent('Journal', ViewMode.StandalonePage) @Component({ selector: 'ds-journal', styleUrls: ['./journal.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts index c718d3565b..f7a13f1033 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts @@ -1,10 +1,10 @@ -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('OrgUnit', ViewMode.GridElement) +@listableObjectComponent('OrgUnit', ViewMode.GridElement) @Component({ selector: 'ds-orgunit-grid-element', styleUrls: ['./orgunit-grid-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts index 374ec323b4..2458d0b99d 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts @@ -1,10 +1,10 @@ -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { focusShadow } from '../../../../shared/animations/focus'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Person', ViewMode.GridElement) +@listableObjectComponent('Person', ViewMode.GridElement) @Component({ selector: 'ds-person-grid-element', styleUrls: ['./person-grid-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts index 742562cdc9..067e14bae3 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts @@ -1,10 +1,10 @@ -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Project', ViewMode.GridElement) +@listableObjectComponent('Project', ViewMode.GridElement) @Component({ selector: 'ds-project-grid-element', styleUrls: ['./project-grid-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.html rename to src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts new file mode 100644 index 0000000000..350ddf7ece --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -0,0 +1,16 @@ +import { Component } from '@angular/core'; +import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { Context } from '../../../../core/shared/context.model'; + +@listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) +@Component({ + selector: 'ds-orgunit-item-page-list-element', + templateUrl: './orgunit-item-page-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type OrgUnit + */ +export class OrgunitItemPageListElementComponent extends TypedItemSearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts index dd2b138abb..a06ed5ac72 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { OrgUnitListElementComponent } from './orgunit-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let orgUnitListElementComponent: OrgUnitListElementComponent; diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts index d302af4e84..8348a3fe35 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('OrgUnit', ViewMode.ListElement) +@listableObjectComponent('OrgUnit', ViewMode.ListElement) @Component({ selector: 'ds-orgunit-list-element', styleUrls: ['./orgunit-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts deleted file mode 100644 index 4643465f06..0000000000 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component } from '@angular/core'; -import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; - -@rendersItemType('OrgUnit', ViewMode.ListElement, MetadataRepresentationType.Item) -@Component({ - selector: 'ds-orgunit-metadata-list-element', - templateUrl: './orgunit-metadata-list-element.component.html' -}) -/** - * The component for displaying a list element for an item of the type OrgUnit - */ -export class OrgUnitMetadataListElementComponent extends TypedItemSearchResultListElementComponent { -} diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.html rename to src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts new file mode 100644 index 0000000000..2569a9cb4e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts @@ -0,0 +1,16 @@ +import { Component } from '@angular/core'; +import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { Context } from '../../../../core/shared/context.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; + +@listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) +@Component({ + selector: 'ds-person-item-page-list-element', + templateUrl: './person-item-page-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Person + */ +export class PersonItemPageListElementComponent extends TypedItemSearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts index 3b6aeae45b..9553f8ea2c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { PersonListElementComponent } from './person-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let personListElementComponent: PersonListElementComponent; diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts index 7505eec247..bd46cb1cdd 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Person', ViewMode.ListElement) +@listableObjectComponent('Person', ViewMode.ListElement) @Component({ selector: 'ds-person-list-element', styleUrls: ['./person-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts deleted file mode 100644 index c60a29e41e..0000000000 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; - -@rendersItemType('Person', ViewMode.ListElement, MetadataRepresentationType.Item) -@Component({ - selector: 'ds-person-metadata-list-element', - templateUrl: './person-metadata-list-element.component.html' -}) -/** - * The component for displaying a list element for an item of the type Person - */ -export class PersonMetadataListElementComponent extends TypedItemSearchResultListElementComponent { -} diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts index 02dc3f6d73..0c171ae9ba 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { ProjectListElementComponent } from './project-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let projectListElementComponent: ProjectListElementComponent; diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts index d8765aa254..d6b0dbfbce 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; +import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -@rendersItemType('Project', ViewMode.ListElement) +@metadataRepresentationComponent('Project', MetadataRepresentationType.PlainText) @Component({ selector: 'ds-project-list-element', styleUrls: ['./project-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts index 10c210edd0..164388547c 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts @@ -1,13 +1,13 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('OrgUnit', ViewMode.StandalonePage) +@listableObjectComponent('OrgUnit', ViewMode.StandalonePage) @Component({ selector: 'ds-orgunit', styleUrls: ['./orgunit.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts index 6a61a9cf4a..4783a7548e 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts @@ -1,15 +1,15 @@ import { Component, Inject } from '@angular/core'; import { Observable , of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Person', ViewMode.StandalonePage) +@listableObjectComponent('Person', ViewMode.StandalonePage) @Component({ selector: 'ds-person', styleUrls: ['./person.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts index cc995c79e4..776e38e7f4 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts @@ -2,13 +2,13 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Project', ViewMode.StandalonePage) +@listableObjectComponent('Project', ViewMode.StandalonePage) @Component({ selector: 'ds-project', styleUrls: ['./project.component.scss'], diff --git a/src/app/entity-groups/research-entities/research-entities.module.ts b/src/app/entity-groups/research-entities/research-entities.module.ts index 099fa2a6a3..1f6e477097 100644 --- a/src/app/entity-groups/research-entities/research-entities.module.ts +++ b/src/app/entity-groups/research-entities/research-entities.module.ts @@ -6,8 +6,8 @@ import { OrgunitComponent } from './item-pages/orgunit/orgunit.component'; import { PersonComponent } from './item-pages/person/person.component'; import { ProjectComponent } from './item-pages/project/project.component'; import { OrgUnitListElementComponent } from './item-list-elements/orgunit/orgunit-list-element.component'; -import { OrgUnitMetadataListElementComponent } from './item-list-elements/orgunit/orgunit-metadata-list-element.component'; -import { PersonMetadataListElementComponent } from './item-list-elements/person/person-metadata-list-element.component'; +import { OrgunitItemPageListElementComponent } from './item-list-elements/orgunit/orgunit-item-page-list-element.component'; +import { PersonItemPageListElementComponent } from './item-list-elements/person/person-item-page-list-element.component'; import { PersonListElementComponent } from './item-list-elements/person/person-list-element.component'; import { ProjectListElementComponent } from './item-list-elements/project/project-list-element.component'; import { TooltipModule } from 'ngx-bootstrap'; @@ -20,9 +20,9 @@ const ENTRY_COMPONENTS = [ PersonComponent, ProjectComponent, OrgUnitListElementComponent, - OrgUnitMetadataListElementComponent, + OrgunitItemPageListElementComponent, PersonListElementComponent, - PersonMetadataListElementComponent, + PersonItemPageListElementComponent, ProjectListElementComponent, PersonGridElementComponent, OrgunitGridElementComponent, diff --git a/src/app/shared/items/item-type-decorator.ts b/src/app/shared/items/item-type-decorator.ts deleted file mode 100644 index e6c7c18150..0000000000 --- a/src/app/shared/items/item-type-decorator.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { hasNoValue, hasValue } from '../empty.util'; -import { ViewMode } from '../../core/shared/view-mode.model'; - -export const DEFAULT_ITEM_TYPE = 'Default'; -export const DEFAULT_VIEW_MODE = ViewMode.ListElement; - - -const map = new Map(); - -/** - * Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) - * @param type - * @param viewMode - */ -export function rendersItemType(type: string, viewMode: string) { - return function decorator(component: any) { - if (hasNoValue(map.get(viewMode))) { - map.set(viewMode, new Map()); - } - if (hasValue(map.get(viewMode).get(type))) { - throw new Error(`There can't be more than one component to render Metadata of type "${type}" in view mode "${viewMode}"`); - } - map.get(viewMode).set(type, component); - }; -} - -/** - * Get the component used for rendering an item by type and viewMode (and optionally a representationType) - * @param type - * @param viewMode - */ -export function getComponentByItemType(type: string, viewMode: string) { - if (hasNoValue(map.get(viewMode))) { - viewMode = DEFAULT_VIEW_MODE; - } - if (hasNoValue(map.get(viewMode).get(type))) { - type = DEFAULT_ITEM_TYPE; - } - return map.get(viewMode).get(type); -} diff --git a/src/app/shared/items/switcher/item-type-switcher.component.html b/src/app/shared/items/switcher/item-type-switcher.component.html deleted file mode 100644 index f2ea5784fc..0000000000 --- a/src/app/shared/items/switcher/item-type-switcher.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/items/switcher/item-type-switcher.component.scss b/src/app/shared/items/switcher/item-type-switcher.component.scss deleted file mode 100644 index 45a533cd01..0000000000 --- a/src/app/shared/items/switcher/item-type-switcher.component.scss +++ /dev/null @@ -1 +0,0 @@ -@import '../../../../styles/variables'; diff --git a/src/app/shared/items/switcher/item-type-switcher.component.ts b/src/app/shared/items/switcher/item-type-switcher.component.ts deleted file mode 100644 index 0f31b10c7a..0000000000 --- a/src/app/shared/items/switcher/item-type-switcher.component.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Component, InjectionToken, Injector, Input, OnInit } from '@angular/core'; -import { SearchResult } from '../../../+search-page/search-result.model'; -import { Item } from '../../../core/shared/item.model'; -import { hasValue } from '../../empty.util'; -import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model'; -import { getComponentByItemType } from '../item-type-decorator'; -import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; - -export const ITEM: InjectionToken = new InjectionToken('item'); - -@Component({ - selector: 'ds-item-type-switcher', - styleUrls: ['./item-type-switcher.component.scss'], - templateUrl: './item-type-switcher.component.html' -}) -/** - * Component for determining what component to use depending on the item's relationship type (relationship.type) - */ -export class ItemTypeSwitcherComponent implements OnInit { - /** - * The item or metadata to determine the component for - */ - @Input() object: Item | SearchResult; - - /** - * The preferred view-mode to display - */ - @Input() viewMode: string; - - /** - * The object injector used to inject the item into the child component - */ - objectInjector: Injector; - - component: any; - - constructor(private injector: Injector) { - } - - ngOnInit(): void { - this.objectInjector = Injector.create({ - providers: [{ provide: ITEM, useFactory: () => this.object, deps:[] }], - parent: this.injector - }); - this.component = this.getComponent(); - } - - /** - * Fetch the component depending on the item's relationship type - * @returns {string} - */ - private getComponent(): string { - let item: Item; - if (hasValue((this.object as any).indexableObject)) { - const searchResult = this.object as ItemSearchResult; - item = searchResult.indexableObject; - } else { - item = this.object as Item; - } - - const type = item.firstMetadataValue('relationship.type'); - return getComponentByItemType(type, this.viewMode); - } -} diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.html b/src/app/shared/metadata-representation/metadata-representation-loader.component.html new file mode 100644 index 0000000000..3979c238ad --- /dev/null +++ b/src/app/shared/metadata-representation/metadata-representation-loader.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts index e69de29bb2..ba3f6ed00b 100644 --- a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts +++ b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts @@ -0,0 +1,45 @@ +import { Component, ComponentFactoryResolver, InjectionToken, Injector, Input, OnInit, ViewChild } from '@angular/core'; +import { MetadataRepresentation } from '../../core/shared/metadata-representation/metadata-representation.model'; +import { getMetadataRepresentationComponent } from './metadata-representation.decorator'; +import { Context } from '../../core/shared/context.model'; +import { GenericConstructor } from '../../core/shared/generic-constructor'; +import { MetadataRepresentationListElementComponent } from '../object-list/metadata-representation-list-element/metadata-representation-list-element.component'; +import { MetadataRepresentationDirective } from './metadata-representation.directive'; + +@Component({ + selector: 'ds-metadata-representation-loader', + // styleUrls: ['./metadata-representation-loader.component.scss'], + templateUrl: './metadata-representation-loader.component.html' +}) +/** + * Component for determining what component to use depending on the item's relationship type (relationship.type) + */ +export class MetadataRepresentationLoaderComponent implements OnInit { + /** + * The item or metadata to determine the component for + */ + @Input() mdRepresentation: MetadataRepresentation; + @Input() context: Context; + @ViewChild(MetadataRepresentationDirective) mdRepDirective: MetadataRepresentationDirective; + + constructor(private componentFactoryResolver: ComponentFactoryResolver) { + } + + ngOnInit(): void { + const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); + + const viewContainerRef = this.mdRepDirective.viewContainerRef; + viewContainerRef.clear(); + + const componentRef = viewContainerRef.createComponent(componentFactory); + (componentRef.instance).metadataRepresentation = this.mdRepresentation; + } + + /** + * Fetch the component depending on the item's relationship type + * @returns {string} + */ + private getComponent(): GenericConstructor { + return getMetadataRepresentationComponent(this.mdRepresentation.itemType, this.mdRepresentation.representationType, this.context); + } +} diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.ts index 0eee4f6d2f..42495fec81 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.ts @@ -1,7 +1,7 @@ import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; import { hasNoValue, hasValue } from '../empty.util'; import { Context } from '../../core/shared/context.model'; -import { DEFAULT_ITEM_TYPE } from '../items/item-type-decorator'; +import { DEFAULT_ITEM_TYPE } from '../object-collection/shared/listable-object/listable-object.decorator'; const map = new Map(); @@ -26,19 +26,18 @@ export function metadataRepresentationComponent(entityType: string, mdRepresenta } export function getMetadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { - if (hasNoValue(entityType) || hasNoValue(map.get(entityType))) { - entityType = DEFAULT_ITEM_TYPE; + const mapForEntity = map.get(entityType); + if (hasValue(mapForEntity)) { + const entityAndMDRepMap = mapForEntity.get(mdRepresentationType); + if (hasValue(entityAndMDRepMap)) { + if (hasValue(entityAndMDRepMap.get(context))) { + return entityAndMDRepMap.get(context); + } + if (hasValue(entityAndMDRepMap.get(DEFAULT_CONTEXT))) { + return entityAndMDRepMap.get(DEFAULT_CONTEXT); + } + } + return mapForEntity.get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); } - - if (hasNoValue(map.get(entityType).get(mdRepresentationType))) { - mdRepresentationType = DEFAULT_REPRESENTATION_TYPE; - } - - let representationComponent = map.get(entityType).get(mdRepresentationType).get(context); - - if (hasNoValue(representationComponent)) { - representationComponent = map.get(entityType).get(mdRepresentationType).get(DEFAULT_REPRESENTATION_TYPE); - } - - return representationComponent; + return map.get(DEFAULT_ITEM_TYPE).get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); } \ No newline at end of file diff --git a/src/app/shared/metadata-representation/metadata-representation.directive.ts b/src/app/shared/metadata-representation/metadata-representation.directive.ts new file mode 100644 index 0000000000..c57d1ef4ac --- /dev/null +++ b/src/app/shared/metadata-representation/metadata-representation.directive.ts @@ -0,0 +1,8 @@ +import { Directive, ViewContainerRef } from '@angular/core'; + +@Directive({ + selector: '[dsMetadataRepresentation]', +}) +export class MetadataRepresentationDirective { + constructor(public viewContainerRef: ViewContainerRef) { } +} \ No newline at end of file diff --git a/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts b/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts deleted file mode 100644 index 836ddf727d..0000000000 --- a/src/app/shared/object-collection/shared/dso-element-decorator.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { renderElementsFor } from './dso-element-decorator'; -import { Item } from '../../../core/shared/item.model'; -import { ViewMode } from '../../../core/shared/view-mode.model'; - -describe('ElementDecorator', () => { - const gridDecorator = renderElementsFor(Item, ViewMode.GridElement); - const listDecorator = renderElementsFor(Item, ViewMode.ListElement); - it('should have a decorator for both list and grid', () => { - expect(listDecorator.length).not.toBeNull(); - expect(gridDecorator.length).not.toBeNull(); - }); - it('should have 2 separate decorators for grid and list', () => { - expect(listDecorator).not.toEqual(gridDecorator); - }); - -}); diff --git a/src/app/shared/object-collection/shared/dso-element-decorator.ts b/src/app/shared/object-collection/shared/dso-element-decorator.ts deleted file mode 100644 index 98650fd25b..0000000000 --- a/src/app/shared/object-collection/shared/dso-element-decorator.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { GenericConstructor } from '../../../core/shared/generic-constructor'; -import { ListableObject } from './listable-object.model'; -import { ViewMode } from '../../../core/shared/view-mode.model'; - -const dsoElementMap = new Map(); -export function renderElementsFor(listable: GenericConstructor, viewMode: ViewMode) { - return function decorator(objectElement: any) { - if (!objectElement) { - return; - } - if (!dsoElementMap.get(viewMode)) { - dsoElementMap.set(viewMode, new Map()); - } - dsoElementMap.get(viewMode).set(listable, objectElement); - }; -} - -export function rendersDSOType(listable: GenericConstructor, viewMode: ViewMode) { - return dsoElementMap.get(viewMode).get(listable); -} diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html new file mode 100644 index 0000000000..d41303d462 --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html @@ -0,0 +1 @@ + diff --git a/src/app/shared/items/switcher/item-type-switcher.component.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts similarity index 88% rename from src/app/shared/items/switcher/item-type-switcher.component.spec.ts rename to src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts index c564c72564..d10ee1a0dd 100644 --- a/src/app/shared/items/switcher/item-type-switcher.component.spec.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts @@ -1,4 +1,4 @@ -import { ItemTypeSwitcherComponent } from './item-type-switcher.component'; +import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { PageInfo } from '../../../core/shared/page-info.model'; @@ -33,18 +33,18 @@ const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentat let viewMode = ViewMode.StandalonePage; describe('ItemTypeSwitcherComponent', () => { - let comp: ItemTypeSwitcherComponent; - let fixture: ComponentFixture; + let comp: ListableObjectComponentLoaderComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ItemTypeSwitcherComponent ], + declarations: [ ListableObjectComponentLoaderComponent ], schemas: [ NO_ERRORS_SCHEMA ] }).compileComponents(); // compile template and css })); beforeEach(async(() => { - fixture = TestBed.createComponent(ItemTypeSwitcherComponent); + fixture = TestBed.createComponent(ListableObjectComponentLoaderComponent); comp = fixture.componentInstance; comp.object = mockItem; comp.viewMode = viewMode; diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts new file mode 100644 index 0000000000..17c860e04b --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -0,0 +1,43 @@ +import { Component, InjectionToken, Injector, Input, OnInit } from '@angular/core'; +import { ListableObject } from '../listable-object.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { Context } from '../../../../core/shared/context.model'; +import { hasValue } from '../../../empty.util'; +import { getListableObjectComponent } from './listable-object.decorator'; + +@Component({ + selector: 'ds-listable-object-component-loader', + styleUrls: ['./listable-object-component-loader.component.scss'], + templateUrl: './listable-object-component-loader.component.html' +}) +/** + * Component for determining what component to use depending on the item's relationship type (relationship.type) + */ +export class ListableObjectComponentLoaderComponent implements OnInit { + /** + * The item or metadata to determine the component for + */ + @Input() object: ListableObject; + + /** + * The preferred view-mode to display + */ + @Input() viewMode: ViewMode; + + @Input() context: Context; + + constructor(private injector: Injector) { + } + + ngOnInit(): void { + + } + + /** + * Fetch the component depending on the item's relationship type + * @returns {string} + */ + private getComponent(): string { + return getListableObjectComponent(this.object, this.viewMode); + } +} diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts new file mode 100644 index 0000000000..c628378c6f --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts @@ -0,0 +1,16 @@ +import { Item } from '../../../../core/shared/item.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from './listable-object.decorator'; + +describe('ElementDecorator', () => { + const gridDecorator = listableObjectComponent(Item, ViewMode.GridElement); + const listDecorator = listableObjectComponent(Item, ViewMode.ListElement); + it('should have a decorator for both list and grid', () => { + expect(listDecorator.length).not.toBeNull(); + expect(gridDecorator.length).not.toBeNull(); + }); + it('should have 2 separate decorators for grid and list', () => { + expect(listDecorator).not.toEqual(gridDecorator); + }); + +}); diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts new file mode 100644 index 0000000000..2e30c0b761 --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts @@ -0,0 +1,50 @@ +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { GenericConstructor } from '../../../../core/shared/generic-constructor'; +import { ListableObject } from '../listable-object.model'; +import { Context } from '../../../../core/shared/context.model'; +import { hasNoValue, hasValue } from '../../../empty.util'; +import { DEFAULT_CONTEXT } from '../../../metadata-representation/metadata-representation.decorator'; + +export const DEFAULT_ITEM_TYPE = 'Default'; +export const DEFAULT_VIEW_MODE = ViewMode.ListElement; + + +const listElementMap = new Map(); + +/** + * Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) + * @param type + * @param viewMode + */ +export function listableObjectComponent(objectType: GenericConstructor | string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { + return function decorator(component: any) { + if (hasNoValue(objectType)) { + return; + } + if (hasNoValue(listElementMap.get(objectType))) { + listElementMap.set(objectType, new Map()); + } + if (hasNoValue(listElementMap.get(objectType).get(viewMode))) { + listElementMap.get(objectType).set(viewMode, new Map()); + } + listElementMap.get(objectType).get(viewMode).set(context, component); + }; +} + + +export function getListableObjectComponent(entityType: GenericConstructor | string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { + const mapForType = listElementMap.get(entityType); + if (hasValue(mapForType)) { + const typeAndMDRepMap = mapForType.get(viewMode); + if (hasValue(typeAndMDRepMap)) { + if (hasValue(typeAndMDRepMap.get(context))) { + return typeAndMDRepMap.get(context); + } + if (hasValue(typeAndMDRepMap.get(DEFAULT_CONTEXT))) { + return typeAndMDRepMap.get(DEFAULT_CONTEXT); + } + } + return mapForType.get(DEFAULT_VIEW_MODE).get(DEFAULT_CONTEXT); + } + return listElementMap.get(DEFAULT_ITEM_TYPE).get(DEFAULT_VIEW_MODE).get(DEFAULT_CONTEXT); +} \ No newline at end of file diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts new file mode 100644 index 0000000000..3b0decd7bd --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts @@ -0,0 +1,8 @@ +import { Directive, ViewContainerRef } from '@angular/core'; + +@Directive({ + selector: '[dsListableObject]', +}) +export class ListableObjectDirective { + constructor(public viewContainerRef: ViewContainerRef) { } +} \ No newline at end of file diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts index 83222e8e20..4e947a496f 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts @@ -3,7 +3,6 @@ import { Component, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { RemoteData } from '../../../../core/data/remote-data'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { isNotUndefined } from '../../../empty.util'; @@ -13,6 +12,7 @@ import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.m import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders claimed task object for the mydspace result in the detail view. @@ -23,8 +23,8 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa templateUrl: './claimed-my-dspace-result-detail-element.component.html' }) -@renderElementsFor(ClaimedTaskMyDSpaceResult, ViewMode.DetailedListElement) -@renderElementsFor(ClaimedTask, ViewMode.DetailedListElement) +@listableObjectComponent(ClaimedTaskMyDSpaceResult, ViewMode.DetailedListElement) +@listableObjectComponent(ClaimedTask, ViewMode.DetailedListElement) export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts index 51bc44a6ac..2b50dd0819 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Item } from '../../../../core/shared/item.model'; import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders item object for the mydspace result in the detail view. @@ -16,7 +16,7 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa templateUrl: './item-my-dspace-result-detail-element.component.html' }) -@renderElementsFor(ItemMyDSpaceResult, ViewMode.DetailedListElement) +@listableObjectComponent(ItemMyDSpaceResult, ViewMode.DetailedListElement) export class ItemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts index 7dffac9630..16e96cf412 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts @@ -2,7 +2,6 @@ import { Component, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; import { ListableObject } from '../../../object-collection/shared/listable-object.model'; @@ -12,6 +11,7 @@ import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders pool task object for the mydspace result in the detail view. @@ -22,8 +22,8 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: './pool-my-dspace-result-detail-element.component.html', }) -@renderElementsFor(PoolTaskMyDSpaceResult, ViewMode.DetailedListElement) -@renderElementsFor(PoolTask, ViewMode.DetailedListElement) +@listableObjectComponent(PoolTaskMyDSpaceResult, ViewMode.DetailedListElement) +@listableObjectComponent(PoolTask, ViewMode.DetailedListElement) export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts index 10890d9635..a8c2e5555f 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts @@ -1,6 +1,5 @@ import { Component, Inject } from '@angular/core'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Item } from '../../../../core/shared/item.model'; import { ListableObject } from '../../../object-collection/shared/listable-object.model'; @@ -12,6 +11,7 @@ import { Observable } from 'rxjs/internal/Observable'; import { RemoteData } from '../../../../core/data/remote-data'; import { find } from 'rxjs/operators'; import { isNotUndefined } from '../../../empty.util'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders workflowitem object for the mydspace result in the detail view. @@ -22,8 +22,8 @@ import { isNotUndefined } from '../../../empty.util'; templateUrl: './workflowitem-my-dspace-result-detail-element.component.html', }) -@renderElementsFor(WorkflowitemMyDSpaceResult, ViewMode.DetailedListElement) -@renderElementsFor(WorkflowItem, ViewMode.DetailedListElement) +@listableObjectComponent(WorkflowitemMyDSpaceResult, ViewMode.DetailedListElement) +@listableObjectComponent(WorkflowItem, ViewMode.DetailedListElement) export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts index 72b68e4e92..0415715c44 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts @@ -3,7 +3,6 @@ import { Component, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; @@ -15,6 +14,7 @@ import { ListableObject } from '../../../object-collection/shared/listable-objec import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders workspaceitem object for the mydspace result in the detail view. @@ -25,8 +25,8 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: './workspaceitem-my-dspace-result-detail-element.component.html', }) -@renderElementsFor(WorkspaceitemMyDSpaceResult, ViewMode.DetailedListElement) -@renderElementsFor(WorkspaceItem, ViewMode.DetailedListElement) +@listableObjectComponent(WorkspaceitemMyDSpaceResult, ViewMode.DetailedListElement) +@listableObjectComponent(WorkspaceItem, ViewMode.DetailedListElement) export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.html b/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.html deleted file mode 100644 index ef7254b97c..0000000000 --- a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.scss b/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.scss deleted file mode 100644 index 51a7fc6a55..0000000000 --- a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import '../../../../styles/variables'; - diff --git a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.spec.ts b/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.spec.ts deleted file mode 100644 index e54ae58398..0000000000 --- a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { ActivatedRoute, Router } from '@angular/router'; - -import { of as observableOf } from 'rxjs'; - -import { RouterStub } from '../../testing/router-stub'; -import { WrapperDetailElementComponent } from './wrapper-detail-element.component'; - -let wrapperDetailElementComponent: WrapperDetailElementComponent; -let fixture: ComponentFixture; -const queryParam = 'test query'; -const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f'; -const activatedRouteStub = { - queryParams: observableOf({ - query: queryParam, - scope: scopeParam - }) -}; - -describe('WrapperDetailElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ WrapperDetailElementComponent ], - providers: [ - { provide: ActivatedRoute, useValue: activatedRouteStub }, - { provide: Router, useClass: RouterStub }, - { provide: 'objectElementProvider', useFactory: (WrapperDetailElementComponent)} - ], - - schemas: [ NO_ERRORS_SCHEMA ] - }).compileComponents(); // compile template and css - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(WrapperDetailElementComponent); - wrapperDetailElementComponent = fixture.componentInstance; - })); - - it('should show the wrapper element containing the detail object',() => { - expect(fixture.debugElement.query(By.css('ds-workspaceitem-my-dspace-result-detail-element'))).toBeDefined(); - }) -}); diff --git a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts b/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts deleted file mode 100644 index 5b48d4069f..0000000000 --- a/src/app/shared/object-detail/wrapper-detail-element/wrapper-detail-element.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Component, Injector, Input, OnInit } from '@angular/core'; - -import { ViewMode } from '../../../core/shared/view-mode.model'; -import { GenericConstructor } from '../../../core/shared/generic-constructor'; -import { rendersDSOType } from '../../object-collection/shared/dso-element-decorator'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; - -/** - * This component renders a wrapper for an object in the detail view. - */ -@Component({ - selector: 'ds-wrapper-detail-element', - styleUrls: ['./wrapper-detail-element.component.scss'], - templateUrl: './wrapper-detail-element.component.html' -}) -export class WrapperDetailElementComponent implements OnInit { - - /** - * The listable object. - */ - @Input() object: ListableObject; - - /** - * The instance of the injector. - */ - objectInjector: Injector; - - detailElement: any; - - /** - * Initialize instance variables - * - * @param {Injector} injector - */ - constructor(private injector: Injector) { - } - - /** - * Initialize injector - */ - ngOnInit(): void { - this.objectInjector = Injector.create({ - providers: [{ provide: 'objectElementProvider', useFactory: () => (this.object), deps:[] }], - parent: this.injector - }); - this.detailElement = this.getDetailElement(); - } - - /** - * Return class name for the object to inject - */ - private getDetailElement(): string { - const f: GenericConstructor = this.object.constructor as GenericConstructor; - return rendersDSOType(f, ViewMode.DetailedListElement); - } -} diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts index c142e4d13e..1261cd6dfd 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts @@ -1,9 +1,9 @@ import { Component, Inject } from '@angular/core'; import { Collection } from '../../../core/shared/collection.model'; -import { renderElementsFor} from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-collection-grid-element', @@ -11,5 +11,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; templateUrl: './collection-grid-element.component.html' }) -@renderElementsFor(Collection, ViewMode.GridElement) +@listableObjectComponent(Collection, ViewMode.GridElement) export class CollectionGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts index 773b862784..67d4ac663c 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts @@ -2,8 +2,8 @@ import { Component } from '@angular/core'; import { Community } from '../../../core/shared/community.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-community-grid-element', @@ -11,5 +11,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; templateUrl: './community-grid-element.component.html' }) -@renderElementsFor(Community, ViewMode.GridElement) +@listableObjectComponent(Community, ViewMode.GridElement) export class CommunityGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts index 3e083fb973..e146370752 100644 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts @@ -1,9 +1,9 @@ -import { Component, Input, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import { renderElementsFor} from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-item-grid-element', @@ -11,5 +11,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; templateUrl: './item-grid-element.component.html' }) -@renderElementsFor(Item, ViewMode.GridElement) +@listableObjectComponent(Item, ViewMode.GridElement) export class ItemGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts index e0ba26fcfc..3d0b80932d 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts @@ -8,7 +8,7 @@ import { PublicationGridElementComponent } from './publication-grid-element.comp import { of as observableOf } from 'rxjs/internal/observable/of'; import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { ITEM } from '../../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts index 63f5148aec..f99810ea69 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts @@ -1,11 +1,11 @@ import { TypedItemSearchResultGridElementComponent } from '../typed-item-search-result-grid-element.component'; -import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../items/item-type-decorator'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../animations/focus'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Publication', ViewMode.GridElement) -@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.GridElement) +@listableObjectComponent('Publication', ViewMode.GridElement) +@listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.GridElement) @Component({ selector: 'ds-publication-grid-element', styleUrls: ['./publication-grid-element.component.scss'], diff --git a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts index e4ace8d0b2..8035ec623f 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts @@ -6,7 +6,7 @@ import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; import { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts index f4f470c052..3e19b34c04 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts @@ -3,7 +3,7 @@ import { Item } from '../../../../core/shared/item.model'; import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component'; import { TruncatableService } from '../../../truncatable/truncatable.service'; import { Component, Inject } from '@angular/core'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; import { hasValue } from '../../../empty.util'; import { MetadataMap } from '../../../../core/shared/metadata.models'; diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts index e61e5375b3..1d0f47b70b 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; -import { renderElementsFor} from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; import { Collection } from '../../../../core/shared/collection.model'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-collection-search-result-grid-element', @@ -12,5 +12,5 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: 'collection-search-result-grid-element.component.html' }) -@renderElementsFor(CollectionSearchResult, ViewMode.GridElement) +@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement) export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent {} diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts index 66c7b11983..806e6a44e3 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { Community } from '../../../../core/shared/community.model'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-community-search-result-grid-element', @@ -11,7 +11,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: 'community-search-result-grid-element.component.html' }) -@renderElementsFor(CommunitySearchResult, ViewMode.GridElement) +@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement) export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts index cb10d0b2db..f90a9f6799 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; import { Item } from '../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { focusShadow } from '../../../animations/focus'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-item-search-result-grid-element', @@ -14,7 +14,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; animations: [focusShadow], }) -@renderElementsFor(ItemSearchResult, ViewMode.GridElement) +@listableObjectComponent(ItemSearchResult, ViewMode.GridElement) export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent { viewMode = ViewMode.GridElement; -} +} \ No newline at end of file diff --git a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.html b/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.html deleted file mode 100644 index d6fd1cf9aa..0000000000 --- a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.scss b/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.scss deleted file mode 100644 index 8b13789179..0000000000 --- a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.scss +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.spec.ts b/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.spec.ts deleted file mode 100644 index 0a78c97209..0000000000 --- a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { WrapperGridElementComponent } from './wrapper-grid-element.component'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { of as observableOf } from 'rxjs'; -import { ActivatedRoute, Router } from '@angular/router'; -import { RouterStub } from '../../testing/router-stub'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { By } from '@angular/platform-browser'; - -let wrapperGridElementComponent: WrapperGridElementComponent; -let fixture: ComponentFixture; -const queryParam = 'test query'; -const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f'; -const activatedRouteStub = { - queryParams: observableOf({ - query: queryParam, - scope: scopeParam - }) -}; - -describe('WrapperGridElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ WrapperGridElementComponent ], - providers: [ - { provide: ActivatedRoute, useValue: activatedRouteStub }, - { provide: Router, useClass: RouterStub }, - { provide: 'objectElementProvider', useFactory: (wrapperGridElementComponent)} - ], - - schemas: [ NO_ERRORS_SCHEMA ] - }).compileComponents(); // compile template and css - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(WrapperGridElementComponent); - wrapperGridElementComponent = fixture.componentInstance; - - })); - - it('should show the wrapper element containing the cards',() => { - expect(fixture.debugElement.query(By.css('ds-collection-grid-element'))).toBeDefined(); - }) -}) diff --git a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts b/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts deleted file mode 100644 index 2bd1e8bfc8..0000000000 --- a/src/app/shared/object-grid/wrapper-grid-element/wrapper-grid-element.component.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Component, Injector, Input, OnInit } from '@angular/core'; -import { GenericConstructor } from '../../../core/shared/generic-constructor'; -import { rendersDSOType } from '../../object-collection/shared/dso-element-decorator'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; -import { ViewMode } from '../../../core/shared/view-mode.model'; - -@Component({ - selector: 'ds-wrapper-grid-element', - styleUrls: ['./wrapper-grid-element.component.scss'], - templateUrl: './wrapper-grid-element.component.html' -}) -export class WrapperGridElementComponent implements OnInit { - @Input() object: ListableObject; - objectInjector: Injector; - gridElement: any; - - constructor(private injector: Injector) { - } - - ngOnInit(): void { - this.objectInjector = Injector.create({ - providers: [{ provide: 'objectElementProvider', useFactory: () => (this.object), deps:[] }], - parent: this.injector - }); - this.gridElement = this.getGridElement(); - } - - getGridElement(): string { - const f: GenericConstructor = this.object.constructor as GenericConstructor; - return rendersDSOType(f, ViewMode.GridElement); - } -} diff --git a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts index 8732637228..2ebfc2713e 100644 --- a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts +++ b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts @@ -1,9 +1,9 @@ import { Component, Input, Inject } from '@angular/core'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { BrowseEntry } from '../../../core/shared/browse-entry.model'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-browse-entry-list-element', @@ -14,5 +14,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; /** * This component is automatically used to create a list view for BrowseEntry objects when used in ObjectCollectionComponent */ -@renderElementsFor(BrowseEntry, ViewMode.ListElement) +@listableObjectComponent(BrowseEntry, ViewMode.ListElement) export class BrowseEntryListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts index d4d46fdd69..685a990409 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts @@ -1,9 +1,9 @@ import { Component, Inject } from '@angular/core'; import { Collection } from '../../../core/shared/collection.model'; -import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-collection-list-element', @@ -11,5 +11,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; templateUrl: './collection-list-element.component.html' }) -@renderElementsFor(Collection, ViewMode.ListElement) +@listableObjectComponent(Collection, ViewMode.ListElement) export class CollectionListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/community-list-element/community-list-element.component.ts b/src/app/shared/object-list/community-list-element/community-list-element.component.ts index c23d35b961..4581c2c0da 100644 --- a/src/app/shared/object-list/community-list-element/community-list-element.component.ts +++ b/src/app/shared/object-list/community-list-element/community-list-element.component.ts @@ -2,8 +2,8 @@ import { Component, Input, Inject } from '@angular/core'; import { Community } from '../../../core/shared/community.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-community-list-element', @@ -11,5 +11,5 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; templateUrl: './community-list-element.component.html' }) -@renderElementsFor(Community, ViewMode.ListElement) +@listableObjectComponent(Community, ViewMode.ListElement) export class CommunityListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.ts index 3428c3f68d..e41a92f36d 100644 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-item-list-element', @@ -15,7 +15,7 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; * The component used to list items depending on type * Uses item-type-switcher to determine which components to use for displaying the list */ -@renderElementsFor(Item, ViewMode.ListElement) +@listableObjectComponent(Item, ViewMode.ListElement) export class ItemListElementComponent extends AbstractListableElementComponent { viewMode = ViewMode.ListElement; } diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts index 732fd0d4e4..fe46669cfe 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts @@ -5,7 +5,7 @@ import { PublicationListElementComponent } from './publication-list-element.comp import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; -import { ITEM } from '../../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; import { of as observableOf } from 'rxjs'; let publicationListElementComponent: PublicationListElementComponent; diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 46de8ac6cc..52d2f569b3 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; -import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../items/item-type-decorator'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType('Publication', ViewMode.ListElement) -@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.ListElement) +@listableObjectComponent('Publication', ViewMode.ListElement) +@listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.ListElement) @Component({ selector: 'ds-publication-list-element', styleUrls: ['./publication-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts index 082347be0b..c114a941cf 100644 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts @@ -7,7 +7,7 @@ import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; import { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts index dd1b5a7e5f..cf7dc0b330 100644 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts @@ -1,7 +1,7 @@ import { Component, Inject } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; import { hasValue } from '../../../empty.util'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { TruncatableService } from '../../../truncatable/truncatable.service'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts index 5ffa068951..2aa54bae64 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts @@ -1,5 +1,5 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ItemMetadataListElementComponent } from './item-metadata-list-element.component'; import { By } from '@angular/platform-browser'; diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts index cf2786a2e6..25e97d59f6 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts @@ -1,10 +1,11 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; -import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../items/item-type-decorator'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { metadataRepresentationComponent } from '../../../metadata-representation/metadata-representation.decorator'; +import { DEFAULT_ITEM_TYPE } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.MetadataField, MetadataRepresentationType.Item) +@metadataRepresentationComponent(DEFAULT_ITEM_TYPE, MetadataRepresentationType.Item) @Component({ selector: 'ds-item-metadata-list-element', templateUrl: './item-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts index 2488db50b1..427726149f 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts @@ -1,6 +1,6 @@ import { Component, Inject } from '@angular/core'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; -import { ITEM } from '../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../items/switcher/listable-object-component-loader.component'; @Component({ selector: 'ds-metadata-representation-list-element', @@ -10,6 +10,8 @@ import { ITEM } from '../../items/switcher/item-type-switcher.component'; * An abstract class for displaying a single MetadataRepresentation */ export class MetadataRepresentationListElementComponent { - constructor(@Inject(ITEM) public metadataRepresentation: MetadataRepresentation) { + metadataRepresentation: MetadataRepresentation; + + constructor() { } } diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts index 42b9abde16..ba6d06ad84 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { PlainTextMetadataListElementComponent } from './plain-text-metadata-list-element.component'; import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; const mockMetadataRepresentation = Object.assign(new MetadatumRepresentation('type'), { key: 'dc.contributor.author', diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts index 0ebccc79f8..20d7c9739e 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts @@ -1,12 +1,12 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; -import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../items/item-type-decorator'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { metadataRepresentationComponent } from '../../../metadata-representation/metadata-representation.decorator'; +import { DEFAULT_ITEM_TYPE } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.MetadataField, MetadataRepresentationType.PlainText) +@metadataRepresentationComponent(DEFAULT_ITEM_TYPE, MetadataRepresentationType.PlainText) // For now, authority controlled fields are rendered the same way as plain text fields -@rendersItemType(DEFAULT_ITEM_TYPE, ViewMode.MetadataField, MetadataRepresentationType.AuthorityControlled) +@metadataRepresentationComponent(DEFAULT_ITEM_TYPE, MetadataRepresentationType.AuthorityControlled) @Component({ selector: 'ds-plain-text-metadata-list-element', templateUrl: './plain-text-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts index 66cdbfb43c..68eb27c93a 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts @@ -4,7 +4,6 @@ import { Location, LocationStrategy, PathLocationStrategy } from '@angular/commo import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; @@ -13,6 +12,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders claimed task object for the mydspace result in the list view. @@ -24,8 +24,8 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) -@renderElementsFor(ClaimedTaskMyDSpaceResult, ViewMode.ListElement) -@renderElementsFor(ClaimedTask, ViewMode.ListElement) +@listableObjectComponent(ClaimedTaskMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent(ClaimedTask, ViewMode.ListElement) export class ClaimedMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts index a9ceac5da3..8d3fd00eaa 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { Item } from '../../../../core/shared/item.model'; import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders item object for the mydspace result in the list view. @@ -16,7 +16,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: './item-my-dspace-result-list-element.component.html' }) -@renderElementsFor(ItemMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent(ItemMyDSpaceResult, ViewMode.ListElement) export class ItemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts index 62cbdde1c0..d3876714dc 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts @@ -3,7 +3,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; @@ -13,6 +12,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders pool task object for the mydspace result in the list view. @@ -23,8 +23,8 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa templateUrl: './pool-my-dspace-result-list-element.component.html', }) -@renderElementsFor(PoolTaskMyDSpaceResult, ViewMode.ListElement) -@renderElementsFor(PoolTask, ViewMode.ListElement) +@listableObjectComponent(PoolTaskMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent(PoolTask, ViewMode.ListElement) export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent implements OnInit { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts index e03367abce..5ec7572984 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts @@ -3,7 +3,6 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; @@ -12,6 +11,7 @@ import { WorkflowitemMyDSpaceResult } from '../../../object-collection/shared/wo import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders workflowitem object for the mydspace result in the list view. @@ -22,8 +22,8 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa templateUrl: './workflowitem-my-dspace-result-list-element.component.html', }) -@renderElementsFor(WorkflowitemMyDSpaceResult, ViewMode.ListElement) -@renderElementsFor(WorkflowItem, ViewMode.ListElement) +@listableObjectComponent(WorkflowitemMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent(WorkflowItem, ViewMode.ListElement) export class WorkflowitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts index ea5f9d6f6b..e88ea54703 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts @@ -3,7 +3,6 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; @@ -12,6 +11,7 @@ import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; /** * This component renders workspaceitem object for the mydspace result in the list view. @@ -22,7 +22,7 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa templateUrl: './workspaceitem-my-dspace-result-list-element.component.html', }) -@renderElementsFor(WorkspaceitemMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent(WorkspaceitemMyDSpaceResult, ViewMode.ListElement) export class WorkspaceitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts index 657252c1bd..384e1c1f81 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Collection } from '../../../../core/shared/collection.model'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-collection-search-result-list-element', @@ -13,5 +13,5 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: 'collection-search-result-list-element.component.html' }) -@renderElementsFor(CollectionSearchResult, ViewMode.ListElement) +@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement) export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent {} diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts index c57e716a2f..3281e380e4 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Community } from '../../../../core/shared/community.model'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-community-search-result-list-element', @@ -13,7 +13,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; templateUrl: 'community-search-result-list-element.component.html' }) -@renderElementsFor(CommunitySearchResult, ViewMode.ListElement) +@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement) export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts index 6acedefdbd..0b25443454 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts @@ -2,10 +2,10 @@ import { Component } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; import { focusBackground } from '../../../animations/focus'; -import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; @Component({ selector: 'ds-item-search-result-list-element', @@ -15,7 +15,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; }) -@renderElementsFor(ItemSearchResult, ViewMode.ListElement) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement) export class ItemSearchResultListElementComponent extends SearchResultListElementComponent { viewMode = ViewMode.ListElement; diff --git a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.html b/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.html deleted file mode 100644 index db87596f31..0000000000 --- a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.scss b/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.scss deleted file mode 100644 index 8b13789179..0000000000 --- a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.scss +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts b/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts deleted file mode 100644 index 8663d37d35..0000000000 --- a/src/app/shared/object-list/wrapper-list-element/wrapper-list-element.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Component, Injector, Input, OnInit } from '@angular/core'; -import { GenericConstructor } from '../../../core/shared/generic-constructor'; -import { rendersDSOType } from '../../object-collection/shared/dso-element-decorator' -import { ListableObject } from '../../object-collection/shared/listable-object.model'; -import { ViewMode } from '../../../core/shared/view-mode.model'; - -@Component({ - selector: 'ds-wrapper-list-element', - styleUrls: ['./wrapper-list-element.component.scss'], - templateUrl: './wrapper-list-element.component.html' -}) -export class WrapperListElementComponent implements OnInit { - @Input() object: ListableObject; - @Input() index: number; - objectInjector: Injector; - listElement: any; - - constructor(private injector: Injector) {} - - ngOnInit(): void { - this.objectInjector = Injector.create({ - providers: [ - { provide: 'objectElementProvider', useFactory: () => (this.object), deps:[] }, - { provide: 'indexElementProvider', useFactory: () => (this.index), deps:[] } - ], - parent: this.injector - }); - this.listElement = this.getListElement(); - } - - private getListElement(): string { - const f: GenericConstructor = this.object.constructor as GenericConstructor; - return rendersDSOType(f, ViewMode.ListElement); - } -} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 2367652dd3..d50056d731 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -9,7 +9,7 @@ import { NgbDatepickerModule, NgbModule, NgbTimepickerModule, NgbTypeaheadModule import { TranslateModule } from '@ngx-translate/core'; import { NgxPaginationModule } from 'ngx-pagination'; -import { ItemTypeSwitcherComponent } from './items/switcher/item-type-switcher.component'; +import { ListableObjectComponentLoaderComponent } from './items/switcher/listable-object-component-loader.component'; import { TypedItemSearchResultListElementComponent } from './object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component'; @@ -143,6 +143,8 @@ import { DsoInputSuggestionsComponent } from './input-suggestions/dso-input-sugg import { TypedItemSearchResultGridElementComponent } from './object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { PublicationGridElementComponent } from './object-grid/item-grid-element/item-types/publication/publication-grid-element.component'; import { ItemTypeBadgeComponent } from './object-list/item-type-badge/item-type-badge.component'; +import { MetadataRepresentationLoaderComponent } from './metadata-representation/metadata-representation-loader.component'; +import { MetadataRepresentationDirective } from './metadata-representation/metadata-representation.directive'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -264,9 +266,10 @@ const COMPONENTS = [ ItemSearchResultListElementComponent, TypedItemSearchResultListElementComponent, TypedItemSearchResultGridElementComponent, - ItemTypeSwitcherComponent, + ListableObjectComponentLoaderComponent, BrowseByComponent, - ItemTypeBadgeComponent + ItemTypeBadgeComponent, + MetadataRepresentationLoaderComponent ]; const ENTRY_COMPONENTS = [ @@ -335,7 +338,8 @@ const DIRECTIVES = [ AuthorityConfidenceStateDirective, InListValidator, AutoFocusDirective, - RoleDirective + RoleDirective, + MetadataRepresentationDirective ]; @NgModule({ From 9badabade6c98df14e379147fd978f0dc4f7968e Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 3 Oct 2019 16:26:58 +0200 Subject: [PATCH 05/17] Split typed list/grid elements into normal and search result --- .../item-metadata.component.spec.ts | 6 +- .../edit-relationship-list.component.spec.ts | 2 +- .../edit-relationship.component.spec.ts | 2 +- .../modify-item-overview.component.spec.ts | 2 +- ...item-page-abstract-field.component.spec.ts | 2 +- .../item-page-author-field.component.spec.ts | 2 +- .../item-page-date-field.component.spec.ts | 2 +- .../generic-item-page-field.component.spec.ts | 2 +- .../item-page-field.component.spec.ts | 2 +- .../item-page-title-field.component.spec.ts | 2 +- .../uri/item-page-uri-field.component.spec.ts | 2 +- .../publication/publication.component.html | 32 ++-- .../publication/publication.component.ts | 6 +- .../item-types/shared/item.component.ts | 14 +- .../related-entities-search.component.spec.ts | 2 +- .../journal-issue-grid-element.component.html | 31 +-- .../journal-issue-grid-element.component.ts | 7 +- ...journal-volume-grid-element.component.html | 31 +-- .../journal-volume-grid-element.component.ts | 7 +- .../journal-grid-element.component.html | 36 +--- .../journal/journal-grid-element.component.ts | 6 +- ...-search-result-grid-element.component.html | 32 ++++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 50 +++++ ...ue-search-result-grid-element.component.ts | 20 ++ ...-search-result-grid-element.component.html | 32 ++++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 50 +++++ ...me-search-result-grid-element.component.ts | 20 ++ ...-search-result-grid-element.component.html | 37 ++++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 56 ++++++ ...al-search-result-grid-element.component.ts | 20 ++ .../journal-issue-list-element.component.html | 22 +-- ...urnal-issue-list-element.component.spec.ts | 8 +- .../journal-issue-list-element.component.ts | 5 +- ...journal-volume-list-element.component.html | 22 +-- ...rnal-volume-list-element.component.spec.ts | 8 +- .../journal-volume-list-element.component.ts | 5 +- .../journal-list-element.component.html | 16 +- .../journal-list-element.component.spec.ts | 4 +- .../journal/journal-list-element.component.ts | 5 +- ...-search-result-list-element.component.html | 23 +++ ...-search-result-list-element.component.scss | 0 ...arch-result-list-element.component.spec.ts | 117 ++++++++++++ ...ue-search-result-list-element.component.ts | 18 ++ ...-search-result-list-element.component.html | 23 +++ ...-search-result-list-element.component.scss | 0 ...arch-result-list-element.component.spec.ts | 117 ++++++++++++ ...me-search-result-list-element.component.ts | 18 ++ ...-search-result-list-element.component.html | 17 ++ ...-search-result-list-element.component.scss | 0 ...arch-result-list-element.component.spec.ts | 87 +++++++++ ...al-search-result-list-element.component.ts | 18 ++ .../journal-issue.component.html | 20 +- .../journal-issue/journal-issue.component.ts | 4 +- .../journal-volume.component.html | 12 +- .../journal-volume.component.ts | 4 +- .../item-pages/journal/journal.component.html | 16 +- .../item-pages/journal/journal.component.ts | 2 +- .../journal-entities.module.ts | 14 +- .../orgunit-grid-element.component.html | 36 +--- .../orgunit/orgunit-grid-element.component.ts | 7 +- .../person/person-grid-element.component.html | 31 +-- .../person/person-grid-element.component.ts | 7 +- .../project-grid-element.component.html | 26 +-- .../project/project-grid-element.component.ts | 7 +- ...-search-result-grid-element.component.html | 37 ++++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 56 ++++++ ...it-search-result-grid-element.component.ts | 20 ++ ...-search-result-grid-element.component.html | 32 ++++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 50 +++++ ...on-search-result-grid-element.component.ts | 20 ++ ...-search-result-grid-element.component.html | 27 +++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 44 +++++ ...ct-search-result-grid-element.component.ts | 20 ++ ...unit-item-page-list-element.component.html | 6 +- ...rgunit-item-page-list-element.component.ts | 5 +- .../orgunit-list-element.component.html | 17 +- .../orgunit-list-element.component.spec.ts | 4 +- .../orgunit/orgunit-list-element.component.ts | 5 +- ...rson-item-page-list-element.component.html | 6 +- ...person-item-page-list-element.component.ts | 5 +- .../person/person-list-element.component.html | 16 +- .../person-list-element.component.spec.ts | 6 +- .../person/person-list-element.component.ts | 5 +- .../project-list-element.component.html | 17 +- .../project/project-list-element.component.ts | 5 +- ...-search-result-list-element.component.html | 17 ++ ...-search-result-list-element.component.scss | 1 + ...arch-result-list-element.component.spec.ts | 87 +++++++++ ...it-search-result-list-element.component.ts | 18 ++ ...-search-result-list-element.component.html | 17 ++ ...-search-result-list-element.component.scss | 1 + ...arch-result-list-element.component.spec.ts | 85 +++++++++ ...on-search-result-list-element.component.ts | 18 ++ ...-search-result-list-element.component.html | 16 ++ ...-search-result-list-element.component.scss | 1 + ...arch-result-list-element.component.spec.ts | 87 +++++++++ ...ct-search-result-list-element.component.ts | 18 ++ .../item-pages/orgunit/orgunit.component.html | 16 +- .../item-pages/orgunit/orgunit.component.ts | 6 +- .../item-pages/person/person.component.ts | 13 +- .../item-pages/project/project.component.html | 14 +- .../item-pages/project/project.component.ts | 6 +- .../research-entities.module.ts | 14 +- .../object-collection.component.ts | 13 +- ...table-object-component-loader.component.ts | 24 ++- .../abstract-listable-element.component.ts | 7 +- ...-dspace-result-detail-element.component.ts | 4 - .../item-detail-preview.component.spec.ts | 2 +- ...-dspace-result-detail-element.component.ts | 4 +- ...-dspace-result-detail-element.component.ts | 4 +- ...-dspace-result-detail-element.component.ts | 4 - ...-dspace-result-detail-element.component.ts | 4 - .../item-grid-element.component.html | 29 +-- .../publication-grid-element.component.html | 35 +--- .../publication-grid-element.component.ts | 5 +- ...arch-result-grid-element.component.spec.ts | 83 -------- ...em-search-result-grid-element.component.ts | 37 ---- ...-search-result-grid-element.component.html | 2 +- ...-search-result-grid-element.component.html | 36 ++++ ...-search-result-grid-element.component.scss | 0 ...arch-result-grid-element.component.spec.ts | 127 +++++++++++++ ...on-search-result-grid-element.component.ts | 20 ++ .../search-result-grid-element.component.ts | 4 +- .../item-list-element.component.html | 2 +- .../publication-list-element.component.html | 26 +-- ...publication-list-element.component.spec.ts | 18 +- .../publication-list-element.component.ts | 5 +- ...arch-result-list-element.component.spec.ts | 84 --------- ...em-search-result-list-element.component.ts | 37 ---- ...a-representation-list-element.component.ts | 3 +- ...my-dspace-result-list-element.component.ts | 5 +- ...my-dspace-result-list-element.component.ts | 5 +- ...-search-result-list-element.component.html | 2 +- ...-search-result-list-element.component.html | 27 +++ ...-search-result-list-element.component.scss | 1 + ...arch-result-list-element.component.spec.ts | 177 ++++++++++++++++++ ...on-search-result-list-element.component.ts | 18 ++ .../search-result-list-element.component.ts | 4 +- src/app/shared/shared.module.ts | 20 +- src/backend/api.ts | 4 +- 146 files changed, 2094 insertions(+), 860 deletions(-) create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.scss create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.scss create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.scss create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts create mode 100644 src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.scss create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.scss create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.scss create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts create mode 100644 src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.scss create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.scss create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts create mode 100644 src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts delete mode 100644 src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts delete mode 100644 src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts create mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html create mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.scss create mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts create mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts delete mode 100644 src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts create mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html create mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss create mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts create mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts index 0c164b7bc2..b9a793eddd 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts @@ -216,9 +216,9 @@ describe('ItemMetadataComponent', () => { }); it('it should call reinstateFieldUpdates on the objectUpdatesService with the correct url and metadata', () => { - expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.item.metadataAsList); - expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.item, { metadata: Metadata.toMetadataMap(comp.item.metadataAsList) })); - expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.item.metadataAsList); + expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.object.metadataAsList); + expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.object, { metadata: Metadata.toMetadataMap(comp.object.metadataAsList) })); + expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.object.metadataAsList); }); }); diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts index 3748ebca9d..c8e4c35b8b 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts @@ -117,7 +117,7 @@ describe('EditRelationshipListComponent', () => { fixture = TestBed.createComponent(EditRelationshipListComponent); comp = fixture.componentInstance; de = fixture.debugElement; - comp.item = item; + comp.object = item; comp.url = url; comp.relationshipLabel = relationshipType.leftLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts index 3306d8eb01..55f97000e7 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts @@ -113,7 +113,7 @@ describe('EditRelationshipComponent', () => { comp.url = url; comp.fieldUpdate = fieldUpdate1; - comp.item = item; + comp.object = item; fixture.detectChanges(); }); diff --git a/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts b/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts index 07ad9a347c..d0c875d2d3 100644 --- a/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts +++ b/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts @@ -32,7 +32,7 @@ describe('ModifyItemOverviewComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ModifyItemOverviewComponent); comp = fixture.componentInstance; - comp.item = mockItem; + comp.object = mockItem; fixture.detectChanges(); }); diff --git a/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts index 9461ee0950..219da338eb 100644 --- a/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageAbstractFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageAbstractFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts index d865caff8a..5647c7cc11 100644 --- a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts @@ -32,7 +32,7 @@ describe('ItemPageAuthorFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageAuthorFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(field, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(field, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts index 2adada582b..760398e1f5 100644 --- a/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageDateFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageDateFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts index d8abd39cf3..2bfff14dd6 100644 --- a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts @@ -33,7 +33,7 @@ describe('GenericItemPageFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(GenericItemPageFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); comp.fields = mockFields; comp.label = mockLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts index 1b7acb2e3b..4db4e06ce6 100644 --- a/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts @@ -40,7 +40,7 @@ describe('ItemPageFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); comp.fields = mockFields; comp.label = mockLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts index cb1ba6a4bc..17ce39dd18 100644 --- a/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageTitleFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageTitleFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts index 4511f16aae..60d2f5c97c 100644 --- a/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageUriFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageUriFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index abf5225c27..09952354a5 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -1,27 +1,27 @@

- {{'publication.page.titleprefix' | translate}} + {{'publication.page.titleprefix' | translate}}

- + - - - - + + + - - - @@ -43,25 +43,25 @@ [items]="journalIssues$ | async" [label]="'relationships.isJournalIssueOf' | translate"> - - + - - - - + + diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index 09319a4fa6..8f0bdc141d 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -44,15 +44,15 @@ export class PublicationComponent extends ItemComponent implements OnInit { this.authors$ = this.buildRepresentations('Person', 'dc.contributor.author'); this.projects$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPublication') + getRelatedItemsByTypeLabel(this.object.id, 'isProjectOfPublication') ); this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPublication') + getRelatedItemsByTypeLabel(this.object.id, 'isOrgUnitOfPublication') ); this.journalIssues$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isJournalIssueOfPublication') + getRelatedItemsByTypeLabel(this.object.id, 'isJournalIssueOfPublication') ); } diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 6ad84ffae2..398228856b 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -1,14 +1,12 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnInit } from '@angular/core'; import { Observable , zip as observableZip, combineLatest as observableCombineLatest } from 'rxjs'; import { distinctUntilChanged, filter, flatMap, map } from 'rxjs/operators'; -import { ItemDataService } from '../../../../core/data/item-data.service'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { RemoteData } from '../../../../core/data/remote-data'; import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { Item } from '../../../../core/shared/item.model'; import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; @@ -66,13 +64,13 @@ export class ItemComponent implements OnInit { * Resolved relationships and types together in one observable */ resolvedRelsAndTypes$: Observable<[Relationship[], RelationshipType[]]>; + @Input() object: Item; constructor( - @Inject(ITEM) public item: Item ) {} ngOnInit(): void { - const relationships$ = this.item.relationships; + const relationships$ = this.object.relationships; if (relationships$) { const relsCurrentPage$ = relationships$.pipe( filter((rd: RemoteData>) => rd.hasSucceeded), @@ -104,8 +102,8 @@ export class ItemComponent implements OnInit { * @param metadataField The metadata field that resembles the item type. */ buildRepresentations(itemType: string, metadataField: string): Observable { - const metadata = this.item.findMetadataSortedByPlace(metadataField); - const relsCurrentPage$ = this.item.relationships.pipe( + const metadata = this.object.findMetadataSortedByPlace(metadataField); + const relsCurrentPage$ = this.object.relationships.pipe( getSucceededRemoteData(), getRemoteDataPayload(), map((pl: PaginatedList) => pl.page), @@ -113,7 +111,7 @@ export class ItemComponent implements OnInit { ); return relsCurrentPage$.pipe( - relationsToRepresentations(this.item.id, itemType, metadata) + relationsToRepresentations(this.object.id, itemType, metadata) ); } diff --git a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts index 711e1b9d3d..bc2571f6f9 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts +++ b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts @@ -38,7 +38,7 @@ describe('RelatedEntitiesSearchComponent', () => { comp = fixture.componentInstance; fixedFilterService = (comp as any).fixedFilterService; comp.relationType = mockRelationType; - comp.item = mockItem; + comp.object = mockItem; comp.relationEntityType = mockRelationEntityType; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html index 3aa79fc70a..fab0cf5c07 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html @@ -1,30 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts index 75e23de21d..3e57731613 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalIssue', ViewMode.GridElement) @Component({ selector: 'ds-journal-issue-grid-element', styleUrls: ['./journal-issue-grid-element.component.scss'], templateUrl: './journal-issue-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Journal Issue */ -export class JournalIssueGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class JournalIssueGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html index b2b251f550..06bcb10c4d 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html @@ -1,30 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts index 35f1a6161d..eb88c25a12 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalVolume', ViewMode.GridElement) @Component({ selector: 'ds-journal-volume-grid-element', styleUrls: ['./journal-volume-grid-element.component.scss'], templateUrl: './journal-volume-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Journal Volume */ -export class JournalVolumeGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class JournalVolumeGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html index af0739004c..1a7a6f5da8 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html @@ -1,35 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - {{dso.firstMetadataValue('creativework.editor')}} - - , - {{dso.firstMetadataValue('creativework.publisher')}} - - -

-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts index 4596549e3a..c86529317b 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts @@ -1,18 +1,18 @@ import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Journal', ViewMode.GridElement) @Component({ selector: 'ds-journal-grid-element', styleUrls: ['./journal-grid-element.component.scss'], templateUrl: './journal-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Journal */ -export class JournalGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class JournalGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html new file mode 100644 index 0000000000..69ea378269 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -0,0 +1,32 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.scss b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..db13b3592c --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts @@ -0,0 +1,50 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { JournalIssueSearchResultGridElementComponent } from './journal-issue-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativework.datePublished': [ + { + language: null, + value: '2015-06-26' + } + ], + 'journal.title': [ + { + language: 'en_US', + value: 'The journal title' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts new file mode 100644 index 0000000000..ceda357559 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('JournalIssueSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-journal-issue-search-result-grid-element', + styleUrls: ['./journal-issue-search-result-grid-element.component.scss'], + templateUrl: './journal-issue-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Journal Issue + */ +export class JournalIssueSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html new file mode 100644 index 0000000000..93559d21bf --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -0,0 +1,32 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.scss b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..07ffc7bdc0 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts @@ -0,0 +1,50 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { JournalVolumeSearchResultGridElementComponent } from './journal-volume-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativework.datePublished': [ + { + language: null, + value: '2015-06-26' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'A description for the journal volume' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts new file mode 100644 index 0000000000..9ce106f962 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { focusShadow } from '../../../../../shared/animations/focus'; + +@listableObjectComponent('JournalVolumeSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-journal-volume-search-result-grid-element', + styleUrls: ['./journal-volume-search-result-grid-element.component.scss'], + templateUrl: './journal-volume-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Journal Volume + */ +export class JournalVolumeSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html new file mode 100644 index 0000000000..ad37333b90 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -0,0 +1,37 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + {{item.firstMetadataValue('creativework.editor')}} + + , + {{item.firstMetadataValue('creativework.publisher')}} + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.scss b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..94e2e7fd68 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts @@ -0,0 +1,56 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { JournalSearchResultGridElementComponent } from './journal-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativework.editor': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'creativework.publisher': [ + { + language: 'en_US', + value: 'A company' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'This is the description' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts new file mode 100644 index 0000000000..5f24601223 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('JournalSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-journal-search-result-grid-element', + styleUrls: ['./journal-search-result-grid-element.component.scss'], + templateUrl: './journal-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Journal + */ +export class JournalSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html index 030a26df39..1e418ba7c2 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html @@ -1,21 +1 @@ - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts index 37234f8140..ec61615c9a 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts @@ -69,7 +69,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has a journal identifier', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithMetadata; + journalIssueListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -81,7 +81,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has no journal identifier', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithoutMetadata; + journalIssueListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -93,7 +93,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has a journal number', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithMetadata; + journalIssueListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -105,7 +105,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has no journal number', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithoutMetadata; + journalIssueListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts index 847b8a6978..454c140050 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalIssue', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Journal Issue */ -export class JournalIssueListElementComponent extends TypedItemSearchResultListElementComponent { +export class JournalIssueListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html index 4e6e34d3d6..c00de1c33d 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html @@ -1,21 +1 @@ - - - - - - - - - - - - () - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts index 4872d47c31..21d28c7fe8 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts @@ -69,7 +69,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has a journal title', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithMetadata; + journalVolumeListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -81,7 +81,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has no journal title', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithoutMetadata; + journalVolumeListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -93,7 +93,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has a journal identifier', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithMetadata; + journalVolumeListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -105,7 +105,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has no journal identifier', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithoutMetadata; + journalVolumeListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts index e1bc178b5e..641a0d2238 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalVolume', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Journal Volume */ -export class JournalVolumeListElementComponent extends TypedItemSearchResultListElementComponent { +export class JournalVolumeListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html index 0e46e921bb..3df361e7f9 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html @@ -1,15 +1 @@ - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts index 469549821e..c9567fc731 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts @@ -63,7 +63,7 @@ describe('JournalListElementComponent', () => { describe('When the item has an issn', () => { beforeEach(() => { - journalListElementComponent.item = mockItemWithMetadata; + journalListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -75,7 +75,7 @@ describe('JournalListElementComponent', () => { describe('When the item has no issn', () => { beforeEach(() => { - journalListElementComponent.item = mockItemWithoutMetadata; + journalListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts index 05e1576219..fa83c3cff4 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Journal', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Journal */ -export class JournalListElementComponent extends TypedItemSearchResultListElementComponent { +export class JournalListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html new file mode 100644 index 0000000000..2d9faadcdc --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + - + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.scss b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..4d49346e83 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts @@ -0,0 +1,117 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { JournalIssueSearchResultListElementComponent } from './journal-issue-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'publicationvolume.volumeNumber': [ + { + language: 'en_US', + value: '1234' + } + ], + 'publicationissue.issueNumber': [ + { + language: 'en_US', + value: '5678' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalIssueListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ JournalIssueSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(JournalIssueSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalIssueSearchResultListElementComponent); + journalIssueListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has a journal identifier', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal issues span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues')); + expect(journalIdentifierField).not.toBeNull(); + }); + }); + + describe('When the item has no journal identifier', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal issues span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues')); + expect(journalIdentifierField).toBeNull(); + }); + }); + + describe('When the item has a journal number', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal issue numbers span', () => { + const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers')); + expect(journalNumberField).not.toBeNull(); + }); + }); + + describe('When the item has no journal number', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal issue numbers span', () => { + const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers')); + expect(journalNumberField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts new file mode 100644 index 0000000000..65969752ea --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('JournalIssueSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-journal-issue-search-result-list-element', + styleUrls: ['./journal-issue-search-result-list-element.component.scss'], + templateUrl: './journal-issue-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Journal Issue + */ +export class JournalIssueSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html new file mode 100644 index 0000000000..8a1ae65a22 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + + () + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.scss b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..c452ad7be2 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts @@ -0,0 +1,117 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { JournalVolumeSearchResultListElementComponent } from './journal-volume-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'journal.title': [ + { + language: 'en_US', + value: 'This is just another journal title' + } + ], + 'publicationvolume.volumeNumber': [ + { + language: 'en_US', + value: '1234' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalVolumeListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ JournalVolumeSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(JournalVolumeSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent); + journalVolumeListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has a journal title', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal title span', () => { + const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes')); + expect(journalTitleField).not.toBeNull(); + }); + }); + + describe('When the item has no journal title', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal title span', () => { + const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes')); + expect(journalTitleField).toBeNull(); + }); + }); + + describe('When the item has a journal identifier', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal identifiers span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers')); + expect(journalIdentifierField).not.toBeNull(); + }); + }); + + describe('When the item has no journal identifier', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal identifiers span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers')); + expect(journalIdentifierField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts new file mode 100644 index 0000000000..05ffe5ea57 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; + +@listableObjectComponent('JournalVolumeSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-journal-volume-search-result-list-element', + styleUrls: ['./journal-volume-search-result-list-element.component.scss'], + templateUrl: './journal-volume-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Journal Volume + */ +export class JournalVolumeSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html new file mode 100644 index 0000000000..d1dfff123a --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.scss b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..3603b9e689 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts @@ -0,0 +1,87 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { JournalSearchResultListElementComponent } from './journal-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let journalListElementComponent: JournalSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativeworkseries.issn': [ + { + language: 'en_US', + value: '1234' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ JournalSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(JournalSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalSearchResultListElementComponent); + journalListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has an issn', () => { + beforeEach(() => { + journalListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journals span', () => { + const issnField = fixture.debugElement.query(By.css('span.item-list-journals')); + expect(issnField).not.toBeNull(); + }); + }); + + describe('When the item has no issn', () => { + beforeEach(() => { + journalListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journals span', () => { + const issnField = fixture.debugElement.query(By.css('span.item-list-journals')); + expect(issnField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts new file mode 100644 index 0000000000..3e389dcc83 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; + +@listableObjectComponent('JournalSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-journal-search-result-list-element', + styleUrls: ['./journal-search-result-list-element.component.scss'], + templateUrl: './journal-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Journal + */ +export class JournalSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index eebd3e03c8..d49d80b15e 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -1,28 +1,28 @@

- {{'journalissue.page.titleprefix' | translate}} + {{'journalissue.page.titleprefix' | translate}}

- + - - - - - @@ -37,16 +37,16 @@ [items]="publications$ | async" [label]="'relationships.isPublicationOfJournalIssue' | translate"> - - diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts index 631ec64490..151a60a198 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts @@ -32,10 +32,10 @@ export class JournalIssueComponent extends ItemComponent { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.volumes$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isJournalVolumeOfIssue') + getRelatedItemsByTypeLabel(this.object.id, 'isJournalVolumeOfIssue') ); this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfJournalIssue') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfJournalIssue') ); } } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html index 83626c7ae7..d96bff9570 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html @@ -1,16 +1,16 @@

- {{'journalvolume.page.titleprefix' | translate}} + {{'journalvolume.page.titleprefix' | translate}}

- + - - @@ -24,12 +24,12 @@ [items]="issues$ | async" [label]="'relationships.isIssueOf' | translate"> - diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts index 72cfc103fa..b1d83c25f2 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts @@ -32,10 +32,10 @@ export class JournalVolumeComponent extends ItemComponent { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.journals$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isJournalOfVolume') + getRelatedItemsByTypeLabel(this.object.id, 'isJournalOfVolume') ); this.issues$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isIssueOfJournalVolume') + getRelatedItemsByTypeLabel(this.object.id, 'isIssueOfJournalVolume') ); } } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index a82d3c5df6..05d7ffc802 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -1,20 +1,20 @@

- {{'journal.page.titleprefix' | translate}} + {{'journal.page.titleprefix' | translate}}

- + - - - @@ -24,18 +24,18 @@ [items]="volumes$ | async" [label]="'relationships.isVolumeOf' | translate"> -
-
diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts index 32b2648477..1282144a2f 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts @@ -27,7 +27,7 @@ export class JournalComponent extends ItemComponent { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.volumes$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isVolumeOfJournal') + getRelatedItemsByTypeLabel(this.object.id, 'isVolumeOfJournal') ); } } diff --git a/src/app/entity-groups/journal-entities/journal-entities.module.ts b/src/app/entity-groups/journal-entities/journal-entities.module.ts index 4033645e1b..d00eae1e54 100644 --- a/src/app/entity-groups/journal-entities/journal-entities.module.ts +++ b/src/app/entity-groups/journal-entities/journal-entities.module.ts @@ -12,6 +12,12 @@ import { TooltipModule } from 'ngx-bootstrap'; import { JournalIssueGridElementComponent } from './item-grid-elements/journal-issue/journal-issue-grid-element.component'; import { JournalVolumeGridElementComponent } from './item-grid-elements/journal-volume/journal-volume-grid-element.component'; import { JournalGridElementComponent } from './item-grid-elements/journal/journal-grid-element.component'; +import { JournalSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component'; +import { JournalSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component'; +import { JournalIssueSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component'; +import { JournalVolumeSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component'; +import { JournalIssueSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component'; +import { JournalVolumeSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component'; const ENTRY_COMPONENTS = [ JournalComponent, @@ -22,7 +28,13 @@ const ENTRY_COMPONENTS = [ JournalVolumeListElementComponent, JournalIssueGridElementComponent, JournalVolumeGridElementComponent, - JournalGridElementComponent + JournalGridElementComponent, + JournalSearchResultListElementComponent, + JournalIssueSearchResultListElementComponent, + JournalVolumeSearchResultListElementComponent, + JournalIssueSearchResultGridElementComponent, + JournalVolumeSearchResultGridElementComponent, + JournalSearchResultGridElementComponent ]; @NgModule({ diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html index a4765c4e8f..8ad7ce3590 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html @@ -1,35 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-

- - {{dso.firstMetadataValue('organization.address.addressCountry')}} - - , - {{dso.firstMetadataValue('organization.address.addressLocality')}} - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts index f7a13f1033..1bdcbdc370 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.GridElement) @Component({ selector: 'ds-orgunit-grid-element', styleUrls: ['./orgunit-grid-element.component.scss'], templateUrl: './orgunit-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Organisation Unit */ -export class OrgunitGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class OrgunitGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html index 331c2bd520..b837422121 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html @@ -1,30 +1 @@ - -
- -
- - -
-
-
- - -

-
- -

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts index 2458d0b99d..2e3ce5804e 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; -import { focusShadow } from '../../../../shared/animations/focus'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Person', ViewMode.GridElement) @Component({ selector: 'ds-person-grid-element', styleUrls: ['./person-grid-element.component.scss'], templateUrl: './person-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Person */ -export class PersonGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class PersonGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html index 889276b29b..094d109dde 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html @@ -1,25 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts index 067e14bae3..58547960cf 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Project', ViewMode.GridElement) @Component({ selector: 'ds-project-grid-element', styleUrls: ['./project-grid-element.component.scss'], templateUrl: './project-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Project */ -export class ProjectGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class ProjectGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html new file mode 100644 index 0000000000..799f5bd43c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html @@ -0,0 +1,37 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+

+ + {{item.firstMetadataValue('organization.address.addressCountry')}} + + , + {{item.firstMetadataValue('organization.address.addressLocality')}} + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..f854eaa273 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts @@ -0,0 +1,56 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { OrgunitSearchResultGridElementComponent } from './orgunit-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'organization.foundingDate': [ + { + language: null, + value: '2015-06-26' + } + ], + 'organization.address.addressCountry': [ + { + language: 'en_US', + value: 'Belgium' + } + ], + 'organization.address.addressLocality': [ + { + language: 'en_US', + value: 'Brussels' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts new file mode 100644 index 0000000000..535fb0cdbc --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('OrgUnitSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-orgunit-search-result-grid-element', + styleUrls: ['./orgunit-search-result-grid-element.component.scss'], + templateUrl: './orgunit-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Organisation Unit + */ +export class OrgunitSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html new file mode 100644 index 0000000000..1f66fa0d4e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -0,0 +1,32 @@ + + +
+ +
+ + +
+
+
+ + +

+
+ +

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..752630c7b9 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts @@ -0,0 +1,50 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { PersonSearchResultGridElementComponent } from './person-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'person.email': [ + { + language: 'en_US', + value: 'Smith-Donald@gmail.com' + } + ], + 'person.jobTitle': [ + { + language: 'en_US', + value: 'Web Developer' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts new file mode 100644 index 0000000000..19293c9ed4 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('PersonSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-person-search-result-grid-element', + styleUrls: ['./person-search-result-grid-element.component.scss'], + templateUrl: './person-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Person + */ +export class PersonSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html new file mode 100644 index 0000000000..3465388ee0 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -0,0 +1,27 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..acf52224be --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts @@ -0,0 +1,44 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { ProjectSearchResultGridElementComponent } from './project-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'The project description' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts new file mode 100644 index 0000000000..57c57c6cb1 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { Item } from '../../../../../core/shared/item.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { focusShadow } from '../../../../../shared/animations/focus'; + +@listableObjectComponent('ProjectSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-project-search-result-grid-element', + styleUrls: ['./project-search-result-grid-element.component.scss'], + templateUrl: './project-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Project + */ +export class ProjectSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html index ea429e87c6..bacec900c0 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html @@ -1,13 +1,13 @@ - - - + diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts index 350ddf7ece..84ae543f95 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { Context } from '../../../../core/shared/context.model'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) @Component({ @@ -12,5 +13,5 @@ import { Context } from '../../../../core/shared/context.model'; /** * The component for displaying a list element for an item of the type OrgUnit */ -export class OrgunitItemPageListElementComponent extends TypedItemSearchResultListElementComponent { +export class OrgunitItemPageListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html index 8d312fb7c0..246bac000c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html @@ -1,16 +1 @@ - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts index a06ed5ac72..f1ff6b1dce 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts @@ -63,7 +63,7 @@ describe('OrgUnitListElementComponent', () => { describe('When the item has an orgunit description', () => { beforeEach(() => { - orgUnitListElementComponent.item = mockItemWithMetadata; + orgUnitListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -75,7 +75,7 @@ describe('OrgUnitListElementComponent', () => { describe('When the item has no orgunit description', () => { beforeEach(() => { - orgUnitListElementComponent.item = mockItemWithoutMetadata; + orgUnitListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts index 8348a3fe35..7e25cf614d 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Organisation Unit */ -export class OrgUnitListElementComponent extends TypedItemSearchResultListElementComponent { +export class OrgUnitListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html index 1125c2fb9b..e9627b504e 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html @@ -1,6 +1,6 @@ - @@ -8,8 +8,8 @@ - - + diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts index 2569a9cb4e..d90b90262c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Context } from '../../../../core/shared/context.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Person */ -export class PersonItemPageListElementComponent extends TypedItemSearchResultListElementComponent { +export class PersonItemPageListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html index c88b77083d..9df315824a 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html @@ -1,15 +1 @@ - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts index 9553f8ea2c..7d9eaf0d16 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts @@ -5,7 +5,6 @@ import { PersonListElementComponent } from './person-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let personListElementComponent: PersonListElementComponent; @@ -45,7 +44,6 @@ describe('PersonListElementComponent', () => { TestBed.configureTestingModule({ declarations: [ PersonListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], @@ -63,7 +61,7 @@ describe('PersonListElementComponent', () => { describe('When the item has a job title', () => { beforeEach(() => { - personListElementComponent.item = mockItemWithMetadata; + personListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -75,7 +73,7 @@ describe('PersonListElementComponent', () => { describe('When the item has no job title', () => { beforeEach(() => { - personListElementComponent.item = mockItemWithoutMetadata; + personListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts index bd46cb1cdd..f35ed90c58 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Person', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Person */ -export class PersonListElementComponent extends TypedItemSearchResultListElementComponent { +export class PersonListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html index 3e979b4e4d..6d33c48fb4 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html @@ -1,16 +1 @@ - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts index d6b0dbfbce..04d66dcf34 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @metadataRepresentationComponent('Project', MetadataRepresentationType.PlainText) @Component({ @@ -12,5 +13,5 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep /** * The component for displaying a list element for an item of the type Project */ -export class ProjectListElementComponent extends TypedItemSearchResultListElementComponent { +export class ProjectListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html new file mode 100644 index 0000000000..0bb94c7d24 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss new file mode 100644 index 0000000000..1d0786105c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..18f405760f --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts @@ -0,0 +1,87 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { OrgunitSearchResultListElementComponent } from './orgunit-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let orgUnitListElementComponent: OrgunitSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'A description about the OrgUnit' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('OrgUnitListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(OrgunitSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgunitSearchResultListElementComponent); + orgUnitListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has an orgunit description', () => { + beforeEach(() => { + orgUnitListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the description span', () => { + const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); + expect(orgunitDescriptionField).not.toBeNull(); + }); + }); + + describe('When the item has no orgunit description', () => { + beforeEach(() => { + orgUnitListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the description span', () => { + const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); + expect(orgunitDescriptionField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts new file mode 100644 index 0000000000..860e1154ef --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('OrgUnitSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-orgunit-search-result-list-element', + styleUrls: ['./orgunit-search-result-list-element.component.scss'], + templateUrl: './orgunit-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Organisation Unit + */ +export class OrgunitSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html new file mode 100644 index 0000000000..77f29d25ff --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss new file mode 100644 index 0000000000..1d0786105c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..07c53d3c16 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts @@ -0,0 +1,85 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { PersonSearchResultListElementComponent } from './person-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let personListElementComponent: PersonSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'person.jobTitle': [ + { + language: 'en_US', + value: 'Developer' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PersonListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PersonSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(PersonSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonSearchResultListElementComponent); + personListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has a job title', () => { + beforeEach(() => { + personListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the job title span', () => { + const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); + expect(jobTitleField).not.toBeNull(); + }); + }); + + describe('When the item has no job title', () => { + beforeEach(() => { + personListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the job title span', () => { + const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); + expect(jobTitleField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts new file mode 100644 index 0000000000..b53a369504 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('PersonSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-person-search-result-list-element', + styleUrls: ['./person-search-result-list-element.component.scss'], + templateUrl: './person-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Person + */ +export class PersonSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html new file mode 100644 index 0000000000..fab5971f9e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss new file mode 100644 index 0000000000..1d0786105c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..816467727e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts @@ -0,0 +1,87 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { ProjectSearchResultListElementComponent } from './project-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let projectListElementComponent: ProjectSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + // 'project.identifier.status': [ + // { + // language: 'en_US', + // value: 'A status about the project' + // } + // ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('ProjectListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProjectSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(ProjectSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(ProjectSearchResultListElementComponent); + projectListElementComponent = fixture.componentInstance; + + })); + + // describe('When the item has a status', () => { + // beforeEach(() => { + // projectListElementComponent.item = mockItemWithMetadata; + // fixture.detectChanges(); + // }); + // + // it('should show the status span', () => { + // const statusField = fixture.debugElement.query(By.css('span.item-list-status')); + // expect(statusField).not.toBeNull(); + // }); + // }); + // + // describe('When the item has no status', () => { + // beforeEach(() => { + // projectListElementComponent.item = mockItemWithoutMetadata; + // fixture.detectChanges(); + // }); + // + // it('should not show the status span', () => { + // const statusField = fixture.debugElement.query(By.css('span.item-list-status')); + // expect(statusField).toBeNull(); + // }); + // }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts new file mode 100644 index 0000000000..5fd5d57d81 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { metadataRepresentationComponent } from '../../../../../shared/metadata-representation/metadata-representation.decorator'; +import { MetadataRepresentationType } from '../../../../../core/shared/metadata-representation/metadata-representation.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@metadataRepresentationComponent('ProjectSearchResult', MetadataRepresentationType.PlainText) +@Component({ + selector: 'ds-project-search-result-list-element', + styleUrls: ['./project-search-result-list-element.component.scss'], + templateUrl: './project-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Project + */ +export class ProjectSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html index 92ac3eac30..637e59b4fb 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html @@ -1,24 +1,24 @@

- {{'orgunit.page.titleprefix' | translate}} + {{'orgunit.page.titleprefix' | translate}}

- + - - - - @@ -36,12 +36,12 @@ [items]="publications$ | async" [label]="'relationships.isPublicationOf' | translate"> - diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts index 164388547c..c63a1c8a53 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts @@ -37,15 +37,15 @@ export class OrgunitComponent extends ItemComponent implements OnInit { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.people$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPersonOfOrgUnit') + getRelatedItemsByTypeLabel(this.object.id, 'isPersonOfOrgUnit') ); this.projects$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfOrgUnit') + getRelatedItemsByTypeLabel(this.object.id, 'isProjectOfOrgUnit') ); this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfOrgUnit') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfOrgUnit') ); } }} diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts index 4783a7548e..78d11ccde4 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts @@ -1,7 +1,6 @@ import { Component, Inject } from '@angular/core'; import { Observable , of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; @@ -45,28 +44,28 @@ export class PersonComponent extends ItemComponent { fixedFilterQuery: string; constructor( - @Inject(ITEM) public item: Item, private fixedFilterService: SearchFixedFilterService ) { - super(item); + super(); } + ngOnInit(): void { super.ngOnInit(); if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfAuthor') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfAuthor') ); this.projects$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPerson') + getRelatedItemsByTypeLabel(this.object.id, 'isProjectOfPerson') ); this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPerson') + getRelatedItemsByTypeLabel(this.object.id, 'isOrgUnitOfPerson') ); - this.fixedFilterQuery = this.fixedFilterService.getQueryByRelations('isAuthorOfPublication', this.item.id); + this.fixedFilterQuery = this.fixedFilterService.getQueryByRelations('isAuthorOfPublication', this.object.id); this.fixedFilter$ = observableOf('publication'); } } diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 4e9a130b8c..f9596e7f0c 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -1,10 +1,10 @@

- {{'project.page.titleprefix' | translate}} + {{'project.page.titleprefix' | translate}}

- + @@ -14,11 +14,11 @@ [label]="'project.page.contributor' | translate" [representations]="contributors$ | async"> - - @@ -40,16 +40,16 @@ [items]="orgUnits$ | async" [label]="'relationships.isOrgUnitOf' | translate"> - - diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts index 776e38e7f4..8a672c5eb4 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts @@ -45,15 +45,15 @@ export class ProjectComponent extends ItemComponent implements OnInit { this.contributors$ = this.buildRepresentations('OrgUnit', 'project.contributor.other'); this.people$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPersonOfProject') + getRelatedItemsByTypeLabel(this.object.id, 'isPersonOfProject') ); this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfProject') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfProject') ); this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfProject') + getRelatedItemsByTypeLabel(this.object.id, 'isOrgUnitOfProject') ); } } diff --git a/src/app/entity-groups/research-entities/research-entities.module.ts b/src/app/entity-groups/research-entities/research-entities.module.ts index 1f6e477097..2d4d95dfbf 100644 --- a/src/app/entity-groups/research-entities/research-entities.module.ts +++ b/src/app/entity-groups/research-entities/research-entities.module.ts @@ -14,6 +14,12 @@ import { TooltipModule } from 'ngx-bootstrap'; import { PersonGridElementComponent } from './item-grid-elements/person/person-grid-element.component'; import { OrgunitGridElementComponent } from './item-grid-elements/orgunit/orgunit-grid-element.component'; import { ProjectGridElementComponent } from './item-grid-elements/project/project-grid-element.component'; +import { OrgunitSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component'; +import { PersonSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/person/person-search-result-list-element.component'; +import { ProjectSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/project/project-search-result-list-element.component'; +import { PersonSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component'; +import { OrgunitSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component'; +import { ProjectSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component'; const ENTRY_COMPONENTS = [ OrgunitComponent, @@ -26,7 +32,13 @@ const ENTRY_COMPONENTS = [ ProjectListElementComponent, PersonGridElementComponent, OrgunitGridElementComponent, - ProjectGridElementComponent + ProjectGridElementComponent, + OrgunitSearchResultListElementComponent, + PersonSearchResultListElementComponent, + ProjectSearchResultListElementComponent, + PersonSearchResultGridElementComponent, + OrgunitSearchResultGridElementComponent, + ProjectSearchResultGridElementComponent ]; @NgModule({ diff --git a/src/app/shared/object-collection/object-collection.component.ts b/src/app/shared/object-collection/object-collection.component.ts index f90842d58a..2b25915f1e 100644 --- a/src/app/shared/object-collection/object-collection.component.ts +++ b/src/app/shared/object-collection/object-collection.component.ts @@ -1,13 +1,4 @@ -import { - ChangeDetectorRef, - Component, - EventEmitter, - Input, - OnChanges, - OnInit, - Output, - SimpleChanges -} from '@angular/core'; +import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Observable } from 'rxjs'; @@ -18,7 +9,7 @@ import { PageInfo } from '../../core/shared/page-info.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { ListableObject } from './shared/listable-object.model'; -import { hasValue, isEmpty, isNotEmpty } from '../empty.util'; +import { isNotEmpty } from '../empty.util'; import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 17c860e04b..149425c157 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -1,9 +1,11 @@ -import { Component, InjectionToken, Injector, Input, OnInit } from '@angular/core'; +import { Component, ComponentFactoryResolver, Input, OnInit, ViewChild } from '@angular/core'; import { ListableObject } from '../listable-object.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Context } from '../../../../core/shared/context.model'; -import { hasValue } from '../../../empty.util'; import { getListableObjectComponent } from './listable-object.decorator'; +import { GenericConstructor } from '../../../../core/shared/generic-constructor'; +import { ListableObjectDirective } from './listable-object.directive'; +import { hasValue, isNotEmpty } from '../../../empty.util'; @Component({ selector: 'ds-listable-object-component-loader', @@ -14,6 +16,8 @@ import { getListableObjectComponent } from './listable-object.decorator'; * Component for determining what component to use depending on the item's relationship type (relationship.type) */ export class ListableObjectComponentLoaderComponent implements OnInit { + + @Input() type?: string; /** * The item or metadata to determine the component for */ @@ -25,19 +29,29 @@ export class ListableObjectComponentLoaderComponent implements OnInit { @Input() viewMode: ViewMode; @Input() context: Context; + @ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective; - constructor(private injector: Injector) { + constructor(private componentFactoryResolver: ComponentFactoryResolver) { } ngOnInit(): void { + const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); + const viewContainerRef = this.listableObjectDirective.viewContainerRef; + viewContainerRef.clear(); + + const componentRef = viewContainerRef.createComponent(componentFactory); + (componentRef.instance as any).object = this.object; } /** * Fetch the component depending on the item's relationship type * @returns {string} */ - private getComponent(): string { - return getListableObjectComponent(this.object, this.viewMode); + private getComponent(): GenericConstructor { + if (isNotEmpty(this.type)) { + return getListableObjectComponent(this.type, this.viewMode) + } + return getListableObjectComponent(this.object.constructor as GenericConstructor, this.viewMode); } } diff --git a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts index d52036b5dc..f72d1c9e51 100644 --- a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts +++ b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, Input } from '@angular/core'; import { ListableObject } from '../listable-object.model'; @Component({ @@ -6,8 +6,5 @@ import { ListableObject } from '../listable-object.model'; template: ``, }) export class AbstractListableElementComponent { - object: T; - public constructor(@Inject('objectElementProvider') public listableObject: ListableObject) { - this.object = listableObject as T; - } + @Input() object: T; } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts index 4e947a496f..0c47a239cc 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts @@ -42,10 +42,6 @@ export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultD */ public workflowitem: WorkflowItem; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts index 7920e54b00..c5970d751f 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts @@ -72,7 +72,7 @@ describe('ItemDetailPreviewComponent', () => { fixture = TestBed.createComponent(ItemDetailPreviewComponent); component = fixture.componentInstance; component.object = { hitHighlights: {} } as any; - component.item = mockItem; + component.object = mockItem; component.separator = ', '; spyOn(component.item, 'getFiles').and.returnValue(mockItem.bitstreams); fixture.detectChanges(); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts index 47a44d3132..1b83468c68 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts @@ -22,8 +22,8 @@ export class MyDSpaceResultDetailElementComponent, K * * @param {ListableObject} detailable */ - public constructor(@Inject('objectElementProvider') public detailable: ListableObject) { - super(detailable); + public constructor() { + super(); this.dso = this.object.indexableObject; } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts index 16e96cf412..20fe3dcb2c 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts @@ -41,8 +41,8 @@ export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDeta */ public workflowitem: WorkflowItem; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); + constructor() { + super(); } /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts index a8c2e5555f..ec83c7f6d0 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts @@ -36,10 +36,6 @@ export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceRe */ public status = MyDspaceItemStatusType.WORKFLOW; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts index 0415715c44..afb3107fa4 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts @@ -39,10 +39,6 @@ export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceR */ status = MyDspaceItemStatusType.WORKSPACE; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html index 6bb2cfa99d..21ee7968ca 100644 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html +++ b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html @@ -1,28 +1 @@ - -
- - - - -
-

{{object.firstMetadataValue('dc.title')}}

- - -

- {{author}} - ; - - {{object.firstMetadataValue("dc.date.issued")}} -

-
- - -

{{object.firstMetadataValue("dc.description.abstract")}}

-
- -
- View -
-
-
-
+ diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html index e735dbf107..df413ebead 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html @@ -1,34 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - {{dso.firstMetadataValue('dc.date.issued')}} - , - - - -

-

- - - -

-
- View -
-
-
-
+ diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts index f99810ea69..0893d6b121 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts @@ -1,8 +1,9 @@ -import { TypedItemSearchResultGridElementComponent } from '../typed-item-search-result-grid-element.component'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../animations/focus'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.GridElement) @listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.GridElement) @@ -15,5 +16,5 @@ import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-c /** * The component for displaying a grid element for an item of the type Publication */ -export class PublicationGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class PublicationGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts deleted file mode 100644 index 8035ec623f..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { TruncatePipe } from '../../../utils/truncate.pipe'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { Item } from '../../../../core/shared/item.model'; -import { RemoteData } from '../../../../core/data/remote-data'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { of as observableOf } from 'rxjs'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; -import { TypedItemSearchResultGridElementComponent } from './typed-item-search-result-grid-element.component'; - -const mockItem: Item = Object.assign(new Item(), { - bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))), - metadata: [], - relationships: createRelationshipsObservable() -}); -const mockSearchResult = { - indexableObject: mockItem as Item, - hitHighlights: new MetadataMap() -} as ItemSearchResult; - -describe('TypedItemSearchResultGridElementComponent', () => { - let comp: TypedItemSearchResultGridElementComponent; - let fixture: ComponentFixture; - - describe('when injecting an Item', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockItem} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultGridElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); - - describe('when injecting an ItemSearchResult', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockSearchResult} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultGridElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); -}); diff --git a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts deleted file mode 100644 index 3e19b34c04..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { Component, Inject } from '@angular/core'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { hasValue } from '../../../empty.util'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; - -/** - * A generic component for displaying item grid elements - */ -@Component({ - selector: 'ds-item-search-result-grid-element', - template: '' -}) -export class TypedItemSearchResultGridElementComponent extends SearchResultGridElementComponent { - item: Item; - - constructor( - protected truncatableService: TruncatableService, - @Inject(ITEM) public obj: Item | ItemSearchResult, - ) { - super(undefined, truncatableService); - if (hasValue((obj as any).indexableObject)) { - this.object = obj as ItemSearchResult; - this.dso = this.object.indexableObject; - } else { - this.object = { - indexableObject: obj as Item, - hitHighlights: new MetadataMap() - }; - this.dso = obj as Item; - } - this.item = this.dso; - } -} diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html index d433c7acf2..36740cf48f 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html new file mode 100644 index 0000000000..273be96ca5 --- /dev/null +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html @@ -0,0 +1,36 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + {{item.firstMetadataValue('dc.date.issued')}} + , + + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.scss b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..0245e0699e --- /dev/null +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts @@ -0,0 +1,127 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TruncatePipe } from '../../../../utils/truncate.pipe'; +import { TruncatableService } from '../../../../truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { PublicationSearchResultGridElementComponent } from './publication-grid-element.component'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.contributor.author': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'dc.date.issued': [ + { + language: null, + value: '2015-06-26' + } + ], + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'This is an abstract' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PublicationGridElementComponent', getEntityGridElementTestComponent(PublicationSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract'])); + +/** + * Create test cases for a grid component of an entity. + * @param component The component's class + * @param searchResultWithMetadata An ItemSearchResult containing an item with metadata that should be displayed in the grid element + * @param searchResultWithoutMetadata An ItemSearchResult containing an item that's missing the metadata that should be displayed in the grid element + * @param fieldsToCheck A list of fields to check. The tests expect to find html elements with class ".item-${field}", so make sure they exist in the html template of the grid element. + * For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's + * present when the author metadata is available. + */ +export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) { + return () => { + let comp; + let fixture; + + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [component, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + {provide: ITEM, useValue: searchResultWithoutMetadata} + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(component, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(component); + comp = fixture.componentInstance; + })); + + fieldsToCheck.forEach((field) => { + describe(`when the item has "${field}" metadata`, () => { + beforeEach(() => { + comp.dso = searchResultWithMetadata.indexableObject; + fixture.detectChanges(); + }); + + it(`should show the "${field}" field`, () => { + const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`)); + expect(itemAuthorField).not.toBeNull(); + }); + }); + + describe(`when the item has no "${field}" metadata`, () => { + beforeEach(() => { + comp.dso = searchResultWithoutMetadata.indexableObject; + fixture.detectChanges(); + }); + + it(`should not show the "${field}" field`, () => { + const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`)); + expect(itemAuthorField).toBeNull(); + }); + }); + }); + } +} diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts new file mode 100644 index 0000000000..bda211532a --- /dev/null +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { focusShadow } from '../../../../animations/focus'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { SearchResultGridElementComponent } from '../../search-result-grid-element.component'; +import { Item } from '../../../../../core/shared/item.model'; +import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; + +@listableObjectComponent('PublicationSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-publication-search-result-grid-element', + styleUrls: ['./publication-search-result-grid-element.component.scss'], + templateUrl: './publication-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Publication + */ +export class PublicationSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts index 63b2536043..2213941864 100644 --- a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts @@ -18,8 +18,8 @@ export class SearchResultGridElementComponent, K exten dso: K; isCollapsed$: Observable; - public constructor(@Inject('objectElementProvider') public listableObject: ListableObject, protected truncatableService: TruncatableService) { - super(listableObject); + public constructor(protected truncatableService: TruncatableService) { + super(); if (hasValue(this.object)) { this.dso = this.object.indexableObject; this.isCollapsed$ = this.isCollapsed(); diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.html b/src/app/shared/object-list/item-list-element/item-list-element.component.html index d433c7acf2..21ee7968ca 100644 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html index d467edfb21..f4269d357d 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html @@ -1,25 +1 @@ - - - - - (, ) - - - - ; - - - - -
- - -
-
+ \ No newline at end of file diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts index fe46669cfe..5761a591dd 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts @@ -5,7 +5,6 @@ import { PublicationListElementComponent } from './publication-list-element.comp import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; -import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; import { of as observableOf } from 'rxjs'; let publicationListElementComponent: PublicationListElementComponent; @@ -63,7 +62,6 @@ describe('PublicationListElementComponent', () => { TestBed.configureTestingModule({ declarations: [ PublicationListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], @@ -81,7 +79,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has an author', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -93,7 +91,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no author', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -105,7 +103,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has a publisher', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -117,7 +115,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no publisher', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -129,7 +127,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has an issuedate', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -141,7 +139,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no issuedate', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -153,7 +151,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has an abstract', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -165,7 +163,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no abstract', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 52d2f569b3..9c1b27e785 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.ListElement) @listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.ListElement) @@ -13,5 +14,5 @@ import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-c /** * The component for displaying a list element for an item of the type Publication */ -export class PublicationListElementComponent extends TypedItemSearchResultListElementComponent { +export class PublicationListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts deleted file mode 100644 index c114a941cf..0000000000 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { TruncatePipe } from '../../../utils/truncate.pipe'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from './typed-item-search-result-list-element.component'; -import { Item } from '../../../../core/shared/item.model'; -import { RemoteData } from '../../../../core/data/remote-data'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { of as observableOf } from 'rxjs'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject$ } from '../../../testing/utils'; - -const mockItem: Item = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: [], - relationships: createRelationshipsObservable() -}); -const mockSearchResult = { - indexableObject: mockItem as Item, - hitHighlights: new MetadataMap() -} as ItemSearchResult; - -describe('TypedItemSearchResultListElementComponent', () => { - let comp: TypedItemSearchResultListElementComponent; - let fixture: ComponentFixture; - - describe('when injecting an Item', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultListElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockItem} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultListElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultListElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); - - describe('when injecting an ItemSearchResult', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultListElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockSearchResult} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultListElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultListElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); -}); diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts deleted file mode 100644 index cf7dc0b330..0000000000 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Component, Inject } from '@angular/core'; -import { Item } from '../../../../core/shared/item.model'; -import { hasValue } from '../../../empty.util'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; - -/** - * A generic component for displaying item list elements - */ -@Component({ - selector: 'ds-item-search-result-list-element', - template: '' -}) -export class TypedItemSearchResultListElementComponent extends SearchResultListElementComponent { - item: Item; - - constructor( - protected truncatableService: TruncatableService, - @Inject(ITEM) public obj: Item | ItemSearchResult, - ) { - super(undefined, truncatableService); - if (hasValue((obj as any).indexableObject)) { - this.object = obj as ItemSearchResult; - this.dso = this.object.indexableObject; - } else { - this.object = { - indexableObject: obj as Item, - hitHighlights: new MetadataMap() - }; - this.dso = obj as Item; - } - this.item = this.dso; - } -} diff --git a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts index 427726149f..b7f4a381e2 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts @@ -1,6 +1,5 @@ -import { Component, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; -import { ITEM } from '../../items/switcher/listable-object-component-loader.component'; @Component({ selector: 'ds-metadata-representation-list-element', diff --git a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts index b2a5bf14fd..0db8b73412 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts @@ -28,9 +28,8 @@ export class MyDSpaceResultListElementComponent, K e * @param {ListableObject} listable * @param {number} index */ - public constructor(@Inject('objectElementProvider') public listable: ListableObject, - @Inject('indexElementProvider') public index: number) { - super(listable); + public constructor(@Inject('indexElementProvider') public index: number) { + super(); this.dso = this.object.indexableObject; this.dsoIndex = this.index; } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts index d3876714dc..1f9499f6aa 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts @@ -42,9 +42,8 @@ export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListEl */ public workflowitem: WorkflowItem; - constructor(@Inject('objectElementProvider') public listable: ListableObject, - @Inject('indexElementProvider') public index: number) { - super(listable, index); + constructor(@Inject('indexElementProvider') public index: number) { + super(index); } /** diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html index 051a27bde7..901ce441bf 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html @@ -1,2 +1,2 @@ - + diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html new file mode 100644 index 0000000000..2d42fb611d --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html @@ -0,0 +1,27 @@ + + + + + + (, ) + + + + ; + + + + +
+ + +
+
+
\ No newline at end of file diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss new file mode 100644 index 0000000000..5e4536cf95 --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../../../styles/variables'; diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..1b77c5bd85 --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts @@ -0,0 +1,177 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { PublicationSearchResultListElementComponent } from './publication-list-element.component'; +import { Item } from '../../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../utils/truncate.pipe'; +import { TruncatableService } from '../../../../truncatable/truncatable.service'; +import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; +import { of as observableOf } from 'rxjs'; + +let publicationListElementComponent: PublicationSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.contributor.author': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'dc.publisher': [ + { + language: 'en_US', + value: 'a publisher' + } + ], + 'dc.date.issued': [ + { + language: 'en_US', + value: '2015-06-26' + } + ], + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'This is the abstract' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PublicationListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PublicationSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(PublicationSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PublicationSearchResultListElementComponent); + publicationListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has an author', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the author paragraph', () => { + const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors')); + expect(itemAuthorField).not.toBeNull(); + }); + }); + + describe('When the item has no author', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the author paragraph', () => { + const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors')); + expect(itemAuthorField).toBeNull(); + }); + }); + + describe('When the item has a publisher', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the publisher span', () => { + const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher')); + expect(publisherField).not.toBeNull(); + }); + }); + + describe('When the item has no publisher', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the publisher span', () => { + const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher')); + expect(publisherField).toBeNull(); + }); + }); + + describe('When the item has an issuedate', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the issuedate span', () => { + const dateField = fixture.debugElement.query(By.css('span.item-list-date')); + expect(dateField).not.toBeNull(); + }); + }); + + describe('When the item has no issuedate', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the issuedate span', () => { + const dateField = fixture.debugElement.query(By.css('span.item-list-date')); + expect(dateField).toBeNull(); + }); + }); + + describe('When the item has an abstract', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the abstract span', () => { + const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); + expect(abstractField).not.toBeNull(); + }); + }); + + describe('When the item has no abstract', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the abstract span', () => { + const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); + expect(abstractField).toBeNull(); + }); + }); +}); diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts new file mode 100644 index 0000000000..74d0d30f8d --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../../core/shared/view-mode.model'; +import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model'; +import { SearchResultListElementComponent } from '../../../search-result-list-element.component'; +import { Item } from '../../../../../../core/shared/item.model'; + +@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-publication-search-result-list-element', + styleUrls: ['./publication-search-result-list-element.component.scss'], + templateUrl: './publication-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Publication + */ +export class PublicationSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts index 7017f3f48b..f9110c0cb4 100644 --- a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts @@ -19,8 +19,8 @@ export class SearchResultListElementComponent, K exten dso: K; metadata: MetadataMap; - public constructor(@Inject('objectElementProvider') public listable: ListableObject, protected truncatableService: TruncatableService) { - super(listable); + public constructor(protected truncatableService: TruncatableService) { + super(); if (hasValue(this.object)) { this.dso = this.object.indexableObject; } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index d50056d731..8aa5bf0fdd 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -9,8 +9,6 @@ import { NgbDatepickerModule, NgbModule, NgbTimepickerModule, NgbTypeaheadModule import { TranslateModule } from '@ngx-translate/core'; import { NgxPaginationModule } from 'ngx-pagination'; -import { ListableObjectComponentLoaderComponent } from './items/switcher/listable-object-component-loader.component'; -import { TypedItemSearchResultListElementComponent } from './object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component'; import { FileUploadModule } from 'ng2-file-upload'; @@ -26,13 +24,11 @@ import { CollectionListElementComponent } from './object-list/collection-list-el import { CommunityListElementComponent } from './object-list/community-list-element/community-list-element.component'; import { ItemListElementComponent } from './object-list/item-list-element/item-list-element.component'; import { SearchResultListElementComponent } from './object-list/search-result-list-element/search-result-list-element.component'; -import { WrapperListElementComponent } from './object-list/wrapper-list-element/wrapper-list-element.component'; import { ObjectListComponent } from './object-list/object-list.component'; import { CollectionGridElementComponent } from './object-grid/collection-grid-element/collection-grid-element.component'; import { CommunityGridElementComponent } from './object-grid/community-grid-element/community-grid-element.component'; import { ItemGridElementComponent } from './object-grid/item-grid-element/item-grid-element.component'; import { AbstractListableElementComponent } from './object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { WrapperGridElementComponent } from './object-grid/wrapper-grid-element/wrapper-grid-element.component'; import { ObjectGridComponent } from './object-grid/object-grid.component'; import { ObjectCollectionComponent } from './object-collection/object-collection.component'; import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component'; @@ -85,7 +81,6 @@ import { MyDSpaceResultDetailElementComponent } from './object-detail/my-dspace- import { ClaimedTaskActionsComponent } from './mydspace-actions/claimed-task/claimed-task-actions.component'; import { PoolTaskActionsComponent } from './mydspace-actions/pool-task/pool-task-actions.component'; import { ObjectDetailComponent } from './object-detail/object-detail.component'; -import { WrapperDetailElementComponent } from './object-detail/wrapper-detail-element/wrapper-detail-element.component'; import { ItemDetailPreviewComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component'; import { MyDSpaceItemStatusComponent } from './object-collection/shared/mydspace-item-status/my-dspace-item-status.component'; import { WorkspaceitemActionsComponent } from './mydspace-actions/workspaceitem/workspaceitem-actions.component'; @@ -140,11 +135,13 @@ import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/clai import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component'; import { FilterInputSuggestionsComponent } from './input-suggestions/filter-suggestions/filter-input-suggestions.component'; import { DsoInputSuggestionsComponent } from './input-suggestions/dso-input-suggestions/dso-input-suggestions.component'; -import { TypedItemSearchResultGridElementComponent } from './object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { PublicationGridElementComponent } from './object-grid/item-grid-element/item-types/publication/publication-grid-element.component'; import { ItemTypeBadgeComponent } from './object-list/item-type-badge/item-type-badge.component'; import { MetadataRepresentationLoaderComponent } from './metadata-representation/metadata-representation-loader.component'; import { MetadataRepresentationDirective } from './metadata-representation/metadata-representation.directive'; +import { ListableObjectComponentLoaderComponent } from './object-collection/shared/listable-object/listable-object-component-loader.component'; +import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component'; +import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -224,16 +221,12 @@ const COMPONENTS = [ ObjectDetailComponent, ObjectGridComponent, AbstractListableElementComponent, - WrapperListElementComponent, - WrapperDetailElementComponent, - WrapperGridElementComponent, ObjectCollectionComponent, PaginationComponent, SearchFormComponent, ThumbnailComponent, GridThumbnailComponent, UploaderComponent, - WrapperListElementComponent, ItemListPreviewComponent, MyDSpaceItemStatusComponent, ItemSubmitterComponent, @@ -264,8 +257,6 @@ const COMPONENTS = [ CommunitySearchResultListElementComponent, CollectionSearchResultListElementComponent, ItemSearchResultListElementComponent, - TypedItemSearchResultListElementComponent, - TypedItemSearchResultGridElementComponent, ListableObjectComponentLoaderComponent, BrowseByComponent, ItemTypeBadgeComponent, @@ -288,6 +279,8 @@ const ENTRY_COMPONENTS = [ SearchResultGridElementComponent, PublicationListElementComponent, PublicationGridElementComponent, + PublicationSearchResultListElementComponent, + PublicationSearchResultGridElementComponent, BrowseEntryListElementComponent, MyDSpaceResultDetailElementComponent, SearchResultGridElementComponent, @@ -352,7 +345,8 @@ const DIRECTIVES = [ ...COMPONENTS, ...DIRECTIVES, ...ENTRY_COMPONENTS, - ...SHARED_ITEM_PAGE_COMPONENTS + ...SHARED_ITEM_PAGE_COMPONENTS, + PublicationSearchResultListElementComponent ], providers: [ ...PROVIDERS diff --git a/src/backend/api.ts b/src/backend/api.ts index e1943b5d30..da83b1ba12 100644 --- a/src/backend/api.ts +++ b/src/backend/api.ts @@ -117,7 +117,7 @@ export function createMockApi() { const id = req.params.item_id; try { req.item_id = id; - req.item = ITEMS.items.find((item) => { + req.object = ITEMS.items.find((item) => { return item.id === id; }); next(); @@ -127,7 +127,7 @@ export function createMockApi() { }); router.route('/items/:item_id').get((req, res) => { - res.json(toHALResponse(req, req.item)); + res.json(toHALResponse(req, req.object)); }); router.route('/bundles').get((req, res) => { From a1f144aa0b203d28f498cb85219407e59ab9c64d Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 4 Oct 2019 16:06:59 +0200 Subject: [PATCH 06/17] replaced type input by getRenderType method --- .../edit-relationship.component.html | 2 +- .../simple/item-page.component.html | 2 +- ...etadata-representation-list.component.html | 4 +- ...data-representation-list.component.spec.ts | 2 +- .../related-items.component.html | 4 +- .../related-items.component.spec.ts | 2 +- .../+my-dspace-page/my-dspace-result.model.ts | 3 + .../normalized-search-result.model.ts | 4 +- src/app/+search-page/search-page.module.ts | 3 - src/app/+search-page/search-result.model.ts | 3 + .../models/normalized-eperson.model.ts | 2 +- .../eperson/models/normalized-group.model.ts | 2 +- src/app/core/metadata/metadata-field.model.ts | 4 + .../core/metadata/metadata-schema.model.ts | 4 + .../normalized-metadata-field.model.ts | 2 +- .../normalized-metadata-schema.model.ts | 2 +- src/app/core/registry/registry.service.ts | 2 +- src/app/core/shared/browse-entry.model.ts | 6 +- src/app/core/shared/dspace-object.model.ts | 3 + src/app/core/shared/item.model.ts | 7 ++ ...arch-result-grid-element.component.spec.ts | 15 ++- ...arch-result-grid-element.component.spec.ts | 15 ++- ...arch-result-grid-element.component.spec.ts | 15 ++- ...urnal-issue-list-element.component.spec.ts | 2 - ...rnal-volume-list-element.component.spec.ts | 2 - ...-search-result-list-element.component.html | 1 + ...arch-result-list-element.component.spec.ts | 88 ++++++++------ ...-search-result-list-element.component.html | 1 + ...arch-result-list-element.component.spec.ts | 87 +++++++------ ...-search-result-list-element.component.html | 1 + ...arch-result-list-element.component.spec.ts | 75 +++++++----- ...arch-result-grid-element.component.spec.ts | 15 ++- ...arch-result-grid-element.component.spec.ts | 15 ++- ...arch-result-grid-element.component.spec.ts | 15 ++- ...-search-result-list-element.component.html | 1 + ...-search-result-list-element.component.scss | 1 - ...arch-result-list-element.component.spec.ts | 71 ++++++----- ...-search-result-list-element.component.html | 1 + ...-search-result-list-element.component.scss | 1 - ...arch-result-list-element.component.spec.ts | 73 ++++++----- ...-search-result-list-element.component.html | 32 ++--- ...-search-result-list-element.component.scss | 1 - ...arch-result-list-element.component.spec.ts | 77 ++++++------ .../shared/browse-by/browse-by.component.html | 2 +- .../dso-selector/dso-selector.component.html | 2 +- .../dso-selector/dso-selector.component.ts | 3 +- .../dso-input-suggestions.component.html | 2 +- .../dso-input-suggestions.component.ts | 2 + .../shared/item-my-dspace-result.model.ts | 3 + .../shared/listable-object.model.ts | 6 +- ...ble-object-component-loader.component.html | 2 +- ...table-object-component-loader.component.ts | 12 +- .../listable-object.decorator.ts | 2 +- .../abstract-listable-element.component.ts | 3 +- ...-dspace-result-detail-element.component.ts | 5 +- ...-dspace-result-detail-element.component.ts | 2 +- ...-dspace-result-detail-element.component.ts | 4 +- ...-dspace-result-detail-element.component.ts | 4 +- ...-dspace-result-detail-element.component.ts | 5 +- .../object-detail.component.html | 2 +- .../object-detail/object-detail.component.ts | 2 + .../collection-grid-element.component.ts | 2 +- .../community-grid-element.component.ts | 2 +- .../item-grid-element.component.html | 1 - .../item-grid-element.component.scss | 1 - .../item-grid-element.component.spec.ts | 114 ------------------ .../item-grid-element.component.ts | 15 --- .../object-grid/object-grid.component.html | 2 +- .../object-grid/object-grid.component.ts | 2 + ...on-search-result-grid-element.component.ts | 2 +- ...ty-search-result-grid-element.component.ts | 2 +- ...-search-result-grid-element.component.html | 1 - ...-search-result-grid-element.component.scss | 12 -- ...arch-result-grid-element.component.spec.ts | 61 ---------- ...em-search-result-grid-element.component.ts | 20 --- ...arch-result-grid-element.component.spec.ts | 4 +- .../browse-entry-list-element.component.ts | 2 +- .../collection-list-element.component.ts | 2 +- .../community-list-element.component.ts | 2 +- .../item-list-element.component.html | 1 - .../item-list-element.component.scss | 0 .../item-list-element.component.spec.ts | 47 -------- .../item-list-element.component.ts | 21 ---- .../item-type-badge.component.ts | 2 +- .../item-metadata-list-element.component.html | 4 +- ...em-metadata-list-element.component.spec.ts | 2 +- ...my-dspace-result-list-element.component.ts | 4 +- ...my-dspace-result-list-element.component.ts | 3 +- ...my-dspace-result-list-element.component.ts | 5 +- ...my-dspace-result-list-element.component.ts | 4 +- ...my-dspace-result-list-element.component.ts | 2 +- .../object-list/object-list.component.html | 2 +- .../object-list/object-list.component.ts | 3 +- ...on-search-result-list-element.component.ts | 3 +- ...ty-search-result-list-element.component.ts | 3 +- ...-search-result-list-element.component.html | 2 - ...-search-result-list-element.component.scss | 0 ...arch-result-list-element.component.spec.ts | 60 --------- ...em-search-result-list-element.component.ts | 22 ---- ...-search-result-list-element.component.html | 26 ++-- src/app/shared/shared.module.ts | 11 +- .../simple/item-page.component.html | 2 +- 102 files changed, 452 insertions(+), 755 deletions(-) delete mode 100644 src/app/shared/object-grid/item-grid-element/item-grid-element.component.html delete mode 100644 src/app/shared/object-grid/item-grid-element/item-grid-element.component.scss delete mode 100644 src/app/shared/object-grid/item-grid-element/item-grid-element.component.spec.ts delete mode 100644 src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts delete mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html delete mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.scss delete mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts delete mode 100644 src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/item-list-element.component.html delete mode 100644 src/app/shared/object-list/item-list-element/item-list-element.component.scss delete mode 100644 src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts delete mode 100644 src/app/shared/object-list/item-list-element/item-list-element.component.ts delete mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html delete mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.scss delete mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts delete mode 100644 src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.html b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.html index e25c3c204f..03040ce8e0 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.html +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.html @@ -1,6 +1,6 @@
- +
diff --git a/src/app/+item-page/simple/item-page.component.html b/src/app/+item-page/simple/item-page.component.html index b6de496dc4..501e3e161e 100644 --- a/src/app/+item-page/simple/item-page.component.html +++ b/src/app/+item-page/simple/item-page.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html index 48eabf8451..0bc7d51244 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html @@ -1,5 +1,5 @@ - - + diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts index f02625e8c7..dcdfc1ccea 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts @@ -33,7 +33,7 @@ describe('MetadataRepresentationListComponent', () => { })); it(`should load ${representations.length} item-type-switcher components`, () => { - const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher')); + const fields = fixture.debugElement.queryAll(By.css('ds-listable-object-component-loader')); expect(fields.length).toBe(representations.length); }); diff --git a/src/app/+item-page/simple/related-items/related-items.component.html b/src/app/+item-page/simple/related-items/related-items.component.html index 4b284ad63c..0ff4742873 100644 --- a/src/app/+item-page/simple/related-items/related-items.component.html +++ b/src/app/+item-page/simple/related-items/related-items.component.html @@ -1,5 +1,5 @@ - - + diff --git a/src/app/+item-page/simple/related-items/related-items.component.spec.ts b/src/app/+item-page/simple/related-items/related-items.component.spec.ts index 1896f46015..90e4cadc93 100644 --- a/src/app/+item-page/simple/related-items/related-items.component.spec.ts +++ b/src/app/+item-page/simple/related-items/related-items.component.spec.ts @@ -45,7 +45,7 @@ describe('RelatedItemsComponent', () => { })); it(`should load ${mockItems.length} item-type-switcher components`, () => { - const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher')); + const fields = fixture.debugElement.queryAll(By.css('ds-listable-object-component-loader')); expect(fields.length).toBe(mockItems.length); }); diff --git a/src/app/+my-dspace-page/my-dspace-result.model.ts b/src/app/+my-dspace-page/my-dspace-result.model.ts index d300ed0bc8..1737aaec0a 100644 --- a/src/app/+my-dspace-page/my-dspace-result.model.ts +++ b/src/app/+my-dspace-page/my-dspace-result.model.ts @@ -16,4 +16,7 @@ export class MyDSpaceResult implements ListableObject { */ hitHighlights: MetadataMap; + getRenderType(): string { + return this.indexableObject.getRenderType() + 'MyDSpaceResult'; + } } diff --git a/src/app/+search-page/normalized-search-result.model.ts b/src/app/+search-page/normalized-search-result.model.ts index abb5f21250..8b1c015fef 100644 --- a/src/app/+search-page/normalized-search-result.model.ts +++ b/src/app/+search-page/normalized-search-result.model.ts @@ -1,13 +1,12 @@ import { autoserialize, inheritSerialization } from 'cerialize'; import { MetadataMap } from '../core/shared/metadata.models'; -import { ListableObject } from '../shared/object-collection/shared/listable-object.model'; import { NormalizedObject } from '../core/cache/models/normalized-object.model'; /** * Represents a normalized version of a search result object of a certain DSpaceObject */ @inheritSerialization(NormalizedObject) -export class NormalizedSearchResult implements ListableObject { +export class NormalizedSearchResult { /** * The UUID of the DSpaceObject that was found */ @@ -19,5 +18,4 @@ export class NormalizedSearchResult implements ListableObject { */ @autoserialize hitHighlights: MetadataMap; - } diff --git a/src/app/+search-page/search-page.module.ts b/src/app/+search-page/search-page.module.ts index 816633ec38..940ac45442 100644 --- a/src/app/+search-page/search-page.module.ts +++ b/src/app/+search-page/search-page.module.ts @@ -5,7 +5,6 @@ import { SharedModule } from '../shared/shared.module'; import { SearchPageRoutingModule } from './search-page-routing.module'; import { SearchPageComponent } from './search-page.component'; import { SearchResultsComponent } from './search-results/search-results.component'; -import { ItemSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component'; import { CommunitySearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component' import { CollectionSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component'; import { SearchSidebarComponent } from './search-sidebar/search-sidebar.component'; @@ -44,7 +43,6 @@ const components = [ SearchResultsComponent, SearchSidebarComponent, SearchSettingsComponent, - ItemSearchResultGridElementComponent, CollectionSearchResultGridElementComponent, CommunitySearchResultGridElementComponent, SearchFiltersComponent, @@ -85,7 +83,6 @@ const components = [ SearchConfigurationService ], entryComponents: [ - ItemSearchResultGridElementComponent, CollectionSearchResultGridElementComponent, CommunitySearchResultGridElementComponent, SearchFacetFilterComponent, diff --git a/src/app/+search-page/search-result.model.ts b/src/app/+search-page/search-result.model.ts index 0354edbc6b..0006426119 100644 --- a/src/app/+search-page/search-result.model.ts +++ b/src/app/+search-page/search-result.model.ts @@ -16,4 +16,7 @@ export class SearchResult implements ListableObject { */ hitHighlights: MetadataMap; + getRenderType(): string { + return this.indexableObject.getRenderType() + 'SearchResult'; + } } diff --git a/src/app/core/eperson/models/normalized-eperson.model.ts b/src/app/core/eperson/models/normalized-eperson.model.ts index bf644a83ef..28cdf12ee9 100644 --- a/src/app/core/eperson/models/normalized-eperson.model.ts +++ b/src/app/core/eperson/models/normalized-eperson.model.ts @@ -9,7 +9,7 @@ import { Group } from './group.model'; @mapsTo(EPerson) @inheritSerialization(NormalizedDSpaceObject) -export class NormalizedEPerson extends NormalizedDSpaceObject implements CacheableObject, ListableObject { +export class NormalizedEPerson extends NormalizedDSpaceObject implements CacheableObject { /** * A string representing the unique handle of this EPerson */ diff --git a/src/app/core/eperson/models/normalized-group.model.ts b/src/app/core/eperson/models/normalized-group.model.ts index 329ffb8adf..6530915154 100644 --- a/src/app/core/eperson/models/normalized-group.model.ts +++ b/src/app/core/eperson/models/normalized-group.model.ts @@ -8,7 +8,7 @@ import { Group } from './group.model'; @mapsTo(Group) @inheritSerialization(NormalizedDSpaceObject) -export class NormalizedGroup extends NormalizedDSpaceObject implements CacheableObject, ListableObject { +export class NormalizedGroup extends NormalizedDSpaceObject implements CacheableObject { /** * List of Groups that this Group belong to diff --git a/src/app/core/metadata/metadata-field.model.ts b/src/app/core/metadata/metadata-field.model.ts index 288934e52d..e451398fab 100644 --- a/src/app/core/metadata/metadata-field.model.ts +++ b/src/app/core/metadata/metadata-field.model.ts @@ -50,4 +50,8 @@ export class MetadataField implements ListableObject { } return key; } + + getRenderType(): string { + return this.constructor.name; + } } diff --git a/src/app/core/metadata/metadata-schema.model.ts b/src/app/core/metadata/metadata-schema.model.ts index bc05e475cc..6859f580c0 100644 --- a/src/app/core/metadata/metadata-schema.model.ts +++ b/src/app/core/metadata/metadata-schema.model.ts @@ -26,4 +26,8 @@ export class MetadataSchema implements ListableObject { * The namespace of this metadata schema */ namespace: string; + + getRenderType(): string { + return this.constructor.name; + } } diff --git a/src/app/core/metadata/normalized-metadata-field.model.ts b/src/app/core/metadata/normalized-metadata-field.model.ts index c6b2ee32f8..075dda79d2 100644 --- a/src/app/core/metadata/normalized-metadata-field.model.ts +++ b/src/app/core/metadata/normalized-metadata-field.model.ts @@ -10,7 +10,7 @@ import { MetadataSchema } from './metadata-schema.model'; */ @mapsTo(MetadataField) @inheritSerialization(NormalizedObject) -export class NormalizedMetadataField extends NormalizedObject implements ListableObject { +export class NormalizedMetadataField extends NormalizedObject { /** * The identifier of this normalized metadata field diff --git a/src/app/core/metadata/normalized-metadata-schema.model.ts b/src/app/core/metadata/normalized-metadata-schema.model.ts index 47c7233d81..1aa5609090 100644 --- a/src/app/core/metadata/normalized-metadata-schema.model.ts +++ b/src/app/core/metadata/normalized-metadata-schema.model.ts @@ -9,7 +9,7 @@ import { MetadataSchema } from './metadata-schema.model'; */ @mapsTo(MetadataSchema) @inheritSerialization(NormalizedObject) -export class NormalizedMetadataSchema extends NormalizedObject implements ListableObject { +export class NormalizedMetadataSchema extends NormalizedObject { /** * The unique identifier for this schema */ diff --git a/src/app/core/registry/registry.service.ts b/src/app/core/registry/registry.service.ts index 206426588e..3c6de36492 100644 --- a/src/app/core/registry/registry.service.ts +++ b/src/app/core/registry/registry.service.ts @@ -400,7 +400,7 @@ export class RegistryService { distinctUntilChanged() ); - const serializedSchema = new DSpaceRESTv2Serializer(getMapsToType(MetadataSchema.type)).serialize(schema as NormalizedMetadataSchema); + const serializedSchema = new DSpaceRESTv2Serializer(getMapsToType(MetadataSchema.type)).serialize(schema); const request$ = endpoint$.pipe( take(1), diff --git a/src/app/core/shared/browse-entry.model.ts b/src/app/core/shared/browse-entry.model.ts index d5d4093c81..067fac2bff 100644 --- a/src/app/core/shared/browse-entry.model.ts +++ b/src/app/core/shared/browse-entry.model.ts @@ -6,7 +6,7 @@ import { ResourceType } from './resource-type'; * Class object representing a browse entry * This class is not normalized because browse entries do not have self links */ -export class BrowseEntry implements ListableObject, TypedObject { +export class BrowseEntry implements ListableObject { static type = new ResourceType('browseEntry'); /** @@ -28,4 +28,8 @@ export class BrowseEntry implements ListableObject, TypedObject { * The count of this browse entry */ count: number; + + getRenderType(): string { + return (this as any).type.value; + } } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 26f76c5ce2..0a22315598 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -146,4 +146,7 @@ export class DSpaceObject implements CacheableObject, ListableObject { }); } + getRenderType(): string { + return this.constructor.name; + } } diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index a3e625c022..28a889a18f 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -110,4 +110,11 @@ export class Item extends DSpaceObject { })); } + getRenderType(): string { + const entityType = this.firstMetadataValue('relationship.type'); + if (isNotEmpty(entityType)) { + return entityType; + } + return 'Publication'; + } } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts index db13b3592c..6619694f88 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts @@ -1,11 +1,10 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; -import { JournalIssueSearchResultGridElementComponent } from './journal-issue-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; +import { JournalIssueSearchResultGridElementComponent } from './journal-issue-search-result-grid-element.component'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts index 07ffc7bdc0..bcdde289e0 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts @@ -1,11 +1,10 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; -import { JournalVolumeSearchResultGridElementComponent } from './journal-volume-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; +import { JournalVolumeSearchResultGridElementComponent } from './journal-volume-search-result-grid-element.component'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts index 94e2e7fd68..1ce0aa2436 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts @@ -1,11 +1,10 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; -import { JournalSearchResultGridElementComponent } from './journal-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; +import { JournalSearchResultGridElementComponent } from './journal-search-result-grid-element.component'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts index ec61615c9a..d1cf67a07e 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts @@ -5,7 +5,6 @@ import { JournalIssueListElementComponent } from './journal-issue-list-element.c import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let journalIssueListElementComponent: JournalIssueListElementComponent; @@ -51,7 +50,6 @@ describe('JournalIssueListElementComponent', () => { TestBed.configureTestingModule({ declarations: [ JournalIssueListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts index 21d28c7fe8..2ab4c1eaed 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts @@ -5,7 +5,6 @@ import { JournalVolumeListElementComponent } from './journal-volume-list-element import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let journalVolumeListElementComponent: JournalVolumeListElementComponent; @@ -51,7 +50,6 @@ describe('JournalVolumeListElementComponent', () => { TestBed.configureTestingModule({ declarations: [ JournalVolumeListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html index 2d9faadcdc..e0d6e4053a 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html @@ -1,4 +1,5 @@ + ; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'publicationvolume.volumeNumber': [ + { + language: 'en_US', + value: '1234' + } + ], + 'publicationissue.issueNumber': [ + { + language: 'en_US', + value: '5678' + } + ] } - ], - 'publicationvolume.volumeNumber': [ - { - language: 'en_US', - value: '1234' + }) + }); + +const mockItemWithoutMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ], - 'publicationissue.issueNumber': [ - { - language: 'en_US', - value: '5678' - } - ] - } -}); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); + }) + }); describe('JournalIssueListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ JournalIssueSearchResultListElementComponent , TruncatePipe], + declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], - schemas: [ NO_ERRORS_SCHEMA ] + schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(JournalIssueSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html index 8a1ae65a22..f3c0173bde 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html @@ -1,4 +1,5 @@ + ; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'journal.title': [ + { + language: 'en_US', + value: 'This is just another journal title' + } + ], + 'publicationvolume.volumeNumber': [ + { + language: 'en_US', + value: '1234' + } + ] } - ], - 'journal.title': [ - { - language: 'en_US', - value: 'This is just another journal title' + }) + }); +const mockItemWithoutMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ], - 'publicationvolume.volumeNumber': [ - { - language: 'en_US', - value: '1234' - } - ] - } -}); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); + }) + }); describe('JournalVolumeListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ JournalVolumeSearchResultListElementComponent , TruncatePipe], + declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], - schemas: [ NO_ERRORS_SCHEMA ] + schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(JournalVolumeSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html index d1dfff123a..629149b197 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html @@ -1,4 +1,5 @@ + ; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativeworkseries.issn': [ + { + language: 'en_US', + value: '1234' + } + ] } - ], - 'creativeworkseries.issn': [ - { - language: 'en_US', - value: '1234' + }) + }); + +const mockItemWithoutMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ] + }) } -}); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +); describe('JournalListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ JournalSearchResultListElementComponent , TruncatePipe], + declarations: [JournalSearchResultListElementComponent, TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], - schemas: [ NO_ERRORS_SCHEMA ] + schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(JournalSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts index f854eaa273..579161f940 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts @@ -1,11 +1,10 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; -import { OrgunitSearchResultGridElementComponent } from './orgunit-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { OrgunitSearchResultGridElementComponent } from './orgunit-search-result-grid-element.component'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts index 752630c7b9..6a5c79c770 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts @@ -1,11 +1,10 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; -import { PersonSearchResultGridElementComponent } from './person-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; +import { PersonSearchResultGridElementComponent } from './person-search-result-grid-element.component'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts index acf52224be..64fedf155d 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts @@ -1,11 +1,10 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; -import { ProjectSearchResultGridElementComponent } from './project-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; -import { PaginatedList } from '../../../../core/data/paginated-list'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; +import { ProjectSearchResultGridElementComponent } from './project-search-result-grid-element.component'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html index 0bb94c7d24..b833fa735b 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html @@ -1,4 +1,5 @@ + ; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'A description about the OrgUnit' + } + ] } - ], - 'dc.description': [ - { - language: 'en_US', - value: 'A description about the OrgUnit' + }) + }); +const mockItemWithoutMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ] - } -}); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); + }) + }); describe('OrgUnitListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html index 77f29d25ff..3e1bbbcc2b 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html @@ -1,4 +1,5 @@ + ; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'person.jobTitle': [ + { + language: 'en_US', + value: 'Developer' + } + ] } - ], - 'person.jobTitle': [ - { - language: 'en_US', - value: 'Developer' + }) + }); +const mockItemWithoutMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ] - } -}); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); + }) + }); describe('PersonListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ PersonSearchResultListElementComponent , TruncatePipe], + declarations: [PersonSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} } ], - schemas: [ NO_ERRORS_SCHEMA ] + schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(PersonSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html index fab5971f9e..1715c7eb2e 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html @@ -1,16 +1,18 @@ - - - - - - - - - - + + + + + + + + + + + + - - - + + + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss index 1d0786105c..e69de29bb2 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss @@ -1 +0,0 @@ -@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts index 816467727e..e08e25eb69 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts @@ -1,55 +1,62 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { ProjectSearchResultListElementComponent } from './project-list-element.component'; import { of as observableOf } from 'rxjs'; -import { Item } from '../../../../core/shared/item.model'; -import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; -import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { ProjectSearchResultListElementComponent } from './project-search-result-list-element.component'; +import { Item } from '../../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; let projectListElementComponent: ProjectSearchResultListElementComponent; let fixture: ComponentFixture; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + // 'project.identifier.status': [ + // { + // language: 'en_US', + // value: 'A status about the project' + // } + // ] } - ], - // 'project.identifier.status': [ - // { - // language: 'en_US', - // value: 'A status about the project' - // } - // ] - } -}); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' + }) + }); + +const mockItemWithoutMetadata: ItemSearchResult = Object.assign( + new ItemSearchResult(), + { + indexableObject: Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ] - } -}); + }) + }); describe('ProjectListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ProjectSearchResultListElementComponent , TruncatePipe], + declarations: [ProjectSearchResultListElementComponent, TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], - schemas: [ NO_ERRORS_SCHEMA ] + schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ProjectSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); diff --git a/src/app/shared/browse-by/browse-by.component.html b/src/app/shared/browse-by/browse-by.component.html index bad9f3fe8c..f7cd7e0d35 100644 --- a/src/app/shared/browse-by/browse-by.component.html +++ b/src/app/shared/browse-by/browse-by.component.html @@ -25,7 +25,7 @@
  • - +
diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.html b/src/app/shared/dso-selector/dso-selector/dso-selector.component.html index 662144823d..e2eda4dcfd 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.html +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.html @@ -15,6 +15,6 @@ class="list-group-item list-group-item-action border-0 list-entry" title="{{ listEntry.indexableObject.name }}" (click)="onSelect.emit(listEntry.indexableObject)" #listEntryElement> - +
diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 04501e4923..32149e29dc 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -19,6 +19,7 @@ import { RemoteData } from '../../../core/data/remote-data'; import { PaginatedList } from '../../../core/data/paginated-list'; import { SearchResult } from '../../../+search-page/search-result.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-dso-selector', @@ -31,7 +32,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; * The user can search the list by using the input field */ export class DSOSelectorComponent implements OnInit { - + viewMode = ViewMode.ListElement; /** * The initially selected DSO's uuid */ diff --git a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html index 2b605ccdc6..3e304d9eb3 100644 --- a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html +++ b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html @@ -16,7 +16,7 @@
diff --git a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts index bb1272f076..e1e9d18c8f 100644 --- a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts +++ b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts @@ -2,6 +2,7 @@ import { Component, forwardRef, Input } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { InputSuggestionsComponent } from '../input-suggestions.component'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; +import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-dso-input-suggestions', @@ -22,6 +23,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; * Component representing a form with a autocomplete functionality for DSpaceObjects */ export class DsoInputSuggestionsComponent extends InputSuggestionsComponent { + viewMode = ViewMode.ListElement; /** * The suggestions that should be shown */ diff --git a/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts b/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts index 92724a762f..e77b9295df 100644 --- a/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts +++ b/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts @@ -8,4 +8,7 @@ import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspa */ @searchResultFor(Item, MyDSpaceConfigurationValueType.Workspace) export class ItemMyDSpaceResult extends SearchResult { + getRenderType(): string { + return ItemMyDSpaceResult.name; + } } diff --git a/src/app/shared/object-collection/shared/listable-object.model.ts b/src/app/shared/object-collection/shared/listable-object.model.ts index 07c626cda2..62ab24ae33 100644 --- a/src/app/shared/object-collection/shared/listable-object.model.ts +++ b/src/app/shared/object-collection/shared/listable-object.model.ts @@ -1 +1,5 @@ -export interface ListableObject {} +import { TypedObject } from '../../../core/cache/object-cache.reducer'; + +export interface ListableObject extends TypedObject { + getRenderType(): string; +} diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html index d41303d462..ef9a817424 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 149425c157..4651a342ac 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -5,24 +5,23 @@ import { Context } from '../../../../core/shared/context.model'; import { getListableObjectComponent } from './listable-object.decorator'; import { GenericConstructor } from '../../../../core/shared/generic-constructor'; import { ListableObjectDirective } from './listable-object.directive'; -import { hasValue, isNotEmpty } from '../../../empty.util'; @Component({ selector: 'ds-listable-object-component-loader', - styleUrls: ['./listable-object-component-loader.component.scss'], + // styleUrls: ['./listable-object-component-loader.component.scss'], templateUrl: './listable-object-component-loader.component.html' }) /** * Component for determining what component to use depending on the item's relationship type (relationship.type) */ export class ListableObjectComponentLoaderComponent implements OnInit { - - @Input() type?: string; /** * The item or metadata to determine the component for */ @Input() object: ListableObject; + //TODO DO SOMETHING WITH THIS + @Input() index: number; /** * The preferred view-mode to display */ @@ -49,9 +48,6 @@ export class ListableObjectComponentLoaderComponent implements OnInit { * @returns {string} */ private getComponent(): GenericConstructor { - if (isNotEmpty(this.type)) { - return getListableObjectComponent(this.type, this.viewMode) - } - return getListableObjectComponent(this.object.constructor as GenericConstructor, this.viewMode); + return getListableObjectComponent(this.object.getRenderType(), this.viewMode) } } diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts index 2e30c0b761..092bf8068f 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts @@ -16,7 +16,7 @@ const listElementMap = new Map(); * @param type * @param viewMode */ -export function listableObjectComponent(objectType: GenericConstructor | string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { +export function listableObjectComponent(objectType: string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { return function decorator(component: any) { if (hasNoValue(objectType)) { return; diff --git a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts index f72d1c9e51..d6819b04da 100644 --- a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts +++ b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts @@ -1,10 +1,11 @@ import { Component, Inject, Input } from '@angular/core'; import { ListableObject } from '../listable-object.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @Component({ selector: 'ds-abstract-object-element', template: ``, }) -export class AbstractListableElementComponent { +export class AbstractListableElementComponent { @Input() object: T; } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts index 0c47a239cc..91ddbaf09a 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts @@ -13,6 +13,7 @@ import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/cla import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { Context } from '../../../../core/shared/context.model'; /** * This component renders claimed task object for the mydspace result in the detail view. @@ -23,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './claimed-my-dspace-result-detail-element.component.html' }) -@listableObjectComponent(ClaimedTaskMyDSpaceResult, ViewMode.DetailedListElement) -@listableObjectComponent(ClaimedTask, ViewMode.DetailedListElement) +@listableObjectComponent(ClaimedTaskMyDSpaceResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(ClaimedTask.name, ViewMode.DetailedListElement) export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts index 2b50dd0819..3788a0da4c 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts @@ -16,7 +16,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './item-my-dspace-result-detail-element.component.html' }) -@listableObjectComponent(ItemMyDSpaceResult, ViewMode.DetailedListElement) +@listableObjectComponent(ItemMyDSpaceResult.name, ViewMode.DetailedListElement) export class ItemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts index 20fe3dcb2c..e9ff84b7cf 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts @@ -22,8 +22,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './pool-my-dspace-result-detail-element.component.html', }) -@listableObjectComponent(PoolTaskMyDSpaceResult, ViewMode.DetailedListElement) -@listableObjectComponent(PoolTask, ViewMode.DetailedListElement) +@listableObjectComponent(PoolTaskMyDSpaceResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(PoolTask.name, ViewMode.DetailedListElement) export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts index ec83c7f6d0..4d6b047f56 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts @@ -22,8 +22,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './workflowitem-my-dspace-result-detail-element.component.html', }) -@listableObjectComponent(WorkflowitemMyDSpaceResult, ViewMode.DetailedListElement) -@listableObjectComponent(WorkflowItem, ViewMode.DetailedListElement) +@listableObjectComponent(WorkflowitemMyDSpaceResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(WorkflowItem.name, ViewMode.DetailedListElement) export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts index afb3107fa4..e9cc6967e6 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts @@ -10,7 +10,6 @@ import { WorkspaceitemMyDSpaceResult } from '../../../object-collection/shared/w import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; -import { ListableObject } from '../../../object-collection/shared/listable-object.model'; import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; @@ -25,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './workspaceitem-my-dspace-result-detail-element.component.html', }) -@listableObjectComponent(WorkspaceitemMyDSpaceResult, ViewMode.DetailedListElement) -@listableObjectComponent(WorkspaceItem, ViewMode.DetailedListElement) +@listableObjectComponent(WorkspaceitemMyDSpaceResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(WorkspaceItem.name, ViewMode.DetailedListElement) export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/object-detail.component.html b/src/app/shared/object-detail/object-detail.component.html index a57a23027e..400781b6d2 100644 --- a/src/app/shared/object-detail/object-detail.component.html +++ b/src/app/shared/object-detail/object-detail.component.html @@ -14,7 +14,7 @@
- +
diff --git a/src/app/shared/object-detail/object-detail.component.ts b/src/app/shared/object-detail/object-detail.component.ts index 3187a2cd1b..24df1bf504 100644 --- a/src/app/shared/object-detail/object-detail.component.ts +++ b/src/app/shared/object-detail/object-detail.component.ts @@ -15,6 +15,7 @@ import { fadeIn } from '../animations/fade'; import { ListableObject } from '../object-collection/shared/listable-object.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; +import { ViewMode } from '../../core/shared/view-mode.model'; /** * This component renders a paginated set of results in the detail view. @@ -28,6 +29,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o animations: [fadeIn] }) export class ObjectDetailComponent { + viewMode = ViewMode.DetailedListElement; /** * Pagination options object diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts index 1261cd6dfd..a113e0dffd 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './collection-grid-element.component.html' }) -@listableObjectComponent(Collection, ViewMode.GridElement) +@listableObjectComponent(Collection.name, ViewMode.GridElement) export class CollectionGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts index 67d4ac663c..498222466d 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './community-grid-element.component.html' }) -@listableObjectComponent(Community, ViewMode.GridElement) +@listableObjectComponent(Community.name, ViewMode.GridElement) export class CommunityGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html deleted file mode 100644 index 21ee7968ca..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.scss b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.scss deleted file mode 100644 index 8b13789179..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.scss +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.spec.ts deleted file mode 100644 index 7b286cc415..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.spec.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { ItemGridElementComponent } from './item-grid-element.component'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { TruncatePipe } from '../../utils/truncate.pipe'; -import { Item } from '../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs'; - -let itemGridElementComponent: ItemGridElementComponent; -let fixture: ComponentFixture; - -const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.contributor.author': [ - { - language: 'en_US', - value: 'Smith, Donald' - } - ], - 'dc.date.issued': [ - { - language: null, - value: '2015-06-26' - } - ] - } -}); -const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ], - 'dc.type': [ - { - language: null, - value: 'Article' - } - ] - } -}); - -describe('ItemGridElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ItemGridElementComponent , TruncatePipe], - providers: [ - { provide: 'objectElementProvider', useValue: {mockItemWithAuthorAndDate}} - ], - - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(ItemGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(ItemGridElementComponent); - itemGridElementComponent = fixture.componentInstance; - - })); - - describe('When the item has an author', () => { - beforeEach(() => { - itemGridElementComponent.object = mockItemWithAuthorAndDate; - fixture.detectChanges(); - }); - - it('should show the author paragraph', () => { - const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors')); - expect(itemAuthorField).not.toBeNull(); - }); - }); - - describe('When the item has no author', () => { - beforeEach(() => { - itemGridElementComponent.object = mockItemWithoutAuthorAndDate; - fixture.detectChanges(); - }); - - it('should not show the author paragraph', () => { - const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors')); - expect(itemAuthorField).toBeNull(); - }); - }); - - describe('When the item has an issuedate', () => { - beforeEach(() => { - itemGridElementComponent.object = mockItemWithAuthorAndDate; - fixture.detectChanges(); - }); - - it('should show the issuedate span', () => { - const itemAuthorField = fixture.debugElement.query(By.css('span.item-date')); - expect(itemAuthorField).not.toBeNull(); - }); - }); - - describe('When the item has no issuedate', () => { - beforeEach(() => { - itemGridElementComponent.object = mockItemWithoutAuthorAndDate; - fixture.detectChanges(); - }); - - it('should not show the issuedate span', () => { - const dateField = fixture.debugElement.query(By.css('span.item-date')); - expect(dateField).toBeNull(); - }); - }); -}); diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts deleted file mode 100644 index e146370752..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component } from '@angular/core'; - -import { Item } from '../../../core/shared/item.model'; -import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { ViewMode } from '../../../core/shared/view-mode.model'; -import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; - -@Component({ - selector: 'ds-item-grid-element', - styleUrls: ['./item-grid-element.component.scss'], - templateUrl: './item-grid-element.component.html' -}) - -@listableObjectComponent(Item, ViewMode.GridElement) -export class ItemGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/object-grid.component.html b/src/app/shared/object-grid/object-grid.component.html index 9d1f8f5ea2..c5cd34608f 100644 --- a/src/app/shared/object-grid/object-grid.component.html +++ b/src/app/shared/object-grid/object-grid.component.html @@ -13,7 +13,7 @@
- +
diff --git a/src/app/shared/object-grid/object-grid.component.ts b/src/app/shared/object-grid/object-grid.component.ts index e539ca5714..d3bfbb8e58 100644 --- a/src/app/shared/object-grid/object-grid.component.ts +++ b/src/app/shared/object-grid/object-grid.component.ts @@ -20,6 +20,7 @@ import { HostWindowService, WidthCategory } from '../host-window.service'; import { ListableObject } from '../object-collection/shared/listable-object.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; +import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -31,6 +32,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o }) export class ObjectGridComponent implements OnInit { + viewMode = ViewMode.ListElement; @Input() config: PaginationComponentOptions; @Input() sortConfig: SortOptions; diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts index 1d0f47b70b..983b895e9c 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts @@ -12,5 +12,5 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'collection-search-result-grid-element.component.html' }) -@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement) +@listableObjectComponent(CollectionSearchResult.name, ViewMode.GridElement) export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent {} diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts index 806e6a44e3..e8e19c27d8 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts @@ -11,7 +11,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'community-search-result-grid-element.component.html' }) -@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement) +@listableObjectComponent(CommunitySearchResult.name, ViewMode.GridElement) export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html deleted file mode 100644 index 36740cf48f..0000000000 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.scss b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.scss deleted file mode 100644 index d61f3ccf55..0000000000 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.scss +++ /dev/null @@ -1,12 +0,0 @@ -.card { - a > div { - position: relative; - .thumbnail-overlay { - height: 100%; - position: absolute; - top: 0; - width: 100%; - background-color: map-get($theme-colors, primary); - } - } -} diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts deleted file mode 100644 index d757e87583..0000000000 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.spec.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { of as observableOf } from 'rxjs'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { TruncatePipe } from '../../../utils/truncate.pipe'; -import { Item } from '../../../../core/shared/item.model'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; - -let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent; -let fixture: ComponentFixture; - -const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), -}; - -const type = 'authorOfPublication'; - -const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult(); -mockItemWithRelationshipType.hitHighlights = {}; -mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'relationship.type': [ - { - language: 'en_US', - value: type - } - ] - } -}); - -describe('ItemSearchResultGridElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [ItemSearchResultGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - { provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) } - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemSearchResultGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(ItemSearchResultGridElementComponent); - itemSearchResultGridElementComponent = fixture.componentInstance; - })); - - it('should show send the object to item-type-switcher using viewMode "Card"', () => { - const itemTypeSwitcherComp = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance; - expect(itemTypeSwitcherComp.object).toBe(mockItemWithRelationshipType); - expect(itemTypeSwitcherComp.viewMode).toEqual(ViewMode.GridElement); - }); -}); diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts deleted file mode 100644 index f90a9f6799..0000000000 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component } from '@angular/core'; - -import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; -import { Item } from '../../../../core/shared/item.model'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { focusShadow } from '../../../animations/focus'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; - -@Component({ - selector: 'ds-item-search-result-grid-element', - styleUrls: ['../search-result-grid-element.component.scss', 'item-search-result-grid-element.component.scss'], - templateUrl: 'item-search-result-grid-element.component.html', - animations: [focusShadow], -}) - -@listableObjectComponent(ItemSearchResult, ViewMode.GridElement) -export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent { - viewMode = ViewMode.GridElement; -} \ No newline at end of file diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts index 0245e0699e..63ee848aa0 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts @@ -4,14 +4,13 @@ import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { PublicationSearchResultGridElementComponent } from './publication-grid-element.component'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { PublicationSearchResultGridElementComponent } from './publication-search-result-grid-element.component'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; @@ -85,7 +84,6 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet declarations: [component, TruncatePipe], providers: [ { provide: TruncatableService, useValue: truncatableServiceStub }, - {provide: ITEM, useValue: searchResultWithoutMetadata} ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(component, { diff --git a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts index 2ebfc2713e..ed61badbbd 100644 --- a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts +++ b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts @@ -14,5 +14,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable /** * This component is automatically used to create a list view for BrowseEntry objects when used in ObjectCollectionComponent */ -@listableObjectComponent(BrowseEntry, ViewMode.ListElement) +@listableObjectComponent(BrowseEntry.name, ViewMode.ListElement) export class BrowseEntryListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts index 685a990409..7d57044ba4 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './collection-list-element.component.html' }) -@listableObjectComponent(Collection, ViewMode.ListElement) +@listableObjectComponent(Collection.name, ViewMode.ListElement) export class CollectionListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/community-list-element/community-list-element.component.ts b/src/app/shared/object-list/community-list-element/community-list-element.component.ts index 4581c2c0da..4c3e8bbd6f 100644 --- a/src/app/shared/object-list/community-list-element/community-list-element.component.ts +++ b/src/app/shared/object-list/community-list-element/community-list-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './community-list-element.component.html' }) -@listableObjectComponent(Community, ViewMode.ListElement) +@listableObjectComponent(Community.name, ViewMode.ListElement) export class CommunityListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.html b/src/app/shared/object-list/item-list-element/item-list-element.component.html deleted file mode 100644 index 21ee7968ca..0000000000 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-list-element.component.scss deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts deleted file mode 100644 index 2c0c8b0aa2..0000000000 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { ItemListElementComponent } from './item-list-element.component'; -import { Item } from '../../../core/shared/item.model'; -import { RemoteData } from '../../../core/data/remote-data'; -import { PaginatedList } from '../../../core/data/paginated-list'; -import { PageInfo } from '../../../core/shared/page-info.model'; -import { By } from '@angular/platform-browser'; -import { createRelationshipsObservable } from '../../../+item-page/simple/item-types/shared/item.component.spec'; -import { of as observableOf } from 'rxjs'; -import { createSuccessfulRemoteDataObject$ } from '../../testing/utils'; - -const mockItem: Item = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: [], - relationships: createRelationshipsObservable() -}); - -describe('ItemListElementComponent', () => { - let comp: ItemListElementComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [], - declarations: [ItemListElementComponent], - providers: [ - { provide: 'objectElementProvider', useValue: mockItem } - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemListElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(ItemListElementComponent); - comp = fixture.componentInstance; - fixture.detectChanges(); - })); - - it('should call an item-type-switcher component and pass the item', () => { - const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance; - expect(itemTypeSwitcher.object).toBe(mockItem); - }); - -}); diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.ts deleted file mode 100644 index e41a92f36d..0000000000 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Component } from '@angular/core'; - -import { Item } from '../../../core/shared/item.model'; -import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { ViewMode } from '../../../core/shared/view-mode.model'; -import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; - -@Component({ - selector: 'ds-item-list-element', - styleUrls: ['./item-list-element.component.scss'], - templateUrl: './item-list-element.component.html' -}) - -/** - * The component used to list items depending on type - * Uses item-type-switcher to determine which components to use for displaying the list - */ -@listableObjectComponent(Item, ViewMode.ListElement) -export class ItemListElementComponent extends AbstractListableElementComponent { - viewMode = ViewMode.ListElement; -} diff --git a/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts b/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts index 9ffba33758..a4e12959f4 100644 --- a/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts +++ b/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts @@ -8,5 +8,5 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; templateUrl: './item-type-badge.component.html' }) export class ItemTypeBadgeComponent { - @Input() object: SearchResult; + @Input() object: DSpaceObject; } diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html index 764fdc1064..4ecb8c0c51 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html @@ -1,2 +1,2 @@ - - + + diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts index 2aa54bae64..e89602775e 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemMetadataListElementComponent', () => { })); it('should call an item-type-switcher component and pass the item-metadata-representation', () => { - const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).nativeElement; + const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-listable-object-component-loader')).nativeElement; expect(itemTypeSwitcher.object).toBe(mockItemMetadataRepresentation); }); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts index 68eb27c93a..bef18a5c1a 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts @@ -24,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) -@listableObjectComponent(ClaimedTaskMyDSpaceResult, ViewMode.ListElement) -@listableObjectComponent(ClaimedTask, ViewMode.ListElement) +@listableObjectComponent(ClaimedTaskMyDSpaceResult.name, ViewMode.ListElement) +@listableObjectComponent(ClaimedTask.name, ViewMode.ListElement) export class ClaimedMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts index 8d3fd00eaa..5304138587 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts @@ -6,6 +6,7 @@ import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-ds import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { Context } from '../../../../core/shared/context.model'; /** * This component renders item object for the mydspace result in the list view. @@ -16,7 +17,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './item-my-dspace-result-list-element.component.html' }) -@listableObjectComponent(ItemMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement, Context.Submission) export class ItemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts index 1f9499f6aa..46dfd583e0 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts @@ -13,6 +13,7 @@ import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; /** * This component renders pool task object for the mydspace result in the list view. @@ -23,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './pool-my-dspace-result-list-element.component.html', }) -@listableObjectComponent(PoolTaskMyDSpaceResult, ViewMode.ListElement) -@listableObjectComponent(PoolTask, ViewMode.ListElement) +@listableObjectComponent(PoolTaskMyDSpaceResult.name, ViewMode.ListElement) +@listableObjectComponent(PoolTask.name, ViewMode.ListElement) export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent implements OnInit { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts index 5ec7572984..97c1695c29 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts @@ -22,8 +22,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './workflowitem-my-dspace-result-list-element.component.html', }) -@listableObjectComponent(WorkflowitemMyDSpaceResult, ViewMode.ListElement) -@listableObjectComponent(WorkflowItem, ViewMode.ListElement) +@listableObjectComponent(WorkflowitemMyDSpaceResult.name, ViewMode.ListElement) +@listableObjectComponent(WorkflowItem.name, ViewMode.ListElement) export class WorkflowitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts index e88ea54703..a886e90737 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts @@ -22,7 +22,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: './workspaceitem-my-dspace-result-list-element.component.html', }) -@listableObjectComponent(WorkspaceitemMyDSpaceResult, ViewMode.ListElement) +@listableObjectComponent(WorkspaceitemMyDSpaceResult.name, ViewMode.ListElement) export class WorkspaceitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { /** diff --git a/src/app/shared/object-list/object-list.component.html b/src/app/shared/object-list/object-list.component.html index 1fdc06d5bf..b19daa035a 100644 --- a/src/app/shared/object-list/object-list.component.html +++ b/src/app/shared/object-list/object-list.component.html @@ -12,7 +12,7 @@ (paginationChange)="onPaginationChange($event)">
  • - +
diff --git a/src/app/shared/object-list/object-list.component.ts b/src/app/shared/object-list/object-list.component.ts index afc376034f..cf4728464a 100644 --- a/src/app/shared/object-list/object-list.component.ts +++ b/src/app/shared/object-list/object-list.component.ts @@ -12,6 +12,7 @@ import { RemoteData } from '../../core/data/remote-data'; import { fadeIn } from '../animations/fade'; import { ListableObject } from '../object-collection/shared/listable-object.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; +import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -22,7 +23,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o animations: [fadeIn] }) export class ObjectListComponent { - + viewMode = ViewMode.ListElement; @Input() config: PaginationComponentOptions; @Input() sortConfig: SortOptions; @Input() hasBorder = false; diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts index 384e1c1f81..1a678dddb7 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts @@ -6,6 +6,7 @@ import { Collection } from '../../../../core/shared/collection.model'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { BrowseEntry } from '../../../../core/shared/browse-entry.model'; @Component({ selector: 'ds-collection-search-result-list-element', @@ -13,5 +14,5 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'collection-search-result-list-element.component.html' }) -@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement) +@listableObjectComponent(CollectionSearchResult.name, ViewMode.ListElement) export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent {} diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts index 3281e380e4..fd3bba85e9 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts @@ -6,6 +6,7 @@ import { Community } from '../../../../core/shared/community.model'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { BrowseEntry } from '../../../../core/shared/browse-entry.model'; @Component({ selector: 'ds-community-search-result-list-element', @@ -13,7 +14,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'community-search-result-list-element.component.html' }) -@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement) +@listableObjectComponent(CommunitySearchResult.name, ViewMode.ListElement) export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html deleted file mode 100644 index 901ce441bf..0000000000 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.scss b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.scss deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts deleted file mode 100644 index 8f41018404..0000000000 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { of as observableOf } from 'rxjs'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { TruncatePipe } from '../../../utils/truncate.pipe'; -import { Item } from '../../../../core/shared/item.model'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { TranslateModule } from '@ngx-translate/core'; - -let itemSearchResultListElementComponent: ItemSearchResultListElementComponent; -let fixture: ComponentFixture; - -const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), -}; - -const type = 'authorOfPublication'; - -const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult(); -mockItemWithRelationshipType.hitHighlights = {}; -mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'relationship.type': [ - { - language: 'en_US', - value: type - } - ] - } -}); - -describe('ItemSearchResultListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot(), NoopAnimationsModule], - declarations: [ItemSearchResultListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - { provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) } - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemSearchResultListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(ItemSearchResultListElementComponent); - itemSearchResultListElementComponent = fixture.componentInstance; - })); - - it('should show a badge on top of the list element', () => { - const badge = fixture.debugElement.query(By.css('ds-item-type-badge')).componentInstance; - expect(badge.object).toBe(mockItemWithRelationshipType); - }); -}); diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts deleted file mode 100644 index 0b25443454..0000000000 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component } from '@angular/core'; -import { Item } from '../../../../core/shared/item.model'; -import { focusBackground } from '../../../animations/focus'; - -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { SearchResultListElementComponent } from '../search-result-list-element.component'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; - -@Component({ - selector: 'ds-item-search-result-list-element', - styleUrls: ['../search-result-list-element.component.scss', 'item-search-result-list-element.component.scss'], - templateUrl: 'item-search-result-list-element.component.html', - animations: [focusBackground], - -}) - -@listableObjectComponent(ItemSearchResult, ViewMode.ListElement) -export class ItemSearchResultListElementComponent extends SearchResultListElementComponent { - viewMode = ViewMode.ListElement; - -} diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html index 2d42fb611d..7fbb2c3c79 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html @@ -1,12 +1,14 @@ - - - + + + + + (, , ) -
- - -
-
+
+ + +
+
\ No newline at end of file diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 8aa5bf0fdd..187de7726c 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -22,12 +22,10 @@ import { ConsolePipe } from './utils/console.pipe'; import { CollectionListElementComponent } from './object-list/collection-list-element/collection-list-element.component'; import { CommunityListElementComponent } from './object-list/community-list-element/community-list-element.component'; -import { ItemListElementComponent } from './object-list/item-list-element/item-list-element.component'; import { SearchResultListElementComponent } from './object-list/search-result-list-element/search-result-list-element.component'; import { ObjectListComponent } from './object-list/object-list.component'; import { CollectionGridElementComponent } from './object-grid/collection-grid-element/collection-grid-element.component'; import { CommunityGridElementComponent } from './object-grid/community-grid-element/community-grid-element.component'; -import { ItemGridElementComponent } from './object-grid/item-grid-element/item-grid-element.component'; import { AbstractListableElementComponent } from './object-collection/shared/object-collection-element/abstract-listable-element.component'; import { ObjectGridComponent } from './object-grid/object-grid.component'; import { ObjectCollectionComponent } from './object-collection/object-collection.component'; @@ -122,7 +120,6 @@ import { CreateItemParentSelectorComponent } from './dso-selector/modal-wrappers import { CreateCollectionParentSelectorComponent } from './dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component'; import { CommunitySearchResultListElementComponent } from './object-list/search-result-list-element/community-search-result/community-search-result-list-element.component'; import { CollectionSearchResultListElementComponent } from './object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component'; -import { ItemSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-search-result-list-element.component'; import { EditItemSelectorComponent } from './dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component'; import { EditCommunitySelectorComponent } from './dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component'; import { EditCollectionSelectorComponent } from './dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component'; @@ -142,6 +139,7 @@ import { MetadataRepresentationDirective } from './metadata-representation/metad import { ListableObjectComponentLoaderComponent } from './object-collection/shared/listable-object/listable-object-component-loader.component'; import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component'; import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component'; +import { ListableObjectDirective } from './object-collection/shared/listable-object/listable-object.directive'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -256,7 +254,6 @@ const COMPONENTS = [ EditItemSelectorComponent, CommunitySearchResultListElementComponent, CollectionSearchResultListElementComponent, - ItemSearchResultListElementComponent, ListableObjectComponentLoaderComponent, BrowseByComponent, ItemTypeBadgeComponent, @@ -265,15 +262,12 @@ const COMPONENTS = [ const ENTRY_COMPONENTS = [ // put shared entry components (components that are created dynamically) here - ItemListElementComponent, CollectionListElementComponent, CommunityListElementComponent, MyDSpaceResultListElementComponent, SearchResultListElementComponent, CommunitySearchResultListElementComponent, CollectionSearchResultListElementComponent, - ItemSearchResultListElementComponent, - ItemGridElementComponent, CollectionGridElementComponent, CommunityGridElementComponent, SearchResultGridElementComponent, @@ -332,7 +326,8 @@ const DIRECTIVES = [ InListValidator, AutoFocusDirective, RoleDirective, - MetadataRepresentationDirective + MetadataRepresentationDirective, + ListableObjectDirective ]; @NgModule({ diff --git a/themes/mantis/app/+item-page/simple/item-page.component.html b/themes/mantis/app/+item-page/simple/item-page.component.html index 472df7c78e..83f910e0cd 100644 --- a/themes/mantis/app/+item-page/simple/item-page.component.html +++ b/themes/mantis/app/+item-page/simple/item-page.component.html @@ -1,7 +1,7 @@
- +
From 0fb12c4274bc452e6120b9050b67696c8cacc616 Mon Sep 17 00:00:00 2001 From: lotte Date: Tue, 8 Oct 2019 15:51:31 +0200 Subject: [PATCH 07/17] refactored mydspace/listelements etc --- .../my-dspace-new-submission.component.ts | 4 +- .../my-dspace-page.component.ts | 4 +- .../+my-dspace-page/my-dspace-page.module.ts | 63 +++++++++--------- .../+my-dspace-page/my-dspace-result.model.ts | 22 ------- .../my-dspace-results.component.ts | 5 +- .../search-result-element-decorator.ts | 18 ++---- .../search-service/search.service.ts | 2 +- ...-search-result-grid-element.component.html | 56 ++++++++-------- ...-search-result-grid-element.component.html | 22 +++---- ...-search-result-grid-element.component.html | 64 +++++++++---------- ...-search-result-list-element.component.html | 22 +++---- ...-search-result-list-element.component.html | 22 +++---- ...-search-result-list-element.component.html | 20 +++--- ...-search-result-grid-element.component.html | 62 +++++++++--------- ...-search-result-grid-element.component.html | 56 ++++++++-------- ...-search-result-grid-element.component.html | 46 +++++++------ ...rgunit-item-page-list-element.component.ts | 6 +- ...person-item-page-list-element.component.ts | 7 +- ...-search-result-list-element.component.html | 22 +++---- ...-search-result-list-element.component.html | 20 +++--- ...-search-result-list-element.component.html | 12 ++-- ...ts => claimed-task-search-result.model.ts} | 4 +- .../shared/item-my-dspace-result.model.ts | 14 ---- ...table-object-component-loader.component.ts | 1 + ...el.ts => pool-task-search-result.model.ts} | 4 +- ...ts => workflowitem-search-result.model.ts} | 5 +- ...s => workspaceitem-search-result.model.ts} | 5 +- ...arch-result-detail-element.component.html} | 0 ...h-result-detail-element.component.spec.ts} | 16 ++--- ...search-result-detail-element.component.ts} | 17 ++--- .../item-detail-preview-field.component.ts | 4 +- .../item-detail-preview.component.ts | 4 +- ...-dspace-result-detail-element.component.ts | 27 -------- ...arch-result-detail-element.component.html} | 0 ...arch-result-detail-element.component.scss} | 0 ...h-result-detail-element.component.spec.ts} | 16 ++--- ...-search-result-detail-element.component.ts | 27 ++++++++ ...arch-result-detail-element.component.html} | 0 ...h-result-detail-element.component.spec.ts} | 16 ++--- ...search-result-detail-element.component.ts} | 16 ++--- ...arch-result-detail-element.component.scss} | 0 ...search-result-detail-element.component.ts} | 22 +++---- ...arch-result-detail-element.component.html} | 0 ...h-result-detail-element.component.spec.ts} | 16 ++--- ...search-result-detail-element.component.ts} | 16 ++--- ...arch-result-detail-element.component.html} | 0 ...arch-result-detail-element.component.scss} | 0 ...h-result-detail-element.component.spec.ts} | 16 ++--- ...search-result-detail-element.component.ts} | 21 +++--- ...-search-result-grid-element.component.html | 62 +++++++++--------- .../search-result-grid-element.component.ts | 13 ++-- ...em-metadata-list-element.component.spec.ts | 4 -- ...xt-metadata-list-element.component.spec.ts | 4 -- ...search-result-list-element.component.html} | 0 ...rch-result-list-element.component.spec.ts} | 16 ++--- ...d-search-result-list-element.component.ts} | 13 ++-- .../item-list-preview.component.ts | 4 +- ...lt-list-element-submission.component.html} | 0 ...lt-list-element-submission.component.scss} | 0 ...list-element-submission.component.spec.ts} | 16 ++--- ...sult-list-element-submission.component.ts} | 12 ++-- ...my-dspace-result-list-element.component.ts | 57 ----------------- ...search-result-list-element.component.html} | 0 ...rch-result-list-element.component.spec.ts} | 16 ++--- ...l-search-result-list-element.component.ts} | 22 +++---- ...search-result-list-element.component.html} | 0 ...rch-result-list-element.component.spec.ts} | 16 ++--- ...m-search-result-list-element.component.ts} | 17 +++-- ...search-result-list-element.component.html} | 0 ...search-result-list-element.component.scss} | 0 ...rch-result-list-element.component.spec.ts} | 16 ++--- ...m-search-result-list-element.component.ts} | 14 ++-- ...-search-result-list-element.component.html | 20 +++--- ...on-search-result-list-element.component.ts | 1 + .../search-result-list-element.component.ts | 9 ++- src/app/shared/shared.module.ts | 6 +- 76 files changed, 505 insertions(+), 655 deletions(-) delete mode 100644 src/app/+my-dspace-page/my-dspace-result.model.ts rename src/app/shared/object-collection/shared/{claimed-task-my-dspace-result.model.ts => claimed-task-search-result.model.ts} (75%) delete mode 100644 src/app/shared/object-collection/shared/item-my-dspace-result.model.ts rename src/app/shared/object-collection/shared/{pool-task-my-dspace-result.model.ts => pool-task-search-result.model.ts} (76%) rename src/app/shared/object-collection/shared/{workflowitem-my-dspace-result.model.ts => workflowitem-search-result.model.ts} (56%) rename src/app/shared/object-collection/shared/{workspaceitem-my-dspace-result.model.ts => workspaceitem-search-result.model.ts} (56%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.html => claimed-task-search-result/claimed-task-search-result-detail-element.component.html} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.spec.ts => claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts} (78%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts => claimed-task-search-result/claimed-task-search-result-detail-element.component.ts} (65%) delete mode 100644 src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts rename src/app/shared/object-detail/my-dspace-result-detail-element/{item-my-dspace-result/item-my-dspace-result-detail-element.component.html => item-search-result/item-search-result-detail-element.component.html} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{item-my-dspace-result/item-my-dspace-result-detail-element.component.scss => item-search-result/item-search-result-detail-element.component.scss} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{item-my-dspace-result/item-my-dspace-result-detail-element.component.spec.ts => item-search-result/item-search-result-detail-element.component.spec.ts} (74%) create mode 100644 src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts rename src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/{pool-my-dspace-result-detail-element.component.html => pool-search-result-detail-element.component.html} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/{pool-my-dspace-result-detail-element.component.spec.ts => pool-search-result-detail-element.component.spec.ts} (79%) rename src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/{pool-my-dspace-result-detail-element.component.ts => pool-search-result-detail-element.component.ts} (68%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{my-dspace-result-detail-element.component.scss => search-result-detail-element.component.scss} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{my-dspace-result-detail-element.component.ts => search-result-detail-element.component.ts} (68%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.html => workflow-item-search-result/workflow-item-search-result-detail-element.component.html} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.spec.ts => workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts} (76%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts => workflow-item-search-result/workflow-item-search-result-detail-element.component.ts} (63%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.html => workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.html} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.scss => workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.scss} (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.spec.ts => workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts} (75%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts => workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.ts} (57%) rename src/app/shared/object-list/my-dspace-result-list-element/{claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.html => claimed-search-result/claimed-search-result-list-element.component.html} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.spec.ts => claimed-search-result/claimed-search-result-list-element.component.spec.ts} (79%) rename src/app/shared/object-list/my-dspace-result-list-element/{claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts => claimed-search-result/claimed-search-result-list-element.component.ts} (75%) rename src/app/shared/object-list/my-dspace-result-list-element/{item-my-dspace-result/item-my-dspace-result-list-element.component.html => item-search-result/item-search-result-list-element-submission.component.html} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{item-my-dspace-result/item-my-dspace-result-list-element.component.scss => item-search-result/item-search-result-list-element-submission.component.scss} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{item-my-dspace-result/item-my-dspace-result-list-element.component.spec.ts => item-search-result/item-search-result-list-element-submission.component.spec.ts} (73%) rename src/app/shared/object-list/my-dspace-result-list-element/{item-my-dspace-result/item-my-dspace-result-list-element.component.ts => item-search-result/item-search-result-list-element-submission.component.ts} (60%) delete mode 100644 src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts rename src/app/shared/object-list/my-dspace-result-list-element/{pool-my-dspace-result/pool-my-dspace-result-list-element.component.html => pool-search-result/pool-search-result-list-element.component.html} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{pool-my-dspace-result/pool-my-dspace-result-list-element.component.spec.ts => pool-search-result/pool-search-result-list-element.component.spec.ts} (80%) rename src/app/shared/object-list/my-dspace-result-list-element/{pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts => pool-search-result/pool-search-result-list-element.component.ts} (65%) rename src/app/shared/object-list/my-dspace-result-list-element/{workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.html => workflow-item-search-result/workflow-item-search-result-list-element.component.html} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.spec.ts => workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts} (76%) rename src/app/shared/object-list/my-dspace-result-list-element/{workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts => workflow-item-search-result/workflow-item-search-result-list-element.component.ts} (66%) rename src/app/shared/object-list/my-dspace-result-list-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.html => workspace-item-search-result/workspace-item-search-result-list-element.component.html} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.scss => workspace-item-search-result/workspace-item-search-result-list-element.component.scss} (100%) rename src/app/shared/object-list/my-dspace-result-list-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.spec.ts => workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts} (76%) rename src/app/shared/object-list/my-dspace-result-list-element/{workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts => workspace-item-search-result/workspace-item-search-result-list-element.component.ts} (69%) diff --git a/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts b/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts index 938a1ec899..09adc16af6 100644 --- a/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts +++ b/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts @@ -7,7 +7,6 @@ import { TranslateService } from '@ngx-translate/core'; import { SubmissionState } from '../../submission/submission.reducers'; import { AuthService } from '../../core/auth/auth.service'; -import { MyDSpaceResult } from '../my-dspace-result.model'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { NotificationOptions } from '../../shared/notifications/models/notification-options.model'; @@ -15,6 +14,7 @@ import { UploaderOptions } from '../../shared/uploader/uploader-options.model'; import { HALEndpointService } from '../../core/shared/hal-endpoint.service'; import { NotificationType } from '../../shared/notifications/models/notification-type'; import { hasValue } from '../../shared/empty.util'; +import { SearchResult } from '../../+search-page/search-result.model'; /** * This component represents the whole mydspace page header @@ -25,7 +25,7 @@ import { hasValue } from '../../shared/empty.util'; templateUrl: './my-dspace-new-submission.component.html' }) export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit { - @Output() uploadEnd = new EventEmitter>>(); + @Output() uploadEnd = new EventEmitter>>(); /** * The UploaderOptions object diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index e05f43d56e..1bad29f0d5 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -20,7 +20,6 @@ import { SearchService } from '../+search-page/search-service/search.service'; import { SearchSidebarService } from '../+search-page/search-sidebar/search-sidebar.service'; import { hasValue } from '../shared/empty.util'; import { getSucceededRemoteData } from '../core/shared/operators'; -import { MyDSpaceResult } from './my-dspace-result.model'; import { MyDSpaceResponseParsingService } from '../core/data/mydspace-response-parsing.service'; import { SearchConfigurationOption } from '../+search-page/search-switch-configuration/search-configuration-option.model'; import { RoleType } from '../core/roles/role-types'; @@ -28,6 +27,7 @@ import { SearchConfigurationService } from '../+search-page/search-service/searc import { MyDSpaceConfigurationService } from './my-dspace-configuration.service'; import { ViewMode } from '../core/shared/view-mode.model'; import { MyDSpaceRequest } from '../core/data/request.models'; +import { SearchResult } from '../+search-page/search-result.model'; export const MYDSPACE_ROUTE = '/mydspace'; export const SEARCH_CONFIG_SERVICE: InjectionToken = new InjectionToken('searchConfigurationService'); @@ -63,7 +63,7 @@ export class MyDSpacePageComponent implements OnInit { /** * The current search results */ - resultsRD$: BehaviorSubject>>> = new BehaviorSubject(null); + resultsRD$: BehaviorSubject>>> = new BehaviorSubject(null); /** * The current paginated search options diff --git a/src/app/+my-dspace-page/my-dspace-page.module.ts b/src/app/+my-dspace-page/my-dspace-page.module.ts index 448699504e..6d2b8c0614 100644 --- a/src/app/+my-dspace-page/my-dspace-page.module.ts +++ b/src/app/+my-dspace-page/my-dspace-page.module.ts @@ -7,19 +7,20 @@ import { MyDspacePageRoutingModule } from './my-dspace-page-routing.module'; import { MyDSpacePageComponent } from './my-dspace-page.component'; import { SearchPageModule } from '../+search-page/search-page.module'; import { MyDSpaceResultsComponent } from './my-dspace-results/my-dspace-results.component'; -import { WorkspaceitemMyDSpaceResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component'; -import { ItemMyDSpaceResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component'; -import { WorkflowitemMyDSpaceResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component'; -import { ClaimedMyDSpaceResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component'; -import { PoolMyDSpaceResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component'; +import { WorkspaceItemSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component'; +import { ClaimedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component'; +import { PoolSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component'; import { MyDSpaceNewSubmissionComponent } from './my-dspace-new-submission/my-dspace-new-submission.component'; -import { ItemMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component'; -import { WorkspaceitemMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component'; -import { WorkflowitemMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component'; -import { ClaimedMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component'; -import { PoolMyDSpaceResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component'; +import { ItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component'; +import { WorkspaceItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component'; +import { WorkflowItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component'; +import { ClaimedTaskSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component'; import { MyDSpaceGuard } from './my-dspace.guard'; import { MyDSpaceConfigurationService } from './my-dspace-configuration.service'; +import { SearchResultListElementComponent } from '../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResultListElementSubmissionComponent } from '../shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component'; +import { WorkflowItemSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component'; +import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component'; @NgModule({ imports: [ @@ -31,33 +32,33 @@ import { MyDSpaceConfigurationService } from './my-dspace-configuration.service' declarations: [ MyDSpacePageComponent, MyDSpaceResultsComponent, - ItemMyDSpaceResultListElementComponent, - WorkspaceitemMyDSpaceResultListElementComponent, - WorkflowitemMyDSpaceResultListElementComponent, - ClaimedMyDSpaceResultListElementComponent, - PoolMyDSpaceResultListElementComponent, - ItemMyDSpaceResultDetailElementComponent, - WorkspaceitemMyDSpaceResultDetailElementComponent, - WorkflowitemMyDSpaceResultDetailElementComponent, - ClaimedMyDSpaceResultDetailElementComponent, - PoolMyDSpaceResultDetailElementComponent, - MyDSpaceNewSubmissionComponent + WorkspaceItemSearchResultListElementComponent, + WorkflowItemSearchResultListElementComponent, + ClaimedSearchResultListElementComponent, + PoolSearchResultListElementComponent, + ItemSearchResultDetailElementComponent, + WorkspaceItemSearchResultDetailElementComponent, + WorkflowItemSearchResultDetailElementComponent, + ClaimedTaskSearchResultDetailElementComponent, + PoolSearchResultDetailElementComponent, + MyDSpaceNewSubmissionComponent, + ItemSearchResultListElementSubmissionComponent ], providers: [ MyDSpaceGuard, MyDSpaceConfigurationService ], entryComponents: [ - ItemMyDSpaceResultListElementComponent, - WorkspaceitemMyDSpaceResultListElementComponent, - WorkflowitemMyDSpaceResultListElementComponent, - ClaimedMyDSpaceResultListElementComponent, - PoolMyDSpaceResultListElementComponent, - ItemMyDSpaceResultDetailElementComponent, - WorkspaceitemMyDSpaceResultDetailElementComponent, - WorkflowitemMyDSpaceResultDetailElementComponent, - ClaimedMyDSpaceResultDetailElementComponent, - PoolMyDSpaceResultDetailElementComponent + SearchResultListElementComponent, + WorkspaceItemSearchResultListElementComponent, + WorkflowItemSearchResultListElementComponent, + ClaimedSearchResultListElementComponent, + PoolSearchResultListElementComponent, + ItemSearchResultDetailElementComponent, + WorkspaceItemSearchResultDetailElementComponent, + WorkflowItemSearchResultDetailElementComponent, + ClaimedTaskSearchResultDetailElementComponent, + PoolSearchResultDetailElementComponent ] }) diff --git a/src/app/+my-dspace-page/my-dspace-result.model.ts b/src/app/+my-dspace-page/my-dspace-result.model.ts deleted file mode 100644 index 1737aaec0a..0000000000 --- a/src/app/+my-dspace-page/my-dspace-result.model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { DSpaceObject } from '../core/shared/dspace-object.model'; -import { MetadataMap } from '../core/shared/metadata.models'; -import { ListableObject } from '../shared/object-collection/shared/listable-object.model'; - -/** - * Represents a search result object of a certain () DSpaceObject - */ -export class MyDSpaceResult implements ListableObject { - /** - * The DSpaceObject that was found - */ - indexableObject: T; - - /** - * The metadata that was used to find this item, hithighlighted - */ - hitHighlights: MetadataMap; - - getRenderType(): string { - return this.indexableObject.getRenderType() + 'MyDSpaceResult'; - } -} diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts index 3a16def9c1..a72e797b35 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts @@ -1,13 +1,12 @@ import { Component, Input } from '@angular/core'; - import { RemoteData } from '../../core/data/remote-data'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { fadeIn, fadeInOut } from '../../shared/animations/fade'; -import { MyDSpaceResult } from '../my-dspace-result.model'; import { SearchOptions } from '../../+search-page/search-options.model'; import { PaginatedList } from '../../core/data/paginated-list'; import { ViewMode } from '../../core/shared/view-mode.model'; import { isEmpty } from '../../shared/empty.util'; +import { SearchResult } from '../../+search-page/search-result.model'; /** * Component that represents all results for mydspace page @@ -25,7 +24,7 @@ export class MyDSpaceResultsComponent { /** * The actual search result objects */ - @Input() searchResults: RemoteData>>; + @Input() searchResults: RemoteData>>; /** * The current configuration of the search diff --git a/src/app/+search-page/search-service/search-result-element-decorator.ts b/src/app/+search-page/search-service/search-result-element-decorator.ts index e804a5d8ee..34e61abc01 100644 --- a/src/app/+search-page/search-service/search-result-element-decorator.ts +++ b/src/app/+search-page/search-service/search-result-element-decorator.ts @@ -12,19 +12,13 @@ const searchResultMap = new Map(); * @param {GenericConstructor} domainConstructor The constructor of the DSpaceObject * @returns Decorator function that performs the actual mapping on initialization of the component */ -export function searchResultFor(domainConstructor: GenericConstructor, configuration: string = null) { +export function searchResultFor(domainConstructor: GenericConstructor) { return function decorator(searchResult: any) { if (!searchResult) { return; } - if (isNull(configuration)) { - searchResultMap.set(domainConstructor, searchResult); - } else { - if (!searchResultMap.get(configuration)) { - searchResultMap.set(configuration, new Map()); - } - searchResultMap.get(configuration).set(domainConstructor, searchResult); - } + searchResultMap.set(domainConstructor, searchResult); + }; } @@ -33,10 +27,6 @@ export function searchResultFor(domainConstructor: GenericConstructor} domainConstructor The DSpaceObject's constructor for which the search result component is requested * @returns The component's constructor that matches the given DSpaceObject */ -export function getSearchResultFor(domainConstructor: GenericConstructor, configuration: string = null) { - if (isNull(configuration) || configuration === 'default' || hasNoValue(searchResultMap.get(configuration))) { +export function getSearchResultFor(domainConstructor: GenericConstructor) { return searchResultMap.get(domainConstructor); - } else { - return searchResultMap.get(configuration).get(domainConstructor); - } } diff --git a/src/app/+search-page/search-service/search.service.ts b/src/app/+search-page/search-service/search.service.ts index 7adf4d83c5..3d48ca54c5 100644 --- a/src/app/+search-page/search-service/search.service.ts +++ b/src/app/+search-page/search-service/search.service.ts @@ -158,7 +158,7 @@ export class SearchService implements OnDestroy { let co = DSpaceObject; if (dsos.payload[index]) { const constructor: GenericConstructor = dsos.payload[index].constructor as GenericConstructor; - co = getSearchResultFor(constructor, searchOptions.configuration); + co = getSearchResultFor(constructor); return Object.assign(new co(), object, { indexableObject: dsos.payload[index] }); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html index 69ea378269..ed5d11ef71 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -1,32 +1,30 @@ - - -
- -
- - -
-
-
- - -

+ +
+ +
+ + +
+
+
+ + +

+
+

+ + -

- - - -

-

- - - -

-
- View -
+

+

+ + + +

+
+ View
- - \ No newline at end of file +
+
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html index 93559d21bf..4dea5fc879 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -1,32 +1,30 @@ - - +
- +
- +
- -

+ +

-

- +

+

-

- +

+

- View
-
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html index ad37333b90..2474c27b6c 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -1,37 +1,35 @@ - - -
- -
- - -
-
-
- - -

-
-

- - {{item.firstMetadataValue('creativework.editor')}} - + +

+ +
+ + +
+
+
+ + +

+
+

+ + {{dso.firstMetadataValue('creativework.editor')}} + , - {{item.firstMetadataValue('creativework.publisher')}} + {{dso.firstMetadataValue('creativework.publisher')}} - -

-

- - - -

-
- View -
+ +

+

+ + + +

+
+ View
- - \ No newline at end of file +
+ diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html index e0d6e4053a..98a8472975 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html @@ -1,17 +1,16 @@ - - - - - - - + + + + + - - @@ -20,5 +19,4 @@ - - \ No newline at end of file + diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html index f3c0173bde..9af28297d8 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html @@ -1,18 +1,17 @@ - - - - - - - + + + + + - () @@ -20,5 +19,4 @@ - - \ No newline at end of file + diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html index 629149b197..20b689327a 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html @@ -1,12 +1,11 @@ - - - - - - - + + + + + @@ -14,5 +13,4 @@ - - \ No newline at end of file + diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html index 799f5bd43c..f3fc0d269b 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html @@ -1,37 +1,35 @@ - - -
- -
- - -
-
-
- - -

+ +
+ +
+ + +
+
+
+ + +

+
+

+ + -

- - - -

-

- - {{item.firstMetadataValue('organization.address.addressCountry')}} - +

+

+ + {{dso.firstMetadataValue('organization.address.addressCountry')}} + , - {{item.firstMetadataValue('organization.address.addressLocality')}} + {{dso.firstMetadataValue('organization.address.addressLocality')}} - -

-
- View -
+ +

+
+ View
- - \ No newline at end of file +
+
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html index 1f66fa0d4e..523f524834 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -1,32 +1,30 @@ - - -
- -
- - -
-
-
- - -

+ +
+ +
+ + +
+
+
+ + +

+
+

+ + -

-

- - - -

-
- View -
+

+

+ + + +

+
+ View
- - \ No newline at end of file +
+
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html index 3465388ee0..c409a850cd 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -1,27 +1,25 @@ - - -
- -
- - -
-
-
- - -

+ +
+ +
+ + +
+
+
+ + +

+
+

+ + -

- - - -

-
- View -
+

+
+ View
- - \ No newline at end of file +
+
diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts index 84ae543f95..62a257010f 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -1,11 +1,13 @@ import { Component } from '@angular/core'; import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { Context } from '../../../../core/shared/context.model'; import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../core/shared/item.model'; +import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; +import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -@listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) +@metadataRepresentationComponent('OrgUnit', MetadataRepresentationType.Item) @Component({ selector: 'ds-orgunit-item-page-list-element', templateUrl: './orgunit-item-page-list-element.component.html' diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts index d90b90262c..696640dae5 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts @@ -1,11 +1,10 @@ import { Component } from '@angular/core'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { Context } from '../../../../core/shared/context.model'; -import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../core/shared/item.model'; +import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; +import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -@listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) +@metadataRepresentationComponent('Person', MetadataRepresentationType.Item) @Component({ selector: 'ds-person-item-page-list-element', templateUrl: './person-item-page-list-element.component.html' diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html index b833fa735b..4b32ac8278 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html @@ -1,18 +1,16 @@ - - - - - - - + + + + + - - - \ No newline at end of file + diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html index 3e1bbbcc2b..c3a471c486 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html @@ -1,12 +1,11 @@ - - - - - - - + + + + + @@ -14,5 +13,4 @@ - - \ No newline at end of file + diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html index 1715c7eb2e..df14563102 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html @@ -1,12 +1,11 @@ - - - + + - - + + @@ -15,4 +14,3 @@ - \ No newline at end of file diff --git a/src/app/shared/object-collection/shared/claimed-task-my-dspace-result.model.ts b/src/app/shared/object-collection/shared/claimed-task-search-result.model.ts similarity index 75% rename from src/app/shared/object-collection/shared/claimed-task-my-dspace-result.model.ts rename to src/app/shared/object-collection/shared/claimed-task-search-result.model.ts index 051bfe6d9f..734b4716ba 100644 --- a/src/app/shared/object-collection/shared/claimed-task-my-dspace-result.model.ts +++ b/src/app/shared/object-collection/shared/claimed-task-search-result.model.ts @@ -6,6 +6,6 @@ import { searchResultFor } from '../../../+search-page/search-service/search-res /** * Represents a search result object of a ClaimedTask object */ -@searchResultFor(ClaimedTask, MyDSpaceConfigurationValueType.Workflow) -export class ClaimedTaskMyDSpaceResult extends SearchResult { +@searchResultFor(ClaimedTask) +export class ClaimedTaskSearchResult extends SearchResult { } diff --git a/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts b/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts deleted file mode 100644 index e77b9295df..0000000000 --- a/src/app/shared/object-collection/shared/item-my-dspace-result.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Item } from '../../../core/shared/item.model'; -import { SearchResult } from '../../../+search-page/search-result.model'; -import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; -import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type'; - -/** - * Represents a search result object of a Item object - */ -@searchResultFor(Item, MyDSpaceConfigurationValueType.Workspace) -export class ItemMyDSpaceResult extends SearchResult { - getRenderType(): string { - return ItemMyDSpaceResult.name; - } -} diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 4651a342ac..00e78a3d50 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -41,6 +41,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit { const componentRef = viewContainerRef.createComponent(componentFactory); (componentRef.instance as any).object = this.object; + (componentRef.instance as any).index = this.index; } /** diff --git a/src/app/shared/object-collection/shared/pool-task-my-dspace-result.model.ts b/src/app/shared/object-collection/shared/pool-task-search-result.model.ts similarity index 76% rename from src/app/shared/object-collection/shared/pool-task-my-dspace-result.model.ts rename to src/app/shared/object-collection/shared/pool-task-search-result.model.ts index 1bc2c4c4c2..b44b172acb 100644 --- a/src/app/shared/object-collection/shared/pool-task-my-dspace-result.model.ts +++ b/src/app/shared/object-collection/shared/pool-task-search-result.model.ts @@ -6,6 +6,6 @@ import { searchResultFor } from '../../../+search-page/search-service/search-res /** * Represents a search result object of a PoolTask object */ -@searchResultFor(PoolTask, MyDSpaceConfigurationValueType.Workflow) -export class PoolTaskMyDSpaceResult extends SearchResult { +@searchResultFor(PoolTask) +export class PoolTaskSearchResult extends SearchResult { } diff --git a/src/app/shared/object-collection/shared/workflowitem-my-dspace-result.model.ts b/src/app/shared/object-collection/shared/workflowitem-search-result.model.ts similarity index 56% rename from src/app/shared/object-collection/shared/workflowitem-my-dspace-result.model.ts rename to src/app/shared/object-collection/shared/workflowitem-search-result.model.ts index d91c03b549..5684976e25 100644 --- a/src/app/shared/object-collection/shared/workflowitem-my-dspace-result.model.ts +++ b/src/app/shared/object-collection/shared/workflowitem-search-result.model.ts @@ -1,11 +1,10 @@ import { WorkflowItem } from '../../../core/submission/models/workflowitem.model'; import { SearchResult } from '../../../+search-page/search-result.model'; -import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; /** * Represents a search result object of a WorkflowItem object */ -@searchResultFor(WorkflowItem, MyDSpaceConfigurationValueType.Workspace) -export class WorkflowitemMyDSpaceResult extends SearchResult { +@searchResultFor(WorkflowItem) +export class WorkflowItemSearchResult extends SearchResult { } diff --git a/src/app/shared/object-collection/shared/workspaceitem-my-dspace-result.model.ts b/src/app/shared/object-collection/shared/workspaceitem-search-result.model.ts similarity index 56% rename from src/app/shared/object-collection/shared/workspaceitem-my-dspace-result.model.ts rename to src/app/shared/object-collection/shared/workspaceitem-search-result.model.ts index b7bd5e31d6..12fde0f8f1 100644 --- a/src/app/shared/object-collection/shared/workspaceitem-my-dspace-result.model.ts +++ b/src/app/shared/object-collection/shared/workspaceitem-search-result.model.ts @@ -1,11 +1,10 @@ import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model'; -import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; import { SearchResult } from '../../../+search-page/search-result.model'; /** * Represents a search result object of a WorkspaceItem object */ -@searchResultFor(WorkspaceItem, MyDSpaceConfigurationValueType.Workspace) -export class WorkspaceitemMyDSpaceResult extends SearchResult { +@searchResultFor(WorkspaceItem) +export class WorkspaceItemSearchResult extends SearchResult { } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts similarity index 78% rename from src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts index f57eb6420e..63520a8f5f 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts @@ -5,20 +5,20 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ClaimedMyDSpaceResultDetailElementComponent } from './claimed-my-dspace-result-detail-element.component'; -import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; +import { ClaimedTaskSearchResultDetailElementComponent } from './claimed-task-search-result-detail-element.component'; +import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: ClaimedMyDSpaceResultDetailElementComponent; -let fixture: ComponentFixture; +let component: ClaimedTaskSearchResultDetailElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: ClaimedTaskMyDSpaceResult = new ClaimedTaskMyDSpaceResult(); +const mockResultObject: ClaimedTaskSearchResult = new ClaimedTaskSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -59,19 +59,19 @@ describe('ClaimedMyDSpaceResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [ClaimedMyDSpaceResultDetailElementComponent], + declarations: [ClaimedTaskSearchResultDetailElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ClaimedMyDSpaceResultDetailElementComponent, { + }).overrideComponent(ClaimedTaskSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(ClaimedMyDSpaceResultDetailElementComponent); + fixture = TestBed.createComponent(ClaimedTaskSearchResultDetailElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts similarity index 65% rename from src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts index 91ddbaf09a..80e0fe0048 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts @@ -6,27 +6,24 @@ import { find } from 'rxjs/operators'; import { RemoteData } from '../../../../core/data/remote-data'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { isNotUndefined } from '../../../empty.util'; -import { ListableObject } from '../../../object-collection/shared/listable-object.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; -import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; -import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; +import { SearchResultDetailElementComponent } from '../search-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { Context } from '../../../../core/shared/context.model'; +import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; /** * This component renders claimed task object for the mydspace result in the detail view. */ @Component({ - selector: 'ds-claimed-my-dspace-result-detail-element', - styleUrls: ['../my-dspace-result-detail-element.component.scss'], - templateUrl: './claimed-my-dspace-result-detail-element.component.html' + selector: 'ds-claimed-task-search-result-detail-element', + styleUrls: ['../search-result-detail-element.component.scss'], + templateUrl: './claimed-task-search-result-detail-element.component.html' }) -@listableObjectComponent(ClaimedTaskMyDSpaceResult.name, ViewMode.DetailedListElement) -@listableObjectComponent(ClaimedTask.name, ViewMode.DetailedListElement) -export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { +@listableObjectComponent(ClaimedTaskSearchResult.name, ViewMode.DetailedListElement) +export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** * A boolean representing if to show submitter information diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts index b53d0a6b2d..c87a771f51 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts @@ -1,8 +1,8 @@ import { Component, Input } from '@angular/core'; import { Metadata } from '../../../../../core/shared/metadata.utils'; -import { MyDSpaceResult } from '../../../../../+my-dspace-page/my-dspace-result.model'; import { Item } from '../../../../../core/shared/item.model'; +import { SearchResult } from '../../../../../+search-page/search-result.model'; /** * This component show values for the given item metadata @@ -21,7 +21,7 @@ export class ItemDetailPreviewFieldComponent { /** * The mydspace result object */ - @Input() object: MyDSpaceResult; + @Input() object: SearchResult; /** * The metadata label diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts index d26bfc4589..772ba3e50a 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts @@ -6,7 +6,7 @@ import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { fadeInOut } from '../../../animations/fade'; import { Bitstream } from '../../../../core/shared/bitstream.model'; -import { MyDSpaceResult } from '../../../../+my-dspace-page/my-dspace-result.model'; +import { SearchResult } from '../../../../+search-page/search-result.model'; /** * This component show metadata for the given item object in the detail view. @@ -27,7 +27,7 @@ export class ItemDetailPreviewComponent { /** * The mydspace result object */ - @Input() object: MyDSpaceResult; + @Input() object: SearchResult; /** * Represent item's status diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts deleted file mode 100644 index 3788a0da4c..0000000000 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Component } from '@angular/core'; - -import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { Item } from '../../../../core/shared/item.model'; -import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; -import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; -import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; - -/** - * This component renders item object for the mydspace result in the detail view. - */ -@Component({ - selector: 'ds-workspaceitem-my-dspace-result-detail-element', - styleUrls: ['../my-dspace-result-detail-element.component.scss', './item-my-dspace-result-detail-element.component.scss'], - templateUrl: './item-my-dspace-result-detail-element.component.html' -}) - -@listableObjectComponent(ItemMyDSpaceResult.name, ViewMode.DetailedListElement) -export class ItemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { - - /** - * Represent item's status - */ - public status = MyDspaceItemStatusType.ARCHIVED; - -} diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.scss b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.scss similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.scss rename to src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.scss diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts similarity index 74% rename from src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts index c99f44cbae..070fedde81 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-my-dspace-result/item-my-dspace-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts @@ -5,16 +5,16 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemMyDSpaceResultDetailElementComponent } from './item-my-dspace-result-detail-element.component'; +import { ItemSearchResultDetailElementComponent } from './item-search-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; +import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -let component: ItemMyDSpaceResultDetailElementComponent; -let fixture: ComponentFixture; +let component: ItemSearchResultDetailElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: ItemMyDSpaceResult = new ItemMyDSpaceResult(); +const mockResultObject: ItemSearchResult = new ItemSearchResult(); mockResultObject.hitHighlights = {}; mockResultObject.indexableObject = Object.assign(new Item(), { @@ -51,19 +51,19 @@ describe('ItemMyDSpaceResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [ItemMyDSpaceResultDetailElementComponent], + declarations: [ItemSearchResultDetailElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemMyDSpaceResultDetailElementComponent, { + }).overrideComponent(ItemSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(ItemMyDSpaceResultDetailElementComponent); + fixture = TestBed.createComponent(ItemSearchResultDetailElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts new file mode 100644 index 0000000000..c0e3db6348 --- /dev/null +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts @@ -0,0 +1,27 @@ +import { Component } from '@angular/core'; + +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { Item } from '../../../../core/shared/item.model'; +import { SearchResultDetailElementComponent } from '../search-result-detail-element.component'; +import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; + +/** + * This component renders item object for the mydspace result in the detail view. + */ +@Component({ + selector: 'ds-item-search-result-detail-element', + styleUrls: ['../search-result-detail-element.component.scss', './item-search-result-detail-element.component.scss'], + templateUrl: './item-search-result-detail-element.component.html' +}) + +@listableObjectComponent('PublicationSearchResult', ViewMode.DetailedListElement) +export class ItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { + + /** + * Represent item's status + */ + public status = MyDspaceItemStatusType.ARCHIVED; + +} diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.spec.ts similarity index 79% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.spec.ts index 456b7dc97a..b6fd29e8a6 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.spec.ts @@ -5,19 +5,19 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { PoolMyDSpaceResultDetailElementComponent } from './pool-my-dspace-result-detail-element.component'; -import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; +import { PoolSearchResultDetailElementComponent } from './pool-my-dspace-result-detail-element.component'; +import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: PoolMyDSpaceResultDetailElementComponent; -let fixture: ComponentFixture; +let component: PoolSearchResultDetailElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: PoolTaskMyDSpaceResult = new PoolTaskMyDSpaceResult(); +const mockResultObject: PoolTaskSearchResult = new PoolTaskSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -58,19 +58,19 @@ describe('PoolMyDSpaceResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [PoolMyDSpaceResultDetailElementComponent], + declarations: [PoolSearchResultDetailElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(PoolMyDSpaceResultDetailElementComponent, { + }).overrideComponent(PoolSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(PoolMyDSpaceResultDetailElementComponent); + fixture = TestBed.createComponent(PoolSearchResultDetailElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.ts similarity index 68% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.ts index e9ff84b7cf..4a64d99a50 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.ts @@ -4,27 +4,25 @@ import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; -import { ListableObject } from '../../../object-collection/shared/listable-object.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; -import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; -import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; +import { SearchResultDetailElementComponent } from '../search-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; /** * This component renders pool task object for the mydspace result in the detail view. */ @Component({ - selector: 'ds-pool-my-dspace-result-detail-element', - styleUrls: ['../my-dspace-result-detail-element.component.scss'], - templateUrl: './pool-my-dspace-result-detail-element.component.html', + selector: 'ds-pool-search-result-detail-element', + styleUrls: ['../search-result-detail-element.component.scss'], + templateUrl: './pool-search-result-detail-element.component.html', }) -@listableObjectComponent(PoolTaskMyDSpaceResult.name, ViewMode.DetailedListElement) -@listableObjectComponent(PoolTask.name, ViewMode.DetailedListElement) -export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { +@listableObjectComponent(PoolTaskSearchResult.name, ViewMode.DetailedListElement) +export class PoolSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** * A boolean representing if to show submitter information diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.scss b/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.scss similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.scss rename to src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.scss diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts similarity index 68% rename from src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts index 1b83468c68..b5b60c9035 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts @@ -1,30 +1,26 @@ -import { Component, Inject } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; -import { MyDSpaceResult } from '../../../+my-dspace-page/my-dspace-result.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { Metadata } from '../../../core/shared/metadata.utils'; +import { SearchResult } from '../../../+search-page/search-result.model'; +import { hasValue } from '../../empty.util'; @Component({ - selector: 'ds-my-dspace-result-detail-element', + selector: 'ds-search-result-detail-element', template: `` }) -export class MyDSpaceResultDetailElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent { +export class SearchResultDetailElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent implements OnInit { /** * The result element object */ dso: K; - /** - * Initialize instance variables - * - * @param {ListableObject} detailable - */ - public constructor() { - super(); - this.dso = this.object.indexableObject; + ngOnInit(): void { + if (hasValue(this.object)) { + this.dso = this.object.indexableObject; + } } /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts similarity index 76% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts index 2a4b1321e2..a4f0e3542a 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts @@ -5,19 +5,19 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { WorkflowitemMyDSpaceResultDetailElementComponent } from './workflowitem-my-dspace-result-detail-element.component'; -import { WorkflowitemMyDSpaceResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; +import { WorkflowItemSearchResultDetailElementComponent } from './workflow-item-search-result-detail-element.component'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: WorkflowitemMyDSpaceResultDetailElementComponent; -let fixture: ComponentFixture; +let component: WorkflowItemSearchResultDetailElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: WorkflowitemMyDSpaceResult = new WorkflowitemMyDSpaceResult(); +const mockResultObject: WorkflowItemSearchResult = new WorkflowItemSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -56,19 +56,19 @@ describe('WorkflowitemMyDSpaceResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [WorkflowitemMyDSpaceResultDetailElementComponent], + declarations: [WorkflowItemSearchResultDetailElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(WorkflowitemMyDSpaceResultDetailElementComponent, { + }).overrideComponent(WorkflowItemSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(WorkflowitemMyDSpaceResultDetailElementComponent); + fixture = TestBed.createComponent(WorkflowItemSearchResultDetailElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts similarity index 63% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts index 4d6b047f56..20ef2148ad 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts @@ -2,29 +2,27 @@ import { Component, Inject } from '@angular/core'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Item } from '../../../../core/shared/item.model'; -import { ListableObject } from '../../../object-collection/shared/listable-object.model'; -import { WorkflowitemMyDSpaceResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; -import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; +import { SearchResultDetailElementComponent } from '../search-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { Observable } from 'rxjs/internal/Observable'; import { RemoteData } from '../../../../core/data/remote-data'; import { find } from 'rxjs/operators'; import { isNotUndefined } from '../../../empty.util'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; /** * This component renders workflowitem object for the mydspace result in the detail view. */ @Component({ - selector: 'ds-workflowitem-my-dspace-result-detail-element', - styleUrls: ['../my-dspace-result-detail-element.component.scss'], - templateUrl: './workflowitem-my-dspace-result-detail-element.component.html', + selector: 'ds-workflow-item-search-result-detail-element', + styleUrls: ['../search-result-detail-element.component.scss'], + templateUrl: './workflow-item-search-result-detail-element.component.html', }) -@listableObjectComponent(WorkflowitemMyDSpaceResult.name, ViewMode.DetailedListElement) -@listableObjectComponent(WorkflowItem.name, ViewMode.DetailedListElement) -export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { +@listableObjectComponent(WorkflowItemSearchResult.name, ViewMode.DetailedListElement) +export class WorkflowItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** * The item object that belonging to the result object diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.scss b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.scss similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.scss rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.scss diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts similarity index 75% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts index 0e16b9c0f6..ebd0d1ba6a 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts @@ -5,19 +5,19 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { WorkspaceitemMyDSpaceResultDetailElementComponent } from './workspaceitem-my-dspace-result-detail-element.component'; -import { WorkspaceitemMyDSpaceResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; +import { WorkspaceItemSearchResultDetailElementComponent } from './workspace-item-search-result-detail-element.component'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: WorkspaceitemMyDSpaceResultDetailElementComponent; -let fixture: ComponentFixture; +let component: WorkspaceItemSearchResultDetailElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: WorkspaceitemMyDSpaceResult = new WorkspaceitemMyDSpaceResult(); +const mockResultObject: WorkflowItemSearchResult = new WorkflowItemSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -56,19 +56,19 @@ describe('WorkspaceitemMyDSpaceResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [WorkspaceitemMyDSpaceResultDetailElementComponent], + declarations: [WorkspaceItemSearchResultDetailElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(WorkspaceitemMyDSpaceResultDetailElementComponent, { + }).overrideComponent(WorkspaceItemSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(WorkspaceitemMyDSpaceResultDetailElementComponent); + fixture = TestBed.createComponent(WorkspaceItemSearchResultDetailElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.ts similarity index 57% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.ts index e9cc6967e6..a3527f0713 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.ts @@ -1,32 +1,29 @@ -import { Component, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { - WorkspaceItem -} from '../../../../core/submission/models/workspaceitem.model'; -import { WorkspaceitemMyDSpaceResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; +import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; -import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component'; +import { SearchResultDetailElementComponent } from '../search-result-detail-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model'; /** * This component renders workspaceitem object for the mydspace result in the detail view. */ @Component({ - selector: 'ds-workspaceitem-my-dspace-result-detail-element', - styleUrls: ['../my-dspace-result-detail-element.component.scss', './workspaceitem-my-dspace-result-detail-element.component.scss'], - templateUrl: './workspaceitem-my-dspace-result-detail-element.component.html', + selector: 'ds-workspace-item-search-result-detail-element', + styleUrls: ['../search-result-detail-element.component.scss', './workspace-item-search-result-detail-element.component.scss'], + templateUrl: './workspace-item-search-result-detail-element.component.html', }) -@listableObjectComponent(WorkspaceitemMyDSpaceResult.name, ViewMode.DetailedListElement) -@listableObjectComponent(WorkspaceItem.name, ViewMode.DetailedListElement) -export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent { +@listableObjectComponent(WorkspaceItemSearchResult.name, ViewMode.DetailedListElement) +export class WorkspaceItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** * The item object that belonging to the result object diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html index 273be96ca5..d5b481f13c 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html @@ -1,36 +1,34 @@ - - -
- -
- - -
-
-
- - -

-
-

- - {{item.firstMetadataValue('dc.date.issued')}} - , + +

+ +
+ + +
+
+
+ + +

+
+

+ + {{dso.firstMetadataValue('dc.date.issued')}} + , - -

-

- - - -

-
- View -
+ +

+

+ + + +

+
+ View
- - \ No newline at end of file +
+ diff --git a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts index 2213941864..a136636cda 100644 --- a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts @@ -1,9 +1,8 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; import { SearchResult } from '../../../+search-page/search-result.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; import { TruncatableService } from '../../truncatable/truncatable.service'; import { Observable } from 'rxjs'; import { Metadata } from '../../../core/shared/metadata.utils'; @@ -14,18 +13,23 @@ import { hasValue } from '../../empty.util'; template: `` }) -export class SearchResultGridElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent { +export class SearchResultGridElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent implements OnInit { dso: K; isCollapsed$: Observable; public constructor(protected truncatableService: TruncatableService) { super(); if (hasValue(this.object)) { - this.dso = this.object.indexableObject; this.isCollapsed$ = this.isCollapsed(); } } + ngOnInit(): void { + if (hasValue(this.object)) { + this.dso = this.object.indexableObject; + } + } + /** * Gets all matching metadata string values from hitHighlights or dso metadata, preferring hitHighlights. * @@ -49,5 +53,4 @@ export class SearchResultGridElementComponent, K exten private isCollapsed(): Observable { return this.truncatableService.isCollapsed(this.dso.id); } - } diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts index e89602775e..7afe774831 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts @@ -1,5 +1,4 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ItemMetadataListElementComponent } from './item-metadata-list-element.component'; import { By } from '@angular/platform-browser'; @@ -15,9 +14,6 @@ describe('ItemMetadataListElementComponent', () => { TestBed.configureTestingModule({ imports: [], declarations: [ItemMetadataListElementComponent], - providers: [ - { provide: ITEM, useValue: mockItemMetadataRepresentation } - ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ItemMetadataListElementComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts index ba6d06ad84..9926b8639e 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts @@ -2,7 +2,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { PlainTextMetadataListElementComponent } from './plain-text-metadata-list-element.component'; import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; const mockMetadataRepresentation = Object.assign(new MetadatumRepresentation('type'), { key: 'dc.contributor.author', @@ -17,9 +16,6 @@ describe('PlainTextMetadataListElementComponent', () => { TestBed.configureTestingModule({ imports: [], declarations: [PlainTextMetadataListElementComponent], - providers: [ - { provide: ITEM, useValue: mockMetadataRepresentation } - ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(PlainTextMetadataListElementComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.html similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.html rename to src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.html diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts similarity index 79% rename from src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.spec.ts rename to src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts index 5815cd5401..c52b1f1b07 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts @@ -5,20 +5,20 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ClaimedMyDSpaceResultListElementComponent } from './claimed-my-dspace-result-list-element.component'; -import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; +import { ClaimedSearchResultListElementComponent } from './claimed-search-result-list-element.component'; +import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: ClaimedMyDSpaceResultListElementComponent; -let fixture: ComponentFixture; +let component: ClaimedSearchResultListElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: ClaimedTaskMyDSpaceResult = new ClaimedTaskMyDSpaceResult(); +const mockResultObject: ClaimedTaskSearchResult = new ClaimedTaskSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -59,19 +59,19 @@ describe('ClaimedMyDSpaceResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [ClaimedMyDSpaceResultListElementComponent], + declarations: [ClaimedSearchResultListElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ClaimedMyDSpaceResultListElementComponent, { + }).overrideComponent(ClaimedSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(ClaimedMyDSpaceResultListElementComponent); + fixture = TestBed.createComponent(ClaimedSearchResultListElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts similarity index 75% rename from src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts rename to src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts index bef18a5c1a..5668ece14e 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-my-dspace-result/claimed-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts @@ -4,29 +4,28 @@ import { Location, LocationStrategy, PathLocationStrategy } from '@angular/commo import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; -import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; +import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** * This component renders claimed task object for the mydspace result in the list view. */ @Component({ - selector: 'ds-claimed-my-dspace-result-list-element', + selector: 'ds-claimed-search-result-list-element', styleUrls: ['../my-dspace-result-list-element.component.scss'], - templateUrl: './claimed-my-dspace-result-list-element.component.html', + templateUrl: './claimed-search-result-list-element.component.html', providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) -@listableObjectComponent(ClaimedTaskMyDSpaceResult.name, ViewMode.ListElement) -@listableObjectComponent(ClaimedTask.name, ViewMode.ListElement) -export class ClaimedMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { +@listableObjectComponent(ClaimedTaskSearchResult.name, ViewMode.ListElement) +export class ClaimedSearchResultListElementComponent extends SearchResultListElementComponent { /** * A boolean representing if to show submitter information diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts index 13876ab46a..8324e748f1 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts @@ -3,7 +3,7 @@ import { Component, Input } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; import { fadeInOut } from '../../../animations/fade'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { MyDSpaceResult } from '../../../../+my-dspace-page/my-dspace-result.model'; +import { SearchResult } from '../../../../+search-page/search-result.model'; /** * This component show metadata for the given item object in the list view. @@ -24,7 +24,7 @@ export class ItemListPreviewComponent { /** * The mydspace result object */ - @Input() object: MyDSpaceResult; + @Input() object: SearchResult; /** * Represent item's status diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.html similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.html rename to src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.html diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.scss b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.scss similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.scss rename to src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.scss diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts similarity index 73% rename from src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.spec.ts rename to src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts index ea4f2d24f3..d3c657cc3f 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts @@ -5,16 +5,16 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ItemMyDSpaceResultListElementComponent } from './item-my-dspace-result-list-element.component'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; +import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; +import { ItemSearchResultListElementSubmissionComponent } from './item-search-result-list-element-submission.component'; -let component: ItemMyDSpaceResultListElementComponent; -let fixture: ComponentFixture; +let component: ItemSearchResultListElementSubmissionComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: ItemMyDSpaceResult = new ItemMyDSpaceResult(); +const mockResultObject: ItemSearchResult = new ItemSearchResult(); mockResultObject.hitHighlights = {}; mockResultObject.indexableObject = Object.assign(new Item(), { @@ -51,19 +51,19 @@ describe('ItemMyDSpaceResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [ItemMyDSpaceResultListElementComponent], + declarations: [ItemSearchResultListElementSubmissionComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemMyDSpaceResultListElementComponent, { + }).overrideComponent(ItemSearchResultListElementSubmissionComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(ItemMyDSpaceResultListElementComponent); + fixture = TestBed.createComponent(ItemSearchResultListElementSubmissionComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts similarity index 60% rename from src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts rename to src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index 5304138587..6ff9afd0d7 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-my-dspace-result/item-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -1,24 +1,24 @@ import { Component } from '@angular/core'; -import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { Item } from '../../../../core/shared/item.model'; -import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { Context } from '../../../../core/shared/context.model'; +import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; +import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** * This component renders item object for the mydspace result in the list view. */ @Component({ - selector: 'ds-workspaceitem-my-dspace-result-list-element', - styleUrls: ['../my-dspace-result-list-element.component.scss', './item-my-dspace-result-list-element.component.scss'], - templateUrl: './item-my-dspace-result-list-element.component.html' + selector: 'ds-item-search-result-list-element-submission', + styleUrls: ['../my-dspace-result-list-element.component.scss', './item-search-result-list-element-submission.component.scss'], + templateUrl: './item-search-result-list-element-submission.component.html' }) @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement, Context.Submission) -export class ItemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { +export class ItemSearchResultListElementSubmissionComponent extends SearchResultListElementComponent { /** * Represent item's status diff --git a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts deleted file mode 100644 index 0db8b73412..0000000000 --- a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Component, Inject } from '@angular/core'; - -import { MyDSpaceResult } from '../../../+my-dspace-page/my-dspace-result.model'; -import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; -import { DSpaceObject } from '../../../core/shared/dspace-object.model'; -import { Metadata } from '../../../core/shared/metadata.utils'; - -@Component({ - selector: 'ds-my-dspace-result-list-element', - template: `` -}) -export class MyDSpaceResultListElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent { - - /** - * The result element object - */ - dso: K; - - /** - * The array index of the result element - */ - dsoIndex: number; - - /** - * Initialize instance variables - * - * @param {ListableObject} listable - * @param {number} index - */ - public constructor(@Inject('indexElementProvider') public index: number) { - super(); - this.dso = this.object.indexableObject; - this.dsoIndex = this.index; - } - - /** - * Gets all matching metadata string values from hitHighlights or dso metadata, preferring hitHighlights. - * - * @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]]. - * @returns {string[]} the matching string values or an empty array. - */ - allMetadataValues(keyOrKeys: string | string[]): string[] { - return Metadata.allValues([this.object.hitHighlights, this.dso.metadata], keyOrKeys); - } - - /** - * Gets the first matching metadata string value from hitHighlights or dso metadata, preferring hitHighlights. - * - * @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]]. - * @returns {string} the first matching string value, or `undefined`. - */ - firstMetadataValue(keyOrKeys: string | string[]): string { - return Metadata.firstValue([this.object.hitHighlights, this.dso.metadata], keyOrKeys); - } - -} diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.html similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.html rename to src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.html diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts similarity index 80% rename from src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.spec.ts rename to src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts index 22804a3a30..08b670862f 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts @@ -5,20 +5,20 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { PoolMyDSpaceResultListElementComponent } from './pool-my-dspace-result-list-element.component'; -import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; +import { PoolSearchResultListElementComponent } from './pool-search-result-list-element.component'; +import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: PoolMyDSpaceResultListElementComponent; -let fixture: ComponentFixture; +let component: PoolSearchResultListElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: PoolTaskMyDSpaceResult = new PoolTaskMyDSpaceResult(); +const mockResultObject: PoolTaskSearchResult = new PoolTaskSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -59,19 +59,19 @@ describe('PoolMyDSpaceResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [PoolMyDSpaceResultListElementComponent], + declarations: [PoolSearchResultListElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(PoolMyDSpaceResultListElementComponent, { + }).overrideComponent(PoolSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(PoolMyDSpaceResultListElementComponent); + fixture = TestBed.createComponent(PoolSearchResultListElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts similarity index 65% rename from src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts rename to src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts index 46dfd583e0..3ec85ae040 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts @@ -3,30 +3,28 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; -import { ListableObject } from '../../../object-collection/shared/listable-object.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; -import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; +import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; +import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; /** * This component renders pool task object for the mydspace result in the list view. */ @Component({ - selector: 'ds-pool-my-dspace-result-list-element', + selector: 'ds-pool-search-result-list-element', styleUrls: ['../my-dspace-result-list-element.component.scss'], - templateUrl: './pool-my-dspace-result-list-element.component.html', + templateUrl: './pool-search-result-list-element.component.html', }) -@listableObjectComponent(PoolTaskMyDSpaceResult.name, ViewMode.ListElement) -@listableObjectComponent(PoolTask.name, ViewMode.ListElement) -export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent implements OnInit { +@listableObjectComponent(PoolTaskSearchResult.name, ViewMode.ListElement) +export class PoolSearchResultListElementComponent extends SearchResultListElementComponent implements OnInit { /** * A boolean representing if to show submitter information @@ -43,8 +41,10 @@ export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListEl */ public workflowitem: WorkflowItem; - constructor(@Inject('indexElementProvider') public index: number) { - super(index); + public index: number; + + constructor(protected truncatableService: TruncatableService) { + super(truncatableService); } /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.html similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.html rename to src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.html diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts similarity index 76% rename from src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.spec.ts rename to src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts index ab472b4014..dd04198b93 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts @@ -5,19 +5,19 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { WorkflowitemMyDSpaceResultListElementComponent } from './workflowitem-my-dspace-result-list-element.component'; -import { WorkflowitemMyDSpaceResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; +import { WorkflowItemSearchResultListElementComponent } from './workflow-item-my-search-result-list-element.component'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: WorkflowitemMyDSpaceResultListElementComponent; -let fixture: ComponentFixture; +let component: WorkflowItemSearchResultListElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: WorkflowitemMyDSpaceResult = new WorkflowitemMyDSpaceResult(); +const mockResultObject: WorkflowItemSearchResult = new WorkflowItemSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -56,19 +56,19 @@ describe('WorkflowitemMyDSpaceResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [WorkflowitemMyDSpaceResultListElementComponent], + declarations: [WorkflowItemSearchResultListElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(WorkflowitemMyDSpaceResultListElementComponent, { + }).overrideComponent(WorkflowItemSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(WorkflowitemMyDSpaceResultListElementComponent); + fixture = TestBed.createComponent(WorkflowItemSearchResultListElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts similarity index 66% rename from src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts rename to src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts index 97c1695c29..d5ac65c740 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts @@ -3,29 +3,28 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; -import { WorkflowitemMyDSpaceResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** * This component renders workflowitem object for the mydspace result in the list view. */ @Component({ - selector: 'ds-workflowitem-my-dspace-result-list-element', + selector: 'ds-workflow-item-my-dspace-result-list-element', styleUrls: ['../my-dspace-result-list-element.component.scss'], - templateUrl: './workflowitem-my-dspace-result-list-element.component.html', + templateUrl: './workflow-item-search-result-list-element.component.html', }) -@listableObjectComponent(WorkflowitemMyDSpaceResult.name, ViewMode.ListElement) -@listableObjectComponent(WorkflowItem.name, ViewMode.ListElement) -export class WorkflowitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { - +@listableObjectComponent(WorkflowItemSearchResult.name, ViewMode.ListElement) +export class WorkflowItemSearchResultListElementComponent extends SearchResultListElementComponent { + /** * The item object that belonging to the result object */ @@ -40,7 +39,7 @@ export class WorkflowitemMyDSpaceResultListElementComponent extends MyDSpaceResu * Initialize all instance variables */ ngOnInit() { - this.initItem(this.dso.item as Observable>); + this.initItem(this.dso.item as Observable> ); } /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.html similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.html rename to src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.html diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.scss b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.scss rename to src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.scss diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts similarity index 76% rename from src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.spec.ts rename to src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts index a1c2472d27..988d550345 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts @@ -5,19 +5,19 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { WorkspaceitemMyDSpaceResultListElementComponent } from './workspaceitem-my-dspace-result-list-element.component'; -import { WorkspaceitemMyDSpaceResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; +import { WorkspaceItemSearchResultListElementComponent } from './workspace-item-search-result-list-element.component'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -let component: WorkspaceitemMyDSpaceResultListElementComponent; -let fixture: ComponentFixture; +let component: WorkspaceItemSearchResultListElementComponent; +let fixture: ComponentFixture; const compIndex = 1; -const mockResultObject: WorkspaceitemMyDSpaceResult = new WorkspaceitemMyDSpaceResult(); +const mockResultObject: WorkflowItemSearchResult = new WorkflowItemSearchResult(); mockResultObject.hitHighlights = {}; const item = Object.assign(new Item(), { @@ -56,19 +56,19 @@ describe('WorkspaceitemMyDSpaceResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [WorkspaceitemMyDSpaceResultListElementComponent], + declarations: [WorkspaceItemSearchResultListElementComponent], providers: [ { provide: 'objectElementProvider', useValue: (mockResultObject) }, { provide: 'indexElementProvider', useValue: (compIndex) } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(WorkspaceitemMyDSpaceResultListElementComponent, { + }).overrideComponent(WorkspaceItemSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(WorkspaceitemMyDSpaceResultListElementComponent); + fixture = TestBed.createComponent(WorkspaceItemSearchResultListElementComponent); component = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts similarity index 69% rename from src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts rename to src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts index a886e90737..e4d8409f1c 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts @@ -3,27 +3,27 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; -import { MyDSpaceResultListElementComponent, } from '../my-dspace-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; -import { WorkspaceitemMyDSpaceResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { isNotUndefined } from '../../../empty.util'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model'; +import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** * This component renders workspaceitem object for the mydspace result in the list view. */ @Component({ - selector: 'ds-workspaceitem-my-dspace-result-list-element', - styleUrls: ['../my-dspace-result-list-element.component.scss', './workspaceitem-my-dspace-result-list-element.component.scss'], - templateUrl: './workspaceitem-my-dspace-result-list-element.component.html', + selector: 'ds-workspace-item-search-result-list-element', + styleUrls: ['../my-dspace-result-list-element.component.scss', './workspace-item-search-result-list-element.component.scss'], + templateUrl: './workspace-item-search-result-list-element.component.html', }) -@listableObjectComponent(WorkspaceitemMyDSpaceResult.name, ViewMode.ListElement) -export class WorkspaceitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent { +@listableObjectComponent(WorkspaceItemSearchResult.name, ViewMode.ListElement) +export class WorkspaceItemSearchResultListElementComponent extends SearchResultListElementComponent { /** * The item object that belonging to the result object diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html index 7fbb2c3c79..f6bfe787cb 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html @@ -1,17 +1,16 @@ - - + - + - - ( + (, ) - @@ -20,10 +19,9 @@ -
- +
-
\ No newline at end of file diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts index 74d0d30f8d..3a72b8ef26 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts @@ -6,6 +6,7 @@ import { SearchResultListElementComponent } from '../../../search-result-list-el import { Item } from '../../../../../../core/shared/item.model'; @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) +@listableObjectComponent(ItemSearchResult.name, ViewMode.ListElement) @Component({ selector: 'ds-publication-search-result-list-element', styleUrls: ['./publication-search-result-list-element.component.scss'], diff --git a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts index f9110c0cb4..3d4bf9224b 100644 --- a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts @@ -1,10 +1,9 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { SearchResult } from '../../../+search-page/search-result.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { hasValue } from '../../empty.util'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { TruncatableService } from '../../truncatable/truncatable.service'; import { Metadata } from '../../../core/shared/metadata.utils'; @@ -15,12 +14,15 @@ import { MetadataMap } from '../../../core/shared/metadata.models'; template: `` }) -export class SearchResultListElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent { +export class SearchResultListElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent implements OnInit { dso: K; metadata: MetadataMap; public constructor(protected truncatableService: TruncatableService) { super(); + } + + ngOnInit(): void { if (hasValue(this.object)) { this.dso = this.object.indexableObject; } @@ -49,4 +51,5 @@ export class SearchResultListElementComponent, K exten isCollapsed(): Observable { return this.truncatableService.isCollapsed(this.dso.id); } + } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 187de7726c..57bf6ae8bf 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -74,8 +74,7 @@ import { DsDatePickerComponent } from './form/builder/ds-dynamic-form-ui/models/ import { DsDynamicLookupComponent } from './form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component'; import { MockAdminGuard } from './mocks/mock-admin-guard.service'; import { AlertComponent } from './alert/alert.component'; -import { MyDSpaceResultListElementComponent } from './object-list/my-dspace-result-list-element/my-dspace-result-list-element.component'; -import { MyDSpaceResultDetailElementComponent } from './object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component'; +import { SearchResultDetailElementComponent } from './object-detail/my-dspace-result-detail-element/search-result-detail-element.component'; import { ClaimedTaskActionsComponent } from './mydspace-actions/claimed-task/claimed-task-actions.component'; import { PoolTaskActionsComponent } from './mydspace-actions/pool-task/pool-task-actions.component'; import { ObjectDetailComponent } from './object-detail/object-detail.component'; @@ -264,7 +263,6 @@ const ENTRY_COMPONENTS = [ // put shared entry components (components that are created dynamically) here CollectionListElementComponent, CommunityListElementComponent, - MyDSpaceResultListElementComponent, SearchResultListElementComponent, CommunitySearchResultListElementComponent, CollectionSearchResultListElementComponent, @@ -276,7 +274,7 @@ const ENTRY_COMPONENTS = [ PublicationSearchResultListElementComponent, PublicationSearchResultGridElementComponent, BrowseEntryListElementComponent, - MyDSpaceResultDetailElementComponent, + SearchResultDetailElementComponent, SearchResultGridElementComponent, DsDynamicListComponent, DsDynamicLookupComponent, From dfe11431846872abce7bc750a751ab4cb184a633 Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 10 Oct 2019 16:18:14 +0200 Subject: [PATCH 08/17] metadata representation --- .../publication/publication.component.ts | 4 +- ...etadata-representation-list.component.html | 6 +-- .../+my-dspace-page/my-dspace-page.module.ts | 3 +- .../my-dspace-results.component.html | 3 +- .../my-dspace-results.component.ts | 2 + src/app/+search-page/search-result.model.ts | 4 +- src/app/core/metadata/metadata-field.model.ts | 4 +- .../core/metadata/metadata-schema.model.ts | 4 +- src/app/core/shared/browse-entry.model.ts | 4 +- src/app/core/shared/dspace-object.model.ts | 4 +- src/app/core/shared/item.model.ts | 12 ++--- ...-search-result-grid-element.component.html | 2 +- ...-search-result-grid-element.component.html | 2 +- ...-search-result-grid-element.component.html | 2 +- ...-search-result-grid-element.component.html | 2 +- ...-search-result-grid-element.component.html | 2 +- ...-search-result-grid-element.component.html | 2 +- ...rgunit-item-page-list-element.component.ts | 3 -- .../project/project-list-element.component.ts | 6 +-- ...ct-search-result-list-element.component.ts | 6 +-- .../metadata-representation.decorator.ts | 4 +- .../object-collection.component.html | 3 ++ .../object-collection.component.ts | 1 + .../shared/listable-object.model.ts | 2 +- ...table-object-component-loader.component.ts | 2 +- .../listable-object.decorator.ts | 47 +++++++++++-------- ...-search-result-detail-element.component.ts | 6 +++ .../object-detail.component.html | 6 +-- .../object-detail.component.scss | 4 +- .../object-detail/object-detail.component.ts | 2 + .../publication-grid-element.component.ts | 4 +- .../object-grid/object-grid.component.html | 6 +-- .../object-grid/object-grid.component.scss | 2 +- .../object-grid/object-grid.component.ts | 4 +- ...-search-result-grid-element.component.html | 2 +- .../publication-list-element.component.ts | 4 +- .../item-type-badge.component.html | 2 +- .../item-metadata-list-element.component.ts | 4 +- ...in-text-metadata-list-element.component.ts | 6 +-- ...ed-search-result-list-element.component.ts | 1 + ...esult-list-element-submission.component.ts | 10 ++-- ...ol-search-result-list-element.component.ts | 1 + ...em-search-result-list-element.component.ts | 1 + ...em-search-result-list-element.component.ts | 1 + .../object-list/object-list.component.html | 2 +- .../object-list/object-list.component.ts | 2 + ...on-search-result-list-element.component.ts | 1 - ...-search-result-list-element.component.html | 26 +++++----- 48 files changed, 131 insertions(+), 102 deletions(-) diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index 8f0bdc141d..5bc118a4ca 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -5,10 +5,10 @@ import { ItemComponent } from '../shared/item.component'; import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; @listableObjectComponent('Publication', ViewMode.StandalonePage) -@listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.StandalonePage) +@listableObjectComponent(Item.name, ViewMode.StandalonePage) @Component({ selector: 'ds-publication', styleUrls: ['./publication.component.scss'], diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html index 0bc7d51244..c875f7fe32 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html @@ -1,5 +1,5 @@ - - + + diff --git a/src/app/+my-dspace-page/my-dspace-page.module.ts b/src/app/+my-dspace-page/my-dspace-page.module.ts index 6d2b8c0614..685f1155be 100644 --- a/src/app/+my-dspace-page/my-dspace-page.module.ts +++ b/src/app/+my-dspace-page/my-dspace-page.module.ts @@ -58,7 +58,8 @@ import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/ WorkspaceItemSearchResultDetailElementComponent, WorkflowItemSearchResultDetailElementComponent, ClaimedTaskSearchResultDetailElementComponent, - PoolSearchResultDetailElementComponent + PoolSearchResultDetailElementComponent, + ItemSearchResultListElementSubmissionComponent ] }) diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.html b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.html index 132a0d2204..63eb0ff9a7 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.html +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.html @@ -4,7 +4,8 @@ [hasBorder]="hasBorder" [sortConfig]="searchConfig.sort" [objects]="searchResults" - [hideGear]="true"> + [hideGear]="true" + [context]="context">
diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts index a72e797b35..61669277cf 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts @@ -7,6 +7,7 @@ import { PaginatedList } from '../../core/data/paginated-list'; import { ViewMode } from '../../core/shared/view-mode.model'; import { isEmpty } from '../../shared/empty.util'; import { SearchResult } from '../../+search-page/search-result.model'; +import { Context } from '../../core/shared/context.model'; /** * Component that represents all results for mydspace page @@ -36,6 +37,7 @@ export class MyDSpaceResultsComponent { */ @Input() viewMode: ViewMode; + context = Context.Submission; /** * A boolean representing if search results entry are separated by a line */ diff --git a/src/app/+search-page/search-result.model.ts b/src/app/+search-page/search-result.model.ts index 0006426119..693f81e65b 100644 --- a/src/app/+search-page/search-result.model.ts +++ b/src/app/+search-page/search-result.model.ts @@ -16,7 +16,7 @@ export class SearchResult implements ListableObject { */ hitHighlights: MetadataMap; - getRenderType(): string { - return this.indexableObject.getRenderType() + 'SearchResult'; + getRenderTypes(): string[] { + return this.indexableObject.getRenderTypes().map((type) => type +'SearchResult'); } } diff --git a/src/app/core/metadata/metadata-field.model.ts b/src/app/core/metadata/metadata-field.model.ts index e451398fab..b4a20924b9 100644 --- a/src/app/core/metadata/metadata-field.model.ts +++ b/src/app/core/metadata/metadata-field.model.ts @@ -51,7 +51,7 @@ export class MetadataField implements ListableObject { return key; } - getRenderType(): string { - return this.constructor.name; + getRenderTypes(): string[] { + return [this.constructor.name]; } } diff --git a/src/app/core/metadata/metadata-schema.model.ts b/src/app/core/metadata/metadata-schema.model.ts index 6859f580c0..f1551327a5 100644 --- a/src/app/core/metadata/metadata-schema.model.ts +++ b/src/app/core/metadata/metadata-schema.model.ts @@ -27,7 +27,7 @@ export class MetadataSchema implements ListableObject { */ namespace: string; - getRenderType(): string { - return this.constructor.name; + getRenderTypes(): string[] { + return [this.constructor.name]; } } diff --git a/src/app/core/shared/browse-entry.model.ts b/src/app/core/shared/browse-entry.model.ts index 067fac2bff..a8b41894f5 100644 --- a/src/app/core/shared/browse-entry.model.ts +++ b/src/app/core/shared/browse-entry.model.ts @@ -29,7 +29,7 @@ export class BrowseEntry implements ListableObject { */ count: number; - getRenderType(): string { - return (this as any).type.value; + getRenderTypes(): string[] { + return [this.constructor.name]; } } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 0a22315598..16f4002b7f 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -146,7 +146,7 @@ export class DSpaceObject implements CacheableObject, ListableObject { }); } - getRenderType(): string { - return this.constructor.name; + getRenderTypes(): string[] { + return [this.constructor.name]; } } diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index 28a889a18f..2f553a58db 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -5,7 +5,7 @@ import { DSpaceObject } from './dspace-object.model'; import { Collection } from './collection.model'; import { RemoteData } from '../data/remote-data'; import { Bitstream } from './bitstream.model'; -import { hasValue, isNotEmpty } from '../../shared/empty.util'; +import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; import { PaginatedList } from '../data/paginated-list'; import { Relationship } from './item-relationships/relationship.model'; import { ResourceType } from './resource-type'; @@ -110,11 +110,11 @@ export class Item extends DSpaceObject { })); } - getRenderType(): string { - const entityType = this.firstMetadataValue('relationship.type'); - if (isNotEmpty(entityType)) { - return entityType; + getRenderTypes(): string[] { + let entityType = this.firstMetadataValue('relationship.type'); + if (isEmpty(entityType)) { + entityType = 'Publication'; } - return 'Publication'; + return [entityType, ...super.getRenderTypes()]; } } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html index ed5d11ef71..23cc3ae285 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html index 4dea5fc879..f9ee1c51b7 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html index 2474c27b6c..72faf6a864 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html index f3fc0d269b..675044294a 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html index 523f524834..378bf43ec2 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html index c409a850cd..4e98f94fb9 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts index 62a257010f..708139da95 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -1,7 +1,4 @@ import { Component } from '@angular/core'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; -import { Context } from '../../../../core/shared/context.model'; import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../core/shared/item.model'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts index 04d66dcf34..5f158158d8 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; -import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; -import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../core/shared/item.model'; +import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; -@metadataRepresentationComponent('Project', MetadataRepresentationType.PlainText) +@listableObjectComponent('Project', ViewMode.ListElement) @Component({ selector: 'ds-project-list-element', styleUrls: ['./project-list-element.component.scss'], diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts index 5fd5d57d81..c00ae53d6c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; -import { metadataRepresentationComponent } from '../../../../../shared/metadata-representation/metadata-representation.decorator'; -import { MetadataRepresentationType } from '../../../../../core/shared/metadata-representation/metadata-representation.model'; import { Item } from '../../../../../core/shared/item.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; -@metadataRepresentationComponent('ProjectSearchResult', MetadataRepresentationType.PlainText) +@listableObjectComponent('ProjectSearchResult', ViewMode.ListElement) @Component({ selector: 'ds-project-search-result-list-element', styleUrls: ['./project-search-result-list-element.component.scss'], diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.ts index 42495fec81..913599b989 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.ts @@ -1,7 +1,7 @@ import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; import { hasNoValue, hasValue } from '../empty.util'; import { Context } from '../../core/shared/context.model'; -import { DEFAULT_ITEM_TYPE } from '../object-collection/shared/listable-object/listable-object.decorator'; +import { Item } from '../../core/shared/item.model'; const map = new Map(); @@ -39,5 +39,5 @@ export function getMetadataRepresentationComponent(entityType: string, mdReprese } return mapForEntity.get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); } - return map.get(DEFAULT_ITEM_TYPE).get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); + return map.get(Item.name).get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); } \ No newline at end of file diff --git a/src/app/shared/object-collection/object-collection.component.html b/src/app/shared/object-collection/object-collection.component.html index b3175aef2b..cd845b5b47 100644 --- a/src/app/shared/object-collection/object-collection.component.html +++ b/src/app/shared/object-collection/object-collection.component.html @@ -3,6 +3,7 @@ [objects]="objects" [hasBorder]="hasBorder" [hideGear]="hideGear" + [context]="context" (paginationChange)="onPaginationChange($event)" (pageChange)="onPageChange($event)" (pageSizeChange)="onPageSizeChange($event)" @@ -15,6 +16,7 @@ [sortConfig]="sortConfig" [objects]="objects" [hideGear]="hideGear" + [context]="context" (paginationChange)="onPaginationChange($event)" (pageChange)="onPageChange($event)" (pageSizeChange)="onPageSizeChange($event)" @@ -27,6 +29,7 @@ [sortConfig]="sortConfig" [objects]="objects" [hideGear]="hideGear" + [context]="context" *ngIf="(currentMode$ | async) === viewModeEnum.DetailedListElement"> diff --git a/src/app/shared/object-collection/object-collection.component.ts b/src/app/shared/object-collection/object-collection.component.ts index 2b25915f1e..175bd3ea53 100644 --- a/src/app/shared/object-collection/object-collection.component.ts +++ b/src/app/shared/object-collection/object-collection.component.ts @@ -24,6 +24,7 @@ export class ObjectCollectionComponent implements OnInit { @Input() sortConfig: SortOptions; @Input() hasBorder = false; @Input() hideGear = false; + @Input() context: string; pageInfo: Observable; /** * An event fired when the page is changed. diff --git a/src/app/shared/object-collection/shared/listable-object.model.ts b/src/app/shared/object-collection/shared/listable-object.model.ts index 62ab24ae33..cef068e47c 100644 --- a/src/app/shared/object-collection/shared/listable-object.model.ts +++ b/src/app/shared/object-collection/shared/listable-object.model.ts @@ -1,5 +1,5 @@ import { TypedObject } from '../../../core/cache/object-cache.reducer'; export interface ListableObject extends TypedObject { - getRenderType(): string; + getRenderTypes(): string[]; } diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 00e78a3d50..45367df857 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -49,6 +49,6 @@ export class ListableObjectComponentLoaderComponent implements OnInit { * @returns {string} */ private getComponent(): GenericConstructor { - return getListableObjectComponent(this.object.getRenderType(), this.viewMode) + return getListableObjectComponent(this.object.getRenderTypes(), this.viewMode, this.context) } } diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts index 092bf8068f..29cd1287a1 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts @@ -1,15 +1,12 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { GenericConstructor } from '../../../../core/shared/generic-constructor'; -import { ListableObject } from '../listable-object.model'; import { Context } from '../../../../core/shared/context.model'; import { hasNoValue, hasValue } from '../../../empty.util'; import { DEFAULT_CONTEXT } from '../../../metadata-representation/metadata-representation.decorator'; -export const DEFAULT_ITEM_TYPE = 'Default'; export const DEFAULT_VIEW_MODE = ViewMode.ListElement; -const listElementMap = new Map(); +const map = new Map(); /** * Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) @@ -21,30 +18,40 @@ export function listableObjectComponent(objectType: string, viewMode: ViewMode, if (hasNoValue(objectType)) { return; } - if (hasNoValue(listElementMap.get(objectType))) { - listElementMap.set(objectType, new Map()); + if (hasNoValue(map.get(objectType))) { + map.set(objectType, new Map()); } - if (hasNoValue(listElementMap.get(objectType).get(viewMode))) { - listElementMap.get(objectType).set(viewMode, new Map()); + if (hasNoValue(map.get(objectType).get(viewMode))) { + map.get(objectType).set(viewMode, new Map()); } - listElementMap.get(objectType).get(viewMode).set(context, component); + map.get(objectType).get(viewMode).set(context, component); }; } -export function getListableObjectComponent(entityType: GenericConstructor | string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { - const mapForType = listElementMap.get(entityType); - if (hasValue(mapForType)) { - const typeAndMDRepMap = mapForType.get(viewMode); - if (hasValue(typeAndMDRepMap)) { - if (hasValue(typeAndMDRepMap.get(context))) { - return typeAndMDRepMap.get(context); +export function getListableObjectComponent(types: string[], viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { + let bestMatch = undefined; + let bestMatchValue = 0; + for (let i = 0; i < types.length; i++) { + const typeMap = map.get(types[i]); + if (hasValue(typeMap)) { + const typeModeMap = typeMap.get(viewMode); + if (hasValue(typeModeMap)) { + if (hasValue(typeModeMap.get(context))) { + console.log(typeModeMap.get(context)); + return typeModeMap.get(context); + } + if (bestMatchValue < 2 && hasValue(typeModeMap.get(DEFAULT_CONTEXT))) { + bestMatchValue = 2; + bestMatch = typeModeMap.get(DEFAULT_CONTEXT); + } } - if (hasValue(typeAndMDRepMap.get(DEFAULT_CONTEXT))) { - return typeAndMDRepMap.get(DEFAULT_CONTEXT); + if (bestMatchValue < 1 && hasValue(typeMap.get(DEFAULT_VIEW_MODE).get(DEFAULT_CONTEXT))) { + bestMatchValue = 1; + bestMatch = typeMap.get(DEFAULT_VIEW_MODE).get(DEFAULT_CONTEXT); } } - return mapForType.get(DEFAULT_VIEW_MODE).get(DEFAULT_CONTEXT); } - return listElementMap.get(DEFAULT_ITEM_TYPE).get(DEFAULT_VIEW_MODE).get(DEFAULT_CONTEXT); + console.log(bestMatch); + return bestMatch; } \ No newline at end of file diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts index c0e3db6348..4a9b4d6380 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts @@ -17,6 +17,12 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search- }) @listableObjectComponent('PublicationSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent('OrgUnitSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent('PersonSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent('JournalSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent('JournalIssueSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent('JournalVolumeSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent('ProjectSearchResult', ViewMode.DetailedListElement) export class ItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/object-detail.component.html b/src/app/shared/object-detail/object-detail.component.html index 400781b6d2..7fef7d9689 100644 --- a/src/app/shared/object-detail/object-detail.component.html +++ b/src/app/shared/object-detail/object-detail.component.html @@ -14,9 +14,9 @@
- +
- - + + diff --git a/src/app/shared/object-detail/object-detail.component.scss b/src/app/shared/object-detail/object-detail.component.scss index 9a077e3e08..e0a4e3abdc 100644 --- a/src/app/shared/object-detail/object-detail.component.scss +++ b/src/app/shared/object-detail/object-detail.component.scss @@ -1,9 +1,9 @@ @import '../../../styles/variables'; @import '../../../styles/mixins'; -ds-wrapper-detail-element ::ng-deep { +:host::ng-deep { div.thumbnail > img { height: $card-thumbnail-height; width: 100%; } -} +} \ No newline at end of file diff --git a/src/app/shared/object-detail/object-detail.component.ts b/src/app/shared/object-detail/object-detail.component.ts index 24df1bf504..93da1bcce6 100644 --- a/src/app/shared/object-detail/object-detail.component.ts +++ b/src/app/shared/object-detail/object-detail.component.ts @@ -16,6 +16,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; +import { Context } from '../../core/shared/context.model'; /** * This component renders a paginated set of results in the detail view. @@ -50,6 +51,7 @@ export class ObjectDetailComponent { * A boolean representing if to hide pagination when there is only a page */ @Input() hidePagerWhenSinglePage = true; + @Input() context: Context; /** * The list of objects to paginate diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts index 0893d6b121..4927b18b9d 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts @@ -1,12 +1,12 @@ import { Component } from '@angular/core'; import { focusShadow } from '../../../../animations/focus'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; -import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.GridElement) -@listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.GridElement) +@listableObjectComponent(Item.name, ViewMode.GridElement) @Component({ selector: 'ds-publication-grid-element', styleUrls: ['./publication-grid-element.component.scss'], diff --git a/src/app/shared/object-grid/object-grid.component.html b/src/app/shared/object-grid/object-grid.component.html index c5cd34608f..f527aa3555 100644 --- a/src/app/shared/object-grid/object-grid.component.html +++ b/src/app/shared/object-grid/object-grid.component.html @@ -13,11 +13,11 @@
- +
- - + + diff --git a/src/app/shared/object-grid/object-grid.component.scss b/src/app/shared/object-grid/object-grid.component.scss index 8f19309d89..fb883a1f07 100644 --- a/src/app/shared/object-grid/object-grid.component.scss +++ b/src/app/shared/object-grid/object-grid.component.scss @@ -1,6 +1,6 @@ $ds-wrapper-grid-spacing: $spacer/2; -ds-wrapper-grid-element ::ng-deep { +:host ::ng-deep { div.thumbnail > img { height: $card-thumbnail-height; width: 100%; diff --git a/src/app/shared/object-grid/object-grid.component.ts b/src/app/shared/object-grid/object-grid.component.ts index d3bfbb8e58..52f6e29d14 100644 --- a/src/app/shared/object-grid/object-grid.component.ts +++ b/src/app/shared/object-grid/object-grid.component.ts @@ -21,6 +21,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; +import { Context } from '../../core/shared/context.model'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -32,12 +33,13 @@ import { ViewMode } from '../../core/shared/view-mode.model'; }) export class ObjectGridComponent implements OnInit { - viewMode = ViewMode.ListElement; + viewMode = ViewMode.GridElement; @Input() config: PaginationComponentOptions; @Input() sortConfig: SortOptions; @Input() hideGear = false; @Input() hidePagerWhenSinglePage = true; + @Input() context: Context; private _objects$: BehaviorSubject>>; @Input() set objects(objects: RemoteData>) { diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html index d5b481f13c..e0eedc22fc 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html @@ -7,7 +7,7 @@
- +

diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 9c1b27e785..73cdf978ac 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; -import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.ListElement) -@listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.ListElement) +@listableObjectComponent(Item.name, ViewMode.ListElement) @Component({ selector: 'ds-publication-list-element', styleUrls: ['./publication-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-type-badge/item-type-badge.component.html b/src/app/shared/object-list/item-type-badge/item-type-badge.component.html index 35d7663801..947970b7e1 100644 --- a/src/app/shared/object-list/item-type-badge/item-type-badge.component.html +++ b/src/app/shared/object-list/item-type-badge/item-type-badge.component.html @@ -1,3 +1,3 @@ -
+
{{ type.toLowerCase() + '.listelement.badge' | translate }}
diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts index 25e97d59f6..08ff67e3f1 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts @@ -3,9 +3,9 @@ import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { metadataRepresentationComponent } from '../../../metadata-representation/metadata-representation.decorator'; -import { DEFAULT_ITEM_TYPE } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { Item } from '../../../../core/shared/item.model'; -@metadataRepresentationComponent(DEFAULT_ITEM_TYPE, MetadataRepresentationType.Item) +@metadataRepresentationComponent(Item.name, MetadataRepresentationType.Item) @Component({ selector: 'ds-item-metadata-list-element', templateUrl: './item-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts index 20d7c9739e..50e2c2a60b 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts @@ -2,11 +2,11 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; import { metadataRepresentationComponent } from '../../../metadata-representation/metadata-representation.decorator'; -import { DEFAULT_ITEM_TYPE } from '../../../object-collection/shared/listable-object/listable-object.decorator'; +import { Item } from '../../../../core/shared/item.model'; -@metadataRepresentationComponent(DEFAULT_ITEM_TYPE, MetadataRepresentationType.PlainText) +@metadataRepresentationComponent(Item.name, MetadataRepresentationType.PlainText) // For now, authority controlled fields are rendered the same way as plain text fields -@metadataRepresentationComponent(DEFAULT_ITEM_TYPE, MetadataRepresentationType.AuthorityControlled) +@metadataRepresentationComponent(Item.name, MetadataRepresentationType.AuthorityControlled) @Component({ selector: 'ds-plain-text-metadata-list-element', templateUrl: './plain-text-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts index 5668ece14e..1e74487a97 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts @@ -46,6 +46,7 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initWorkflowItem(this.dso.workflowitem as Observable>); } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index 6ff9afd0d7..31d2977304 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; @@ -17,12 +17,14 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme templateUrl: './item-search-result-list-element-submission.component.html' }) -@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement, Context.Submission) -export class ItemSearchResultListElementSubmissionComponent extends SearchResultListElementComponent { +@listableObjectComponent(ItemSearchResult.name, ViewMode.ListElement, Context.Submission) +export class ItemSearchResultListElementSubmissionComponent extends SearchResultListElementComponent implements OnInit { + ngOnInit() { + super.ngOnInit(); + } /** * Represent item's status */ public status = MyDspaceItemStatusType.ARCHIVED; - } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts index 3ec85ae040..92e0ea3818 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts @@ -51,6 +51,7 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initWorkflowItem(this.dso.workflowitem as Observable>); } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts index d5ac65c740..6a9013b9af 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts @@ -39,6 +39,7 @@ export class WorkflowItemSearchResultListElementComponent extends SearchResultLi * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initItem(this.dso.item as Observable> ); } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts index e4d8409f1c..dd32f56aba 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts @@ -39,6 +39,7 @@ export class WorkspaceItemSearchResultListElementComponent extends SearchResultL * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initItem(this.dso.item as Observable>); } diff --git a/src/app/shared/object-list/object-list.component.html b/src/app/shared/object-list/object-list.component.html index b19daa035a..daec1db8ad 100644 --- a/src/app/shared/object-list/object-list.component.html +++ b/src/app/shared/object-list/object-list.component.html @@ -12,7 +12,7 @@ (paginationChange)="onPaginationChange($event)">
  • - +
diff --git a/src/app/shared/object-list/object-list.component.ts b/src/app/shared/object-list/object-list.component.ts index cf4728464a..0776134e83 100644 --- a/src/app/shared/object-list/object-list.component.ts +++ b/src/app/shared/object-list/object-list.component.ts @@ -13,6 +13,7 @@ import { fadeIn } from '../animations/fade'; import { ListableObject } from '../object-collection/shared/listable-object.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; +import { Context } from '../../core/shared/context.model'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -29,6 +30,7 @@ export class ObjectListComponent { @Input() hasBorder = false; @Input() hideGear = false; @Input() hidePagerWhenSinglePage = true; + @Input() context: Context; private _objects: RemoteData>; @Input() set objects(objects: RemoteData>) { this._objects = objects; diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts index 1a678dddb7..014763c53a 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts @@ -6,7 +6,6 @@ import { Collection } from '../../../../core/shared/collection.model'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { BrowseEntry } from '../../../../core/shared/browse-entry.model'; @Component({ selector: 'ds-collection-search-result-list-element', diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html index f6bfe787cb..62b9bc5e74 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html @@ -1,13 +1,13 @@ - + - - - + + + (, , ) -
- - -
-
+
+ + +
+
From bafb2f349064f4b9ea9c3267a198da5d34b9abb8 Mon Sep 17 00:00:00 2001 From: lotte Date: Mon, 14 Oct 2019 16:27:08 +0200 Subject: [PATCH 09/17] fixed existing tests and added linkType --- .../item-metadata.component.spec.ts | 6 +- .../edit-relationship.component.spec.ts | 3 +- .../modify-item-overview.component.spec.ts | 2 +- ...item-page-abstract-field.component.spec.ts | 2 +- .../item-page-author-field.component.spec.ts | 2 +- .../item-page-date-field.component.spec.ts | 2 +- .../generic-item-page-field.component.spec.ts | 2 +- .../item-page-field.component.spec.ts | 5 +- .../item-page-title-field.component.spec.ts | 2 +- .../uri/item-page-uri-field.component.spec.ts | 2 +- .../publication/publication.component.spec.ts | 5 +- .../item-types/shared/item.component.spec.ts | 10 +- ...data-representation-list.component.spec.ts | 2 +- .../related-entities-search.component.spec.ts | 2 +- .../+my-dspace-page/my-dspace-page.module.ts | 4 +- .../search-results.component.html | 1 + .../search-results.component.ts | 3 + .../journal-issue-grid-element.component.html | 2 +- ...urnal-issue-grid-element.component.spec.ts | 65 +++++-- ...journal-volume-grid-element.component.html | 2 +- ...rnal-volume-grid-element.component.spec.ts | 67 +++++--- .../journal-grid-element.component.html | 2 +- .../journal-grid-element.component.spec.ts | 64 +++++-- ...-search-result-grid-element.component.html | 14 +- ...arch-result-grid-element.component.spec.ts | 2 +- ...-search-result-grid-element.component.html | 14 +- ...arch-result-grid-element.component.spec.ts | 2 +- ...-search-result-grid-element.component.html | 20 ++- ...arch-result-grid-element.component.spec.ts | 2 +- .../journal-issue-list-element.component.html | 2 +- ...urnal-issue-list-element.component.spec.ts | 113 ++++-------- ...journal-volume-list-element.component.html | 2 +- ...rnal-volume-list-element.component.spec.ts | 112 ++++-------- .../journal-list-element.component.html | 2 +- .../journal-list-element.component.spec.ts | 92 ++++------ ...-search-result-list-element.component.html | 5 +- ...arch-result-list-element.component.spec.ts | 2 +- ...-search-result-list-element.component.html | 5 +- ...arch-result-list-element.component.spec.ts | 2 +- ...-search-result-list-element.component.html | 5 +- ...arch-result-list-element.component.spec.ts | 2 +- .../journal-issue.component.html | 2 +- .../journal-volume.component.html | 2 +- .../item-pages/journal/journal.component.html | 2 +- .../journal/journal.component.spec.ts | 5 +- .../orgunit-grid-element.component.html | 2 +- .../orgunit-grid-element.component.spec.ts | 65 ++++--- .../person/person-grid-element.component.html | 2 +- .../person-grid-element.component.spec.ts | 65 ++++--- .../project-grid-element.component.html | 2 +- .../project-grid-element.component.spec.ts | 64 +++++-- ...-search-result-grid-element.component.html | 26 +-- ...arch-result-grid-element.component.spec.ts | 2 +- ...-search-result-grid-element.component.html | 21 ++- ...arch-result-grid-element.component.spec.ts | 2 +- ...-search-result-grid-element.component.html | 16 +- ...arch-result-grid-element.component.spec.ts | 2 +- ...unit-item-page-list-element.component.html | 10 +- ...rgunit-item-page-list-element.component.ts | 6 +- .../orgunit-list-element.component.html | 2 +- .../orgunit-list-element.component.spec.ts | 91 ++++------ ...rson-item-page-list-element.component.html | 10 +- ...person-item-page-list-element.component.ts | 5 +- .../person/person-list-element.component.html | 2 +- .../person-list-element.component.spec.ts | 88 ++++------ .../project-list-element.component.html | 2 +- .../project-list-element.component.spec.ts | 97 +++++------ ...-search-result-list-element.component.html | 9 +- ...arch-result-list-element.component.spec.ts | 2 +- ...-search-result-list-element.component.html | 9 +- ...arch-result-list-element.component.spec.ts | 2 +- ...-search-result-list-element.component.html | 35 ++-- ...arch-result-list-element.component.spec.ts | 2 +- .../item-pages/orgunit/orgunit.component.html | 2 +- .../item-pages/person/person.component.html | 18 +- .../item-pages/project/project.component.html | 2 +- .../dso-input-suggestions.component.html | 6 +- .../dso-input-suggestions.component.ts | 2 + .../input-suggestions.component.scss | 10 -- .../collection-element-link.type.ts | 3 + .../object-collection.component.html | 3 + .../object-collection.component.ts | 8 +- ...-object-component-loader.component.spec.ts | 90 ---------- ...table-object-component-loader.component.ts | 3 + .../listable-object.decorator.ts | 2 - .../abstract-listable-element.component.ts | 6 +- ...ch-result-detail-element.component.spec.ts | 9 +- .../item-detail-preview.component.html | 2 +- .../item-detail-preview.component.spec.ts | 2 +- ...ch-result-detail-element.component.spec.ts | 6 +- ...earch-result-detail-element.component.html | 0 ...ch-result-detail-element.component.spec.ts | 6 +- ...-search-result-detail-element.component.ts | 0 ...ch-result-detail-element.component.spec.ts | 5 +- ...earch-result-detail-element.component.html | 0 ...earch-result-detail-element.component.scss | 0 ...ch-result-detail-element.component.spec.ts | 5 +- ...-search-result-detail-element.component.ts | 0 .../object-detail/object-detail.component.ts | 2 + .../collection-grid-element.component.html | 11 +- .../community-grid-element.component.html | 11 +- .../publication-grid-element.component.html | 2 +- ...publication-grid-element.component.spec.ts | 74 ++------ .../object-grid/object-grid.component.html | 2 +- .../object-grid/object-grid.component.ts | 2 + ...-search-result-grid-element.component.html | 10 +- ...-search-result-grid-element.component.html | 11 +- ...-search-result-grid-element.component.html | 23 ++- ...arch-result-grid-element.component.spec.ts | 4 +- .../browse-entry-list-element.component.html | 13 +- .../collection-list-element.component.html | 5 +- .../community-list-element.component.html | 5 +- .../publication-list-element.component.html | 2 +- ...publication-list-element.component.spec.ts | 161 ++++-------------- .../item-type-badge.component.spec.ts | 8 +- ...em-metadata-list-element.component.spec.ts | 1 + .../item-metadata-list-element.component.ts | 3 +- ...a-representation-list-element.component.ts | 3 - ...xt-metadata-list-element.component.spec.ts | 1 + ...in-text-metadata-list-element.component.ts | 5 +- ...arch-result-list-element.component.spec.ts | 10 +- ...-list-element-submission.component.spec.ts | 4 +- ...arch-result-list-element.component.spec.ts | 9 +- ...arch-result-list-element.component.spec.ts | 11 +- ...arch-result-list-element.component.spec.ts | 9 +- .../object-list/object-list.component.html | 2 +- .../object-list/object-list.component.ts | 2 + ...-search-result-list-element.component.html | 3 +- ...arch-result-list-element.component.spec.ts | 4 +- ...-search-result-list-element.component.html | 3 +- ...arch-result-list-element.component.spec.ts | 3 +- ...-search-result-list-element.component.html | 8 +- ...arch-result-list-element.component.spec.ts | 105 ++++++------ 133 files changed, 941 insertions(+), 1088 deletions(-) create mode 100644 src/app/shared/object-collection/collection-element-link.type.ts delete mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts rename src/app/shared/object-detail/my-dspace-result-detail-element/{pool-my-dspace-result => pool-search-result}/pool-search-result-detail-element.component.html (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{pool-my-dspace-result => pool-search-result}/pool-search-result-detail-element.component.spec.ts (93%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{pool-my-dspace-result => pool-search-result}/pool-search-result-detail-element.component.ts (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspace-item-my-dspace-result => workspace-item-search-result}/workspace-item-search-result-detail-element.component.html (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspace-item-my-dspace-result => workspace-item-search-result}/workspace-item-search-result-detail-element.component.scss (100%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspace-item-my-dspace-result => workspace-item-search-result}/workspace-item-search-result-detail-element.component.spec.ts (93%) rename src/app/shared/object-detail/my-dspace-result-detail-element/{workspace-item-my-dspace-result => workspace-item-search-result}/workspace-item-search-result-detail-element.component.ts (100%) diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts index b9a793eddd..0c164b7bc2 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts @@ -216,9 +216,9 @@ describe('ItemMetadataComponent', () => { }); it('it should call reinstateFieldUpdates on the objectUpdatesService with the correct url and metadata', () => { - expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.object.metadataAsList); - expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.object, { metadata: Metadata.toMetadataMap(comp.object.metadataAsList) })); - expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.object.metadataAsList); + expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.item.metadataAsList); + expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.item, { metadata: Metadata.toMetadataMap(comp.item.metadataAsList) })); + expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.item.metadataAsList); }); }); diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts index 55f97000e7..b90543d6ca 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts @@ -5,7 +5,6 @@ import { ObjectUpdatesService } from '../../../../core/data/object-updates/objec import { NO_ERRORS_SCHEMA } from '@angular/core'; import { EditRelationshipComponent } from './edit-relationship.component'; import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model'; -import { ResourceType } from '../../../../core/shared/resource-type'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { Item } from '../../../../core/shared/item.model'; @@ -113,7 +112,7 @@ describe('EditRelationshipComponent', () => { comp.url = url; comp.fieldUpdate = fieldUpdate1; - comp.object = item; + comp.item = item; fixture.detectChanges(); }); diff --git a/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts b/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts index d0c875d2d3..07ad9a347c 100644 --- a/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts +++ b/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts @@ -32,7 +32,7 @@ describe('ModifyItemOverviewComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ModifyItemOverviewComponent); comp = fixture.componentInstance; - comp.object = mockItem; + comp.item = mockItem; fixture.detectChanges(); }); diff --git a/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts index 219da338eb..9461ee0950 100644 --- a/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageAbstractFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageAbstractFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts index 5647c7cc11..d865caff8a 100644 --- a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts @@ -32,7 +32,7 @@ describe('ItemPageAuthorFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageAuthorFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(field, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(field, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts index 760398e1f5..2adada582b 100644 --- a/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageDateFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageDateFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts index 2bfff14dd6..d8abd39cf3 100644 --- a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts @@ -33,7 +33,7 @@ describe('GenericItemPageFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(GenericItemPageFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); comp.fields = mockFields; comp.label = mockLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts index 4db4e06ce6..6e5ed2c535 100644 --- a/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts @@ -4,12 +4,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Item } from '../../../../core/shared/item.model'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; -import { Observable } from 'rxjs'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { ItemPageFieldComponent } from './item-page-field.component'; import { MetadataValuesComponent } from '../../../field-components/metadata-values/metadata-values.component'; -import { of as observableOf } from 'rxjs'; import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; @@ -40,7 +37,7 @@ describe('ItemPageFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); comp.fields = mockFields; comp.label = mockLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts index 17ce39dd18..cb1ba6a4bc 100644 --- a/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageTitleFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageTitleFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts index 60d2f5c97c..4511f16aae 100644 --- a/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageUriFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageUriFieldComponent); comp = fixture.componentInstance; - comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts b/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts index db2c07c63a..5b17f7bbd4 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts @@ -3,19 +3,16 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { By } from '@angular/platform-browser'; import { createRelationshipsObservable } from '../shared/item.component.spec'; import { PublicationComponent } from './publication.component'; -import { of as observableOf } from 'rxjs'; import { MetadataMap } from '../../../../core/shared/metadata.models'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; @@ -45,7 +42,6 @@ describe('PublicationComponent', () => { })], declarations: [PublicationComponent, GenericItemPageFieldComponent, TruncatePipe], providers: [ - {provide: ITEM, useValue: mockItem}, {provide: ItemDataService, useValue: {}}, {provide: SearchFixedFilterService, useValue: searchFixedFilterServiceStub}, {provide: TruncatableService, useValue: {}} @@ -60,6 +56,7 @@ describe('PublicationComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(PublicationComponent); comp = fixture.componentInstance; + comp.object = mockItem; fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts index e6880c3c90..f436b2f767 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts @@ -7,17 +7,14 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { isNotEmpty } from '../../../../shared/empty.util'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model'; import { PaginatedList } from '../../../../core/data/paginated-list'; -import { RemoteData } from '../../../../core/data/remote-data'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { ItemComponent } from './item.component'; -import { of as observableOf } from 'rxjs'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { VarDirective } from '../../../../shared/utils/var.directive'; import { Observable } from 'rxjs/internal/Observable'; @@ -56,7 +53,6 @@ export function getItemPageFieldsTest(mockItem: Item, component) { })], declarations: [component, GenericItemPageFieldComponent, TruncatePipe], providers: [ - {provide: ITEM, useValue: mockItem}, {provide: ItemDataService, useValue: {}}, {provide: SearchFixedFilterService, useValue: searchFixedFilterServiceStub}, {provide: TruncatableService, useValue: {}} @@ -71,6 +67,7 @@ export function getItemPageFieldsTest(mockItem: Item, component) { beforeEach(async(() => { fixture = TestBed.createComponent(component); comp = fixture.componentInstance; + comp.object = mockItem; fixture.detectChanges(); })); @@ -386,10 +383,6 @@ describe('ItemComponent', () => { } }), BrowserAnimationsModule], declarations: [ItemComponent, VarDirective], - providers: [ - {provide: ITEM, useValue: mockItem} - ], - schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ItemComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} @@ -399,6 +392,7 @@ describe('ItemComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemComponent); comp = fixture.componentInstance; + comp.object = mockItem; fixture.detectChanges(); representations = comp.buildRepresentations('bogus', metadataField); })); diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts index dcdfc1ccea..6795e36440 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts @@ -33,7 +33,7 @@ describe('MetadataRepresentationListComponent', () => { })); it(`should load ${representations.length} item-type-switcher components`, () => { - const fields = fixture.debugElement.queryAll(By.css('ds-listable-object-component-loader')); + const fields = fixture.debugElement.queryAll(By.css('ds-metadata-representation-loader')); expect(fields.length).toBe(representations.length); }); diff --git a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts index bc2571f6f9..711e1b9d3d 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts +++ b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts @@ -38,7 +38,7 @@ describe('RelatedEntitiesSearchComponent', () => { comp = fixture.componentInstance; fixedFilterService = (comp as any).fixedFilterService; comp.relationType = mockRelationType; - comp.object = mockItem; + comp.item = mockItem; comp.relationEntityType = mockRelationEntityType; fixture.detectChanges(); }); diff --git a/src/app/+my-dspace-page/my-dspace-page.module.ts b/src/app/+my-dspace-page/my-dspace-page.module.ts index 685f1155be..be14aebdea 100644 --- a/src/app/+my-dspace-page/my-dspace-page.module.ts +++ b/src/app/+my-dspace-page/my-dspace-page.module.ts @@ -12,7 +12,7 @@ import { ClaimedSearchResultListElementComponent } from '../shared/object-list/m import { PoolSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component'; import { MyDSpaceNewSubmissionComponent } from './my-dspace-new-submission/my-dspace-new-submission.component'; import { ItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component'; -import { WorkspaceItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component'; +import { WorkspaceItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component'; import { WorkflowItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component'; import { ClaimedTaskSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component'; import { MyDSpaceGuard } from './my-dspace.guard'; @@ -20,7 +20,7 @@ import { MyDSpaceConfigurationService } from './my-dspace-configuration.service' import { SearchResultListElementComponent } from '../shared/object-list/search-result-list-element/search-result-list-element.component'; import { ItemSearchResultListElementSubmissionComponent } from '../shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component'; import { WorkflowItemSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component'; -import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component'; +import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component'; @NgModule({ imports: [ diff --git a/src/app/+search-page/search-results/search-results.component.html b/src/app/+search-page/search-results/search-results.component.html index 5a1e89858b..c08a4f023f 100644 --- a/src/app/+search-page/search-results/search-results.component.html +++ b/src/app/+search-page/search-results/search-results.component.html @@ -4,6 +4,7 @@ [config]="searchConfig.pagination" [sortConfig]="searchConfig.sort" [objects]="searchResults" + [linkType]="linkType" [hideGear]="true">
diff --git a/src/app/+search-page/search-results/search-results.component.ts b/src/app/+search-page/search-results/search-results.component.ts index 8ec7b1cae4..46d15d97d9 100644 --- a/src/app/+search-page/search-results/search-results.component.ts +++ b/src/app/+search-page/search-results/search-results.component.ts @@ -8,6 +8,7 @@ import { PaginatedList } from '../../core/data/paginated-list'; import { hasNoValue, isNotEmpty } from '../../shared/empty.util'; import { SortOptions } from '../../core/cache/models/sort-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; +import { CollectionElementLinkType } from '../../shared/object-collection/collection-element-link.type'; @Component({ selector: 'ds-search-results', @@ -24,6 +25,8 @@ import { ViewMode } from '../../core/shared/view-mode.model'; export class SearchResultsComponent { hasNoValue = hasNoValue; + @Input() linkType: CollectionElementLinkType; + /** * The actual search result objects */ diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html index fab0cf5c07..fb69ed92f5 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts index d13feda406..4ad7770e1e 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts @@ -1,15 +1,19 @@ import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { JournalIssueGridElementComponent } from './journal-issue-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; +import { of as observableOf } from 'rxjs'; +import { async, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -33,18 +37,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('JournalIssueGridElementComponent', + () => { + let comp; + let fixture; -describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title'])); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [JournalIssueGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalIssueGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalIssueGridElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the journal issue is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a JournalIssueSearchResultGridElementComponent`, () => { + const journalIssueGridElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-grid-element`)); + expect(journalIssueGridElement).not.toBeNull(); + }); + }); + + }); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html index 06bcb10c4d..53713b47ee 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts index 8c854aeb77..427f1db3cd 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts @@ -1,15 +1,19 @@ import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; -import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { JournalVolumeGridElementComponent } from './journal-volume-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; +import { of as observableOf } from 'rxjs'; +import { async, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { JournalIssueGridElementComponent } from '../journal-issue/journal-issue-grid-element.component'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -33,18 +37,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('JournalVolumeGridElementComponent', + () => { + let comp; + let fixture; -describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description'])); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [JournalVolumeGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalVolumeGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalVolumeGridElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the journal volume is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a JournalVolumeSearchResultGridElementComponent`, () => { + const journalVolumeGridElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-grid-element`)); + expect(journalVolumeGridElement).not.toBeNull(); + }); + }); + + }); \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html index 1a7a6f5da8..594a0e0dc1 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts index 0d0f77842a..d0f3753840 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts @@ -1,15 +1,18 @@ import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { JournalGridElementComponent } from './journal-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; +import { async, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -39,18 +42,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('JournalGridElementComponent', + () => { + let comp; + let fixture; -describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description'])); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [JournalGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalGridElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the journal is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a JournalGridElementComponent`, () => { + const journalGridElement = fixture.debugElement.query(By.css(`ds-journal-search-result-grid-element`)); + expect(journalGridElement).not.toBeNull(); + }); + }); + + }); \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html index 23cc3ae285..18ff77bf23 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -1,15 +1,21 @@
- +
+ +
+ + +
+
-

+

@@ -21,8 +27,8 @@

-
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts index 6619694f88..3cca9071b0 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts @@ -46,4 +46,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title'])); +describe('JournalIssueSearchResultGridElementComponent', getEntityGridElementTestComponent(JournalIssueSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html index f9ee1c51b7..07e50eb6fb 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -1,11 +1,17 @@
- +
- +
+ +
+ + +
+
@@ -21,8 +27,8 @@

-
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts index bcdde289e0..8923b15ccb 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts @@ -46,4 +46,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description'])); +describe('JournalVolumeSearchResultGridElementComponent', getEntityGridElementTestComponent(JournalVolumeSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html index 72faf6a864..394e5241e1 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -1,23 +1,29 @@
- +
- +
+ +
+ + +
+
-

+

- {{dso.firstMetadataValue('creativework.editor')}} + {{firstMetadataValue('creativework.editor')}} , - {{dso.firstMetadataValue('creativework.publisher')}} + {{firstMetadataValue('creativework.publisher')}}

@@ -26,8 +32,8 @@

-
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts index 1ce0aa2436..5712b211ff 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts @@ -52,4 +52,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description'])); +describe('JournalSearchResultGridElementComponent', getEntityGridElementTestComponent(JournalSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description'])); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html index 1e418ba7c2..398feea260 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts index d1cf67a07e..1a06e9f29c 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { JournalIssueListElementComponent } from './journal-issue-list-element.component'; @@ -7,10 +7,7 @@ import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -let journalIssueListElementComponent: JournalIssueListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -33,83 +30,43 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); -describe('JournalIssueListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ JournalIssueListElementComponent , TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: {} } - ], +describe('JournalIssueListElementComponent', + () => { + let comp; + let fixture; - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(JournalIssueListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalIssueListElementComponent); - journalIssueListElementComponent = fixture.componentInstance; + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [JournalIssueListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalIssueListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalIssueListElementComponent); + comp = fixture.componentInstance; + })); - describe('When the item has a journal identifier', () => { - beforeEach(() => { - journalIssueListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); + describe(`when the journal issue is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a JournalIssueListElementComponent`, () => { + const journalIssueListElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-list-element`)); + expect(journalIssueListElement).not.toBeNull(); + }); }); - it('should show the journal issues span', () => { - const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues')); - expect(journalIdentifierField).not.toBeNull(); - }); - }); - - describe('When the item has no journal identifier', () => { - beforeEach(() => { - journalIssueListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the journal issues span', () => { - const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues')); - expect(journalIdentifierField).toBeNull(); - }); - }); - - describe('When the item has a journal number', () => { - beforeEach(() => { - journalIssueListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); - }); - - it('should show the journal issue numbers span', () => { - const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers')); - expect(journalNumberField).not.toBeNull(); - }); - }); - - describe('When the item has no journal number', () => { - beforeEach(() => { - journalIssueListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the journal issue numbers span', () => { - const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers')); - expect(journalNumberField).toBeNull(); - }); - }); -}); + }); \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html index c00de1c33d..bf967e6e78 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts index 2ab4c1eaed..0d1401068b 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { JournalVolumeListElementComponent } from './journal-volume-list-element.component'; @@ -7,10 +7,7 @@ import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -let journalVolumeListElementComponent: JournalVolumeListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -33,83 +30,42 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('JournalVolumeListElementComponent', + () => { + let comp; + let fixture; -describe('JournalVolumeListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ JournalVolumeListElementComponent , TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: {} } - ], + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(JournalVolumeListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [JournalVolumeListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalVolumeListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalVolumeListElementComponent); - journalVolumeListElementComponent = fixture.componentInstance; + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalVolumeListElementComponent); + comp = fixture.componentInstance; + })); - })); + describe(`when the journal volume is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); - describe('When the item has a journal title', () => { - beforeEach(() => { - journalVolumeListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); + it(`should contain a JournalVolumeListElementComponent`, () => { + const journalVolumeListElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-list-element`)); + expect(journalVolumeListElement).not.toBeNull(); + }); }); - it('should show the journal title span', () => { - const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes')); - expect(journalTitleField).not.toBeNull(); - }); - }); - - describe('When the item has no journal title', () => { - beforeEach(() => { - journalVolumeListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the journal title span', () => { - const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes')); - expect(journalTitleField).toBeNull(); - }); - }); - - describe('When the item has a journal identifier', () => { - beforeEach(() => { - journalVolumeListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); - }); - - it('should show the journal identifiers span', () => { - const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers')); - expect(journalIdentifierField).not.toBeNull(); - }); - }); - - describe('When the item has no journal identifier', () => { - beforeEach(() => { - journalVolumeListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the journal identifiers span', () => { - const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers')); - expect(journalIdentifierField).toBeNull(); - }); - }); -}); + }); \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html index 3df361e7f9..3e4dfb0b48 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts index c9567fc731..432f81c171 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts @@ -1,17 +1,13 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { JournalListElementComponent } from './journal-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -let journalListElementComponent: JournalListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -28,60 +24,44 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); -describe('JournalListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ JournalListElementComponent , TruncatePipe], - providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, - { provide: TruncatableService, useValue: {} } - ], - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(JournalListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); +describe('JournalListElementComponent', + () => { + let comp; + let fixture; - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalListElementComponent); - journalListElementComponent = fixture.componentInstance; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [JournalListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - describe('When the item has an issn', () => { - beforeEach(() => { - journalListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalListElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the journal is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a JournalListElementComponent`, () => { + const journalListElement = fixture.debugElement.query(By.css(`ds-journal-search-result-list-element`)); + expect(journalListElement).not.toBeNull(); + }); }); - it('should show the journals span', () => { - const issnField = fixture.debugElement.query(By.css('span.item-list-journals')); - expect(issnField).not.toBeNull(); - }); - }); - - describe('When the item has no issn', () => { - beforeEach(() => { - journalListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the journals span', () => { - const issnField = fixture.debugElement.query(By.css('span.item-list-journals')); - expect(issnField).toBeNull(); - }); - }); -}); + }); \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html index 98a8472975..38094c5c79 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html @@ -1,8 +1,11 @@ - + { +describe('JournalIssueSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html index 9af28297d8..460c4a2187 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html @@ -1,8 +1,11 @@ - + { +describe('JournalVolumeSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe], diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html index 20b689327a..a43132d332 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html @@ -1,8 +1,11 @@ - + { +describe('JournalSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [JournalSearchResultListElementComponent, TruncatePipe], diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index d49d80b15e..4b306b73f2 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -4,7 +4,7 @@
- +
- +
- + { })], declarations: [JournalComponent, GenericItemPageFieldComponent, TruncatePipe], providers: [ - {provide: ITEM, useValue: mockItem}, {provide: ItemDataService, useValue: {}}, {provide: TruncatableService, useValue: {}} ], @@ -69,6 +65,7 @@ describe('JournalComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(JournalComponent); comp = fixture.componentInstance; + comp.object = mockItem; fixture.detectChanges(); })); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html index 8ad7ce3590..f42ffb87e9 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts index 15c7b75bf5..1140f7d908 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts @@ -1,15 +1,17 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { OrgunitGridElementComponent } from './orgunit-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; +import { async, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -39,18 +41,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('OrgunitGridElementComponent', + () => { + let comp; + let fixture; -describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [OrgunitGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(OrgunitGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgunitGridElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the org unit is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a OrgunitGridElementComponent`, () => { + const orgunitGridElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-grid-element`)); + expect(orgunitGridElement).not.toBeNull(); + }); + }); + + }); \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html index b837422121..a431f5979f 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts index 25268261e1..fdcc84d864 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts @@ -1,15 +1,17 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { PersonGridElementComponent } from './person-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; +import { async, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -33,18 +35,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('PersonGridElementComponent', + () => { + let comp; + let fixture; -describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle'])); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [PersonGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PersonGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonGridElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the person is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a PersonGridElementComponent`, () => { + const personGridElement = fixture.debugElement.query(By.css(`ds-person-search-result-grid-element`)); + expect(personGridElement).not.toBeNull(); + }); + }); + + }); \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html index 094d109dde..0c87599399 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts index 969912976c..701ca46a73 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts @@ -6,10 +6,15 @@ import { ProjectGridElementComponent } from './project-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; +import { async, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { PersonGridElementComponent } from '../person/person-grid-element.component'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -27,18 +32,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('ProjectGridElementComponent', + () => { + let comp; + let fixture; -describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description'])); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [ProjectGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(ProjectGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(ProjectGridElementComponent); + comp = fixture.componentInstance; + })); + + describe(`when the project is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a ProjectGridElementComponent`, () => { + const projectGridElement = fixture.debugElement.query(By.css(`ds-project-search-result-grid-element`)); + expect(projectGridElement).not.toBeNull(); + }); + }); + + }); \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html index 675044294a..5c42be2b24 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html @@ -1,34 +1,40 @@
- +
+ +
+ + +
+
-

+

-

+

+ class="item-location card-text"> - {{dso.firstMetadataValue('organization.address.addressCountry')}} - + {{firstMetadataValue('organization.address.addressCountry')}} + , - {{dso.firstMetadataValue('organization.address.addressLocality')}} + {{firstMetadataValue('organization.address.addressLocality')}}

-
- View +
+ View
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts index 579161f940..bb4cb93a70 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts @@ -52,4 +52,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); +describe('OrgunitSearchResultGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html index 378bf43ec2..b7eed7c8b4 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -1,28 +1,35 @@
- +
- +
+ +
+ + +
+
-

+

-

+

-

+

-
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts index 6a5c79c770..05baa7a63f 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts @@ -46,4 +46,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle'])); +describe('PersonSearchResultGridElementComponent', getEntityGridElementTestComponent(PersonSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html index 4e98f94fb9..f3a0dea81f 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -1,23 +1,29 @@
- +
+ +
+ + +
+
-

+

-

+

-
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts index 64fedf155d..a9c0774c8c 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts @@ -40,4 +40,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description'])); +describe('ProjectSearchResultGridElementComponent', getEntityGridElementTestComponent(ProjectSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description'])); diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html index bacec900c0..bdeb37dcd8 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html @@ -1,13 +1,13 @@ - - + - - + diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts index 708139da95..2025faac75 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -1,8 +1,7 @@ import { Component } from '@angular/core'; -import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { Item } from '../../../../core/shared/item.model'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; @metadataRepresentationComponent('OrgUnit', MetadataRepresentationType.Item) @Component({ @@ -12,5 +11,6 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep /** * The component for displaying a list element for an item of the type OrgUnit */ -export class OrgunitItemPageListElementComponent extends AbstractListableElementComponent { +export class OrgunitItemPageListElementComponent { + metadataRepresentation: ItemMetadataRepresentation; } diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html index 246bac000c..ad0eec0313 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts index f1ff6b1dce..d0254e675d 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts @@ -1,17 +1,13 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { OrgUnitListElementComponent } from './orgunit-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -let orgUnitListElementComponent: OrgUnitListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -28,60 +24,43 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); -describe('OrgUnitListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ OrgUnitListElementComponent , TruncatePipe], - providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, - { provide: TruncatableService, useValue: {} } - ], +describe('OrgunitListElementComponent', + () => { + let comp; + let fixture; - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(OrgUnitListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - fixture = TestBed.createComponent(OrgUnitListElementComponent); - orgUnitListElementComponent = fixture.componentInstance; + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [OrgUnitListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(OrgUnitListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgUnitListElementComponent); + comp = fixture.componentInstance; + })); - describe('When the item has an orgunit description', () => { - beforeEach(() => { - orgUnitListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); + describe(`when the orgunit is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a OrgUnitListElementComponent`, () => { + const orgunitListElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-list-element`)); + expect(orgunitListElement).not.toBeNull(); + }); }); - it('should show the description span', () => { - const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); - expect(orgunitDescriptionField).not.toBeNull(); - }); - }); - - describe('When the item has no orgunit description', () => { - beforeEach(() => { - orgUnitListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the description span', () => { - const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); - expect(orgunitDescriptionField).toBeNull(); - }); - }); -}); + }); \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html index e9627b504e..fdc9dd8943 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html @@ -1,15 +1,15 @@ - - + - - + diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts index 696640dae5..6679852cdb 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts @@ -3,6 +3,8 @@ import { AbstractListableElementComponent } from '../../../../shared/object-coll import { Item } from '../../../../core/shared/item.model'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { MetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; @metadataRepresentationComponent('Person', MetadataRepresentationType.Item) @Component({ @@ -12,5 +14,6 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep /** * The component for displaying a list element for an item of the type Person */ -export class PersonItemPageListElementComponent extends AbstractListableElementComponent { +export class PersonItemPageListElementComponent { + metadataRepresentation: ItemMetadataRepresentation; } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html index 9df315824a..dbc3a42a05 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts index 7d9eaf0d16..acc149c1df 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts @@ -6,11 +6,9 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { OrgUnitListElementComponent } from '../orgunit/orgunit-list-element.component'; -let personListElementComponent: PersonListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -27,59 +25,43 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); -describe('PersonListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ PersonListElementComponent , TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: {} } - ], +describe('PersonListElementComponent', + () => { + let comp; + let fixture; - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(PersonListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - fixture = TestBed.createComponent(PersonListElementComponent); - personListElementComponent = fixture.componentInstance; + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PersonListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PersonListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonListElementComponent); + comp = fixture.componentInstance; + })); - describe('When the item has a job title', () => { - beforeEach(() => { - personListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); + describe(`when the person is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a PersonListElementComponent`, () => { + const personListElement = fixture.debugElement.query(By.css(`ds-person-search-result-list-element`)); + expect(personListElement).not.toBeNull(); + }); }); - it('should show the job title span', () => { - const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); - expect(jobTitleField).not.toBeNull(); - }); - }); - - describe('When the item has no job title', () => { - beforeEach(() => { - personListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the job title span', () => { - const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); - expect(jobTitleField).toBeNull(); - }); - }); -}); + }); \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html index 6d33c48fb4..8f74452eaa 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts index 0c171ae9ba..5591a5b625 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts @@ -1,17 +1,14 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { ProjectListElementComponent } from './project-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; +import { PersonListElementComponent } from '../person/person-list-element.component'; +import { ProjectListElementComponent } from './project-list-element.component'; -let projectListElementComponent: ProjectListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -28,60 +25,42 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { // ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); +describe('ProjectListElementComponent', + () => { + let comp; + let fixture; -describe('ProjectListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ProjectListElementComponent , TruncatePipe], - providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, - { provide: TruncatableService, useValue: {} } - ], + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(ProjectListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ProjectListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(ProjectListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(ProjectListElementComponent); - projectListElementComponent = fixture.componentInstance; + beforeEach(async(() => { + fixture = TestBed.createComponent(ProjectListElementComponent); + comp = fixture.componentInstance; + })); - })); + describe(`when the project is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); - // describe('When the item has a status', () => { - // beforeEach(() => { - // projectListElementComponent.item = mockItemWithMetadata; - // fixture.detectChanges(); - // }); - // - // it('should show the status span', () => { - // const statusField = fixture.debugElement.query(By.css('span.item-list-status')); - // expect(statusField).not.toBeNull(); - // }); - // }); - // - // describe('When the item has no status', () => { - // beforeEach(() => { - // projectListElementComponent.item = mockItemWithoutMetadata; - // fixture.detectChanges(); - // }); - // - // it('should not show the status span', () => { - // const statusField = fixture.debugElement.query(By.css('span.item-list-status')); - // expect(statusField).toBeNull(); - // }); - // }); -}); + it(`should contain a ProjectListElementComponent`, () => { + const projectListElement = fixture.debugElement.query(By.css(`ds-project-search-result-list-element`)); + expect(projectListElement).not.toBeNull(); + }); + }); + + }); \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html index 4b32ac8278..39a7add763 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html @@ -1,8 +1,11 @@ - + + { +describe('OrgUnitSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe], diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html index c3a471c486..b2791c4891 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html @@ -1,8 +1,11 @@ - + + { +describe('PersonSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [PersonSearchResultListElementComponent, TruncatePipe], diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html index df14563102..95bff99e7e 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html @@ -1,16 +1,19 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts index e08e25eb69..128190a88b 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts @@ -48,7 +48,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign( }) }); -describe('ProjectListElementComponent', () => { +describe('ProjectSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ProjectSearchResultListElementComponent, TruncatePipe], diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html index 637e59b4fb..c88eb6d439 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html @@ -4,7 +4,7 @@
- + - {{'person.page.titleprefix' | translate}} + {{'person.page.titleprefix' | translate}}
- + - @@ -14,7 +14,7 @@ - @@ -32,26 +32,26 @@ [items]="orgUnits$ | async" [label]="'relationships.isOrgUnitOf' | translate"> - - -
-
diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index f9596e7f0c..615cd3c6cb 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -4,7 +4,7 @@
- + diff --git a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html index 3e304d9eb3..7515b830b9 100644 --- a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html +++ b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.html @@ -1,5 +1,5 @@
@@ -14,9 +14,7 @@ diff --git a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts index e1e9d18c8f..92775f25c6 100644 --- a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts +++ b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts @@ -3,6 +3,7 @@ import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { InputSuggestionsComponent } from '../input-suggestions.component'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { ViewMode } from '../../../core/shared/view-mode.model'; +import { CollectionElementLinkType } from '../../object-collection/collection-element-link.type'; @Component({ selector: 'ds-dso-input-suggestions', @@ -24,6 +25,7 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; */ export class DsoInputSuggestionsComponent extends InputSuggestionsComponent { viewMode = ViewMode.ListElement; + linkTypes = CollectionElementLinkType; /** * The suggestions that should be shown */ diff --git a/src/app/shared/input-suggestions/input-suggestions.component.scss b/src/app/shared/input-suggestions/input-suggestions.component.scss index eb0db5ed42..263c315d30 100644 --- a/src/app/shared/input-suggestions/input-suggestions.component.scss +++ b/src/app/shared/input-suggestions/input-suggestions.component.scss @@ -5,19 +5,9 @@ white-space: normal; word-break: break-word; padding: $input-padding-y $input-padding-x; - position: relative; - &:focus { outline: none; } - - .click-blocker { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - } } } diff --git a/src/app/shared/object-collection/collection-element-link.type.ts b/src/app/shared/object-collection/collection-element-link.type.ts new file mode 100644 index 0000000000..7bef4cf393 --- /dev/null +++ b/src/app/shared/object-collection/collection-element-link.type.ts @@ -0,0 +1,3 @@ +export enum CollectionElementLinkType { + None, Link, ExternalLink +} \ No newline at end of file diff --git a/src/app/shared/object-collection/object-collection.component.html b/src/app/shared/object-collection/object-collection.component.html index cd845b5b47..199f6d0bcf 100644 --- a/src/app/shared/object-collection/object-collection.component.html +++ b/src/app/shared/object-collection/object-collection.component.html @@ -3,6 +3,7 @@ [objects]="objects" [hasBorder]="hasBorder" [hideGear]="hideGear" + [linkType]="linkType" [context]="context" (paginationChange)="onPaginationChange($event)" (pageChange)="onPageChange($event)" @@ -16,6 +17,7 @@ [sortConfig]="sortConfig" [objects]="objects" [hideGear]="hideGear" + [linkType]="linkType" [context]="context" (paginationChange)="onPaginationChange($event)" (pageChange)="onPageChange($event)" @@ -29,6 +31,7 @@ [sortConfig]="sortConfig" [objects]="objects" [hideGear]="hideGear" + [linkType]="linkType" [context]="context" *ngIf="(currentMode$ | async) === viewModeEnum.DetailedListElement"> diff --git a/src/app/shared/object-collection/object-collection.component.ts b/src/app/shared/object-collection/object-collection.component.ts index 175bd3ea53..2756d38639 100644 --- a/src/app/shared/object-collection/object-collection.component.ts +++ b/src/app/shared/object-collection/object-collection.component.ts @@ -11,6 +11,9 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options import { ListableObject } from './shared/listable-object.model'; import { isNotEmpty } from '../empty.util'; import { ViewMode } from '../../core/shared/view-mode.model'; +import { CollectionElementLinkType } from './collection-element-link.type'; +import { PaginatedList } from '../../core/data/paginated-list'; +import { Context } from '../../core/shared/context.model'; @Component({ selector: 'ds-viewable-collection', @@ -19,12 +22,13 @@ import { ViewMode } from '../../core/shared/view-mode.model'; }) export class ObjectCollectionComponent implements OnInit { - @Input() objects: RemoteData; + @Input() objects: RemoteData>; @Input() config?: PaginationComponentOptions; @Input() sortConfig: SortOptions; @Input() hasBorder = false; @Input() hideGear = false; - @Input() context: string; + @Input() linkType: CollectionElementLinkType; + @Input() context: Context; pageInfo: Observable; /** * An event fired when the page is changed. diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts deleted file mode 100644 index d10ee1a0dd..0000000000 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { PageInfo } from '../../../core/shared/page-info.model'; -import { Item } from '../../../core/shared/item.model'; -import { PaginatedList } from '../../../core/data/paginated-list'; -import * as decorator from '../item-type-decorator'; -import { getComponentByItemType} from '../item-type-decorator'; -import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model'; -import { createSuccessfulRemoteDataObject$ } from '../../testing/utils'; -import createSpy = jasmine.createSpy; -import { ViewMode } from '../../../core/shared/view-mode.model'; - -const relationType = 'type'; -const mockItem: Item = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'test item' - } - ], - 'relationship.type': [ - { - language: 'en_US', - value: relationType - } - ] - } -}); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); -let viewMode = ViewMode.StandalonePage; - -describe('ItemTypeSwitcherComponent', () => { - let comp: ListableObjectComponentLoaderComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ListableObjectComponentLoaderComponent ], - schemas: [ NO_ERRORS_SCHEMA ] - }).compileComponents(); // compile template and css - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(ListableObjectComponentLoaderComponent); - comp = fixture.componentInstance; - comp.object = mockItem; - comp.viewMode = viewMode; - spyOnProperty(decorator, 'getComponentByItemType').and.returnValue(createSpy('getComponentByItemType')) - })); - - describe('when the injected object is of type Item', () => { - beforeEach(() => { - viewMode = ViewMode.StandalonePage; - comp.object = mockItem; - comp.viewMode = viewMode; - }); - - describe('when calling getComponent', () => { - beforeEach(() => { - (comp as any).getComponent(); - }); - - it('should call getComponentByItemType with parameters type and viewMode', () => { - expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode); - }); - }); - }); - - describe('when the injected object is of type MetadataRepresentation', () => { - beforeEach(() => { - viewMode = ViewMode.MetadataField; - comp.object = mockItemMetadataRepresentation; - comp.viewMode = viewMode; - }); - - describe('when calling getComponent', () => { - beforeEach(() => { - (comp as any).getComponent(); - }); - - it('should call getComponentByItemType with parameters type, viewMode and representationType', () => { - expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode, mockItemMetadataRepresentation.representationType); - }); - }); - }); - -}); diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 45367df857..fb315303f6 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -5,6 +5,7 @@ import { Context } from '../../../../core/shared/context.model'; import { getListableObjectComponent } from './listable-object.decorator'; import { GenericConstructor } from '../../../../core/shared/generic-constructor'; import { ListableObjectDirective } from './listable-object.directive'; +import { CollectionElementLinkType } from '../../collection-element-link.type'; @Component({ selector: 'ds-listable-object-component-loader', @@ -28,6 +29,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit { @Input() viewMode: ViewMode; @Input() context: Context; + @Input() linkType: CollectionElementLinkType; @ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective; constructor(private componentFactoryResolver: ComponentFactoryResolver) { @@ -42,6 +44,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit { const componentRef = viewContainerRef.createComponent(componentFactory); (componentRef.instance as any).object = this.object; (componentRef.instance as any).index = this.index; + (componentRef.instance as any).linkType = this.linkType; } /** diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts index 29cd1287a1..6098875b4d 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts @@ -38,7 +38,6 @@ export function getListableObjectComponent(types: string[], viewMode: ViewMode, const typeModeMap = typeMap.get(viewMode); if (hasValue(typeModeMap)) { if (hasValue(typeModeMap.get(context))) { - console.log(typeModeMap.get(context)); return typeModeMap.get(context); } if (bestMatchValue < 2 && hasValue(typeModeMap.get(DEFAULT_CONTEXT))) { @@ -52,6 +51,5 @@ export function getListableObjectComponent(types: string[], viewMode: ViewMode, } } } - console.log(bestMatch); return bestMatch; } \ No newline at end of file diff --git a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts index d6819b04da..6d9f0289dd 100644 --- a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts +++ b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts @@ -1,6 +1,6 @@ -import { Component, Inject, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { ListableObject } from '../listable-object.model'; -import { ViewMode } from '../../../../core/shared/view-mode.model'; +import { CollectionElementLinkType } from '../../collection-element-link.type'; @Component({ selector: 'ds-abstract-object-element', @@ -8,4 +8,6 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; }) export class AbstractListableElementComponent { @Input() object: T; + @Input() linkType: CollectionElementLinkType; + linkTypes = CollectionElementLinkType; } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts index 63520a8f5f..64bdfeff7b 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.spec.ts @@ -6,12 +6,11 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { ClaimedTaskSearchResultDetailElementComponent } from './claimed-task-search-result-detail-element.component'; -import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; let component: ClaimedTaskSearchResultDetailElementComponent; let fixture: ComponentFixture; @@ -55,15 +54,11 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); mockResultObject.indexableObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem) }); -describe('ClaimedMyDSpaceResultDetailElementComponent', () => { +describe('ClaimedTaskSearchResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [ClaimedTaskSearchResultDetailElementComponent], - providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } - ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ClaimedTaskSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html index 04e128c49a..66644d23a9 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.html @@ -15,7 +15,7 @@
- + {{file?.name}} ({{(file?.sizeBytes) | dsFileSize }}) diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts index c5970d751f..7920e54b00 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts @@ -72,7 +72,7 @@ describe('ItemDetailPreviewComponent', () => { fixture = TestBed.createComponent(ItemDetailPreviewComponent); component = fixture.componentInstance; component.object = { hitHighlights: {} } as any; - component.object = mockItem; + component.item = mockItem; component.separator = ', '; spyOn(component.item, 'getFiles').and.returnValue(mockItem.bitstreams); fixture.detectChanges(); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts index 070fedde81..72fbff78ed 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.spec.ts @@ -47,15 +47,11 @@ mockResultObject.indexableObject = Object.assign(new Item(), { } }); -describe('ItemMyDSpaceResultDetailElementComponent', () => { +describe('ItemSearchResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [ItemSearchResultDetailElementComponent], - providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } - ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ItemSearchResultDetailElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.spec.ts similarity index 93% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.spec.ts index b6fd29e8a6..412dd00c13 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.spec.ts @@ -5,12 +5,12 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { PoolSearchResultDetailElementComponent } from './pool-my-dspace-result-detail-element.component'; -import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { PoolSearchResultDetailElementComponent } from './pool-search-result-detail-element.component'; +import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; let component: PoolSearchResultDetailElementComponent; let fixture: ComponentFixture; @@ -54,7 +54,7 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); mockResultObject.indexableObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkflowitem) }); -describe('PoolMyDSpaceResultDetailElementComponent', () => { +describe('PoolSearchResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts index a4f0e3542a..0e1a3bd307 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts @@ -6,11 +6,10 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { WorkflowItemSearchResultDetailElementComponent } from './workflow-item-search-result-detail-element.component'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; let component: WorkflowItemSearchResultDetailElementComponent; let fixture: ComponentFixture; @@ -52,7 +51,7 @@ const item = Object.assign(new Item(), { const rd = createSuccessfulRemoteDataObject(item); mockResultObject.indexableObject = Object.assign(new WorkflowItem(), { item: observableOf(rd) }); -describe('WorkflowitemMyDSpaceResultDetailElementComponent', () => { +describe('WorkflowItemSearchResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.html b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.html similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.html rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.html diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.scss b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.scss similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.scss rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.scss diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts similarity index 93% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts index ebd0d1ba6a..c841bf1dab 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts @@ -6,11 +6,10 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { WorkspaceItemSearchResultDetailElementComponent } from './workspace-item-search-result-detail-element.component'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; let component: WorkspaceItemSearchResultDetailElementComponent; let fixture: ComponentFixture; @@ -52,7 +51,7 @@ const item = Object.assign(new Item(), { const rd = createSuccessfulRemoteDataObject(item); mockResultObject.indexableObject = Object.assign(new WorkspaceItem(), { item: observableOf(rd) }); -describe('WorkspaceitemMyDSpaceResultDetailElementComponent', () => { +describe('WorkspaceItemSearchResultDetailElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts similarity index 100% rename from src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component.ts rename to src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts diff --git a/src/app/shared/object-detail/object-detail.component.ts b/src/app/shared/object-detail/object-detail.component.ts index 93da1bcce6..36963b2f5d 100644 --- a/src/app/shared/object-detail/object-detail.component.ts +++ b/src/app/shared/object-detail/object-detail.component.ts @@ -17,6 +17,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; import { Context } from '../../core/shared/context.model'; +import { CollectionElementLinkType } from '../object-collection/collection-element-link.type'; /** * This component renders a paginated set of results in the detail view. @@ -51,6 +52,7 @@ export class ObjectDetailComponent { * A boolean representing if to hide pagination when there is only a page */ @Input() hidePagerWhenSinglePage = true; + @Input() linkType: CollectionElementLinkType; @Input() context: Context; /** diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html index 9fecb51b9a..0b1a85d0ef 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html @@ -1,14 +1,17 @@
- + + + + +

{{object.name}}

{{object.shortDescription}}

-
- View +
+ View
-
diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html index 31a9e8ad3d..eed29367fa 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html @@ -1,14 +1,17 @@
- - + + + + +

{{object.name}}

{{object.shortDescription}}

-
- View +
+ View
diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html index df413ebead..81ee3ebcce 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts index 3d0b80932d..a3103268fe 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts @@ -8,14 +8,12 @@ import { PublicationGridElementComponent } from './publication-grid-element.comp import { of as observableOf } from 'rxjs/internal/observable/of'; import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; +import { JournalGridElementComponent } from '../../../../../entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component'; -const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithMetadata.hitHighlights = {}; -mockItemWithMetadata.indexableObject = Object.assign(new Item(), { +const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), metadata: { 'dc.title': [ @@ -45,33 +43,8 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutMetadata.hitHighlights = {}; -mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); - -describe('PublicationGridElementComponent', getEntityGridElementTestComponent(PublicationGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract'])); - -/** - * Create test cases for a grid component of an entity. - * @param component The component's class - * @param searchResultWithMetadata An ItemSearchResult containing an item with metadata that should be displayed in the grid element - * @param searchResultWithoutMetadata An ItemSearchResult containing an item that's missing the metadata that should be displayed in the grid element - * @param fieldsToCheck A list of fields to check. The tests expect to find html elements with class ".item-${field}", so make sure they exist in the html template of the grid element. - * For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's - * present when the author metadata is available. - */ -export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) { - return () => { +describe('PublicationGridElementComponent', + () => { let comp; let fixture; @@ -82,46 +55,31 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [component, TruncatePipe], + declarations: [PublicationGridElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: truncatableServiceStub }, - {provide: ITEM, useValue: searchResultWithoutMetadata} ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(component, { + }).overrideComponent(PublicationGridElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(component); + fixture = TestBed.createComponent(PublicationGridElementComponent); comp = fixture.componentInstance; })); - fieldsToCheck.forEach((field) => { - describe(`when the item has "${field}" metadata`, () => { - beforeEach(() => { - comp.dso = searchResultWithMetadata.indexableObject; - fixture.detectChanges(); - }); - - it(`should show the "${field}" field`, () => { - const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`)); - expect(itemAuthorField).not.toBeNull(); - }); + describe(`when the publication is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - describe(`when the item has no "${field}" metadata`, () => { - beforeEach(() => { - comp.dso = searchResultWithoutMetadata.indexableObject; - fixture.detectChanges(); - }); - - it(`should not show the "${field}" field`, () => { - const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`)); - expect(itemAuthorField).toBeNull(); - }); + it(`should contain a PublicationGridElementComponent`, () => { + const publicationGridElement = fixture.debugElement.query(By.css(`ds-publication-search-result-grid-element`)); + expect(publicationGridElement).not.toBeNull(); }); }); - } -} + + }); \ No newline at end of file diff --git a/src/app/shared/object-grid/object-grid.component.html b/src/app/shared/object-grid/object-grid.component.html index f527aa3555..348536bfed 100644 --- a/src/app/shared/object-grid/object-grid.component.html +++ b/src/app/shared/object-grid/object-grid.component.html @@ -13,7 +13,7 @@
- +
diff --git a/src/app/shared/object-grid/object-grid.component.ts b/src/app/shared/object-grid/object-grid.component.ts index 52f6e29d14..6b61e6bfd8 100644 --- a/src/app/shared/object-grid/object-grid.component.ts +++ b/src/app/shared/object-grid/object-grid.component.ts @@ -22,6 +22,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; import { Context } from '../../core/shared/context.model'; +import { CollectionElementLinkType } from '../object-collection/collection-element-link.type'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -39,6 +40,7 @@ export class ObjectGridComponent implements OnInit { @Input() sortConfig: SortOptions; @Input() hideGear = false; @Input() hidePagerWhenSinglePage = true; + @Input() linkType: CollectionElementLinkType; @Input() context: Context; private _objects$: BehaviorSubject>>; diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html index 91548d945d..0c45316e30 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html @@ -1,13 +1,17 @@
- + + + + +

{{dso.name}}

{{dso.shortDescription}}

-
- View +
+ View
diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html index 95094a6fa1..d0a9aa700e 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html @@ -1,14 +1,17 @@
- - + + + + +

{{dso.name}}

{{dso.shortDescription}}

-
- View +
+ View
diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html index e0eedc22fc..a00e30cbcd 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html @@ -1,32 +1,39 @@
- +
+ +
+ + +
+
-

+

+ class="item-authors card-text text-muted"> - {{dso.firstMetadataValue('dc.date.issued')}} - , + {{firstMetadataValue('dc.date.issued')}} + ,

-

+

-
diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts index 63ee848aa0..30bb2c9262 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts @@ -99,7 +99,7 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet fieldsToCheck.forEach((field) => { describe(`when the item has "${field}" metadata`, () => { beforeEach(() => { - comp.dso = searchResultWithMetadata.indexableObject; + comp.object = searchResultWithMetadata; fixture.detectChanges(); }); @@ -111,7 +111,7 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet describe(`when the item has no "${field}" metadata`, () => { beforeEach(() => { - comp.dso = searchResultWithoutMetadata.indexableObject; + comp.object = searchResultWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html index 0fad726777..e3455bf095 100644 --- a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html +++ b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html @@ -1,7 +1,10 @@
- - {{object.value}} - -   - {{object.count}} + + {{object.value}} + + + {{object.value}} + +   + {{object.count}}
diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.html b/src/app/shared/object-list/collection-list-element/collection-list-element.component.html index dec2794dca..c61adf5dad 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.html +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.html @@ -1,6 +1,9 @@ - + {{object.name}} + + {{object.name}} +
{{object.shortDescription}}
diff --git a/src/app/shared/object-list/community-list-element/community-list-element.component.html b/src/app/shared/object-list/community-list-element/community-list-element.component.html index 7582680fb2..af01999ca7 100644 --- a/src/app/shared/object-list/community-list-element/community-list-element.component.html +++ b/src/app/shared/object-list/community-list-element/community-list-element.component.html @@ -1,6 +1,9 @@ - + {{object.name}} + + {{object.name}} +
{{object.shortDescription}}
diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html index f4269d357d..acc3ee4194 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts index 5761a591dd..24bc774b1f 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { PublicationListElementComponent } from './publication-list-element.component'; @@ -7,10 +7,7 @@ import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { of as observableOf } from 'rxjs'; -let publicationListElementComponent: PublicationListElementComponent; -let fixture: ComponentFixture; - -const mockItemWithMetadata: Item = Object.assign(new Item(), { +const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ @@ -45,131 +42,43 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), { ] } }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' - } - ] - } -}); -describe('PublicationListElementComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ PublicationListElementComponent , TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: {} } - ], +describe('PublicationListElementComponent', + () => { + let comp; + let fixture; - schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(PublicationListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - fixture = TestBed.createComponent(PublicationListElementComponent); - publicationListElementComponent = fixture.componentInstance; + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PublicationListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PublicationListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(PublicationListElementComponent); + comp = fixture.componentInstance; + })); - describe('When the item has an author', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); + describe(`when the publication is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + + it(`should contain a PublicationListElementComponent`, () => { + const publicationListElement = fixture.debugElement.query(By.css(`ds-publication-search-result-list-element`)); + expect(publicationListElement).not.toBeNull(); + }); }); - it('should show the author paragraph', () => { - const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors')); - expect(itemAuthorField).not.toBeNull(); - }); - }); - - describe('When the item has no author', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the author paragraph', () => { - const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors')); - expect(itemAuthorField).toBeNull(); - }); - }); - - describe('When the item has a publisher', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); - }); - - it('should show the publisher span', () => { - const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher')); - expect(publisherField).not.toBeNull(); - }); - }); - - describe('When the item has no publisher', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the publisher span', () => { - const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher')); - expect(publisherField).toBeNull(); - }); - }); - - describe('When the item has an issuedate', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); - }); - - it('should show the issuedate span', () => { - const dateField = fixture.debugElement.query(By.css('span.item-list-date')); - expect(dateField).not.toBeNull(); - }); - }); - - describe('When the item has no issuedate', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the issuedate span', () => { - const dateField = fixture.debugElement.query(By.css('span.item-list-date')); - expect(dateField).toBeNull(); - }); - }); - - describe('When the item has an abstract', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithMetadata; - fixture.detectChanges(); - }); - - it('should show the abstract span', () => { - const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); - expect(abstractField).not.toBeNull(); - }); - }); - - describe('When the item has no abstract', () => { - beforeEach(() => { - publicationListElementComponent.object = mockItemWithoutMetadata; - fixture.detectChanges(); - }); - - it('should not show the abstract span', () => { - const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); - expect(abstractField).toBeNull(); - }); - }); -}); + }); \ No newline at end of file diff --git a/src/app/shared/object-list/item-type-badge/item-type-badge.component.spec.ts b/src/app/shared/object-list/item-type-badge/item-type-badge.component.spec.ts index 04c40b73ff..35f283efe3 100644 --- a/src/app/shared/object-list/item-type-badge/item-type-badge.component.spec.ts +++ b/src/app/shared/object-list/item-type-badge/item-type-badge.component.spec.ts @@ -13,9 +13,7 @@ let fixture: ComponentFixture; const type = 'authorOfPublication'; -const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult(); -mockItemWithRelationshipType.hitHighlights = {}; -mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), { +const mockItemWithRelationshipType = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'relationship.type': [ @@ -27,9 +25,7 @@ mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), { } }); -const mockItemWithoutRelationshipType: ItemSearchResult = new ItemSearchResult(); -mockItemWithoutRelationshipType.hitHighlights = {}; -mockItemWithoutRelationshipType.indexableObject = Object.assign(new Item(), { +const mockItemWithoutRelationshipType = Object.assign(new Item(), { bitstreams: observableOf({}), metadata: { 'dc.title': [ diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts index 7afe774831..fe2ada3aff 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts @@ -23,6 +23,7 @@ describe('ItemMetadataListElementComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemMetadataListElementComponent); comp = fixture.componentInstance; + comp.metadataRepresentation = mockItemMetadataRepresentation; fixture.detectChanges(); })); diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts index 08ff67e3f1..4f27bf05dd 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts @@ -3,9 +3,8 @@ import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { metadataRepresentationComponent } from '../../../metadata-representation/metadata-representation.decorator'; -import { Item } from '../../../../core/shared/item.model'; -@metadataRepresentationComponent(Item.name, MetadataRepresentationType.Item) +@metadataRepresentationComponent('Publication', MetadataRepresentationType.Item) @Component({ selector: 'ds-item-metadata-list-element', templateUrl: './item-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts index b7f4a381e2..7b8e0d7f9c 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts @@ -10,7 +10,4 @@ import { MetadataRepresentation } from '../../../core/shared/metadata-representa */ export class MetadataRepresentationListElementComponent { metadataRepresentation: MetadataRepresentation; - - constructor() { - } } diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts index 9926b8639e..9a409aa147 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts @@ -25,6 +25,7 @@ describe('PlainTextMetadataListElementComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(PlainTextMetadataListElementComponent); comp = fixture.componentInstance; + comp.metadataRepresentation = mockMetadataRepresentation; fixture.detectChanges(); })); diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts index 50e2c2a60b..198c3712d9 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts @@ -2,11 +2,10 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep import { Component } from '@angular/core'; import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; import { metadataRepresentationComponent } from '../../../metadata-representation/metadata-representation.decorator'; -import { Item } from '../../../../core/shared/item.model'; -@metadataRepresentationComponent(Item.name, MetadataRepresentationType.PlainText) +@metadataRepresentationComponent('Publication', MetadataRepresentationType.PlainText) // For now, authority controlled fields are rendered the same way as plain text fields -@metadataRepresentationComponent(Item.name, MetadataRepresentationType.AuthorityControlled) +@metadataRepresentationComponent('Publication', MetadataRepresentationType.AuthorityControlled) @Component({ selector: 'ds-plain-text-metadata-list-element', templateUrl: './plain-text-metadata-list-element.component.html' diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts index c52b1f1b07..327bb750b1 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts @@ -6,12 +6,13 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { ClaimedSearchResultListElementComponent } from './claimed-search-result-list-element.component'; -import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; +import { TruncatableAction } from '../../../truncatable/truncatable.actions'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: ClaimedSearchResultListElementComponent; let fixture: ComponentFixture; @@ -55,14 +56,13 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); mockResultObject.indexableObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem) }); -describe('ClaimedMyDSpaceResultListElementComponent', () => { +describe('ClaimedSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [ClaimedSearchResultListElementComponent], providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } + { provide: TruncatableService, useValue: {} }, ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ClaimedSearchResultListElementComponent, { diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts index d3c657cc3f..57c1a4706c 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.spec.ts @@ -8,6 +8,7 @@ import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { ItemSearchResultListElementSubmissionComponent } from './item-search-result-list-element-submission.component'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: ItemSearchResultListElementSubmissionComponent; let fixture: ComponentFixture; @@ -53,8 +54,7 @@ describe('ItemMyDSpaceResultListElementComponent', () => { imports: [NoopAnimationsModule], declarations: [ItemSearchResultListElementSubmissionComponent], providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } + { provide: TruncatableService, useValue: {} }, ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ItemSearchResultListElementSubmissionComponent, { diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts index 08b670862f..31f29439af 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts @@ -6,12 +6,12 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { PoolSearchResultListElementComponent } from './pool-search-result-list-element.component'; -import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: PoolSearchResultListElementComponent; let fixture: ComponentFixture; @@ -55,14 +55,13 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); mockResultObject.indexableObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkflowitem) }); -describe('PoolMyDSpaceResultListElementComponent', () => { +describe('PoolSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [PoolSearchResultListElementComponent], providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } + { provide: TruncatableService, useValue: {} }, ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(PoolSearchResultListElementComponent, { diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts index dd04198b93..90036142c4 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts @@ -5,12 +5,12 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { WorkflowItemSearchResultListElementComponent } from './workflow-item-my-search-result-list-element.component'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { WorkflowItemSearchResultListElementComponent } from './workflow-item-search-result-list-element.component'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: WorkflowItemSearchResultListElementComponent; let fixture: ComponentFixture; @@ -52,14 +52,13 @@ const item = Object.assign(new Item(), { const rd = createSuccessfulRemoteDataObject(item); mockResultObject.indexableObject = Object.assign(new WorkflowItem(), { item: observableOf(rd) }); -describe('WorkflowitemMyDSpaceResultListElementComponent', () => { +describe('WorkflowItemSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [WorkflowItemSearchResultListElementComponent], providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } + { provide: TruncatableService, useValue: {} }, ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(WorkflowItemSearchResultListElementComponent, { diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts index 988d550345..eac4320bd7 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts @@ -6,11 +6,11 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { WorkspaceItemSearchResultListElementComponent } from './workspace-item-search-result-list-element.component'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: WorkspaceItemSearchResultListElementComponent; let fixture: ComponentFixture; @@ -52,14 +52,13 @@ const item = Object.assign(new Item(), { const rd = createSuccessfulRemoteDataObject(item); mockResultObject.indexableObject = Object.assign(new WorkspaceItem(), { item: observableOf(rd) }); -describe('WorkspaceitemMyDSpaceResultListElementComponent', () => { +describe('WorkspaceItemSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [WorkspaceItemSearchResultListElementComponent], providers: [ - { provide: 'objectElementProvider', useValue: (mockResultObject) }, - { provide: 'indexElementProvider', useValue: (compIndex) } + { provide: TruncatableService, useValue: {} }, ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(WorkspaceItemSearchResultListElementComponent, { diff --git a/src/app/shared/object-list/object-list.component.html b/src/app/shared/object-list/object-list.component.html index daec1db8ad..1d49ea09d7 100644 --- a/src/app/shared/object-list/object-list.component.html +++ b/src/app/shared/object-list/object-list.component.html @@ -12,7 +12,7 @@ (paginationChange)="onPaginationChange($event)">
  • - +
diff --git a/src/app/shared/object-list/object-list.component.ts b/src/app/shared/object-list/object-list.component.ts index 0776134e83..9704dee70e 100644 --- a/src/app/shared/object-list/object-list.component.ts +++ b/src/app/shared/object-list/object-list.component.ts @@ -14,6 +14,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { ViewMode } from '../../core/shared/view-mode.model'; import { Context } from '../../core/shared/context.model'; +import { CollectionElementLinkType } from '../object-collection/collection-element-link.type'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -30,6 +31,7 @@ export class ObjectListComponent { @Input() hasBorder = false; @Input() hideGear = false; @Input() hidePagerWhenSinglePage = true; + @Input() linkType: CollectionElementLinkType; @Input() context: Context; private _objects: RemoteData>; @Input() set objects(objects: RemoteData>) { diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.html index b4af631e83..3c787c47ce 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.html @@ -1,2 +1,3 @@ - + +
diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.spec.ts index 7f5aaf5d9c..9de1e085b5 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.spec.ts @@ -47,9 +47,7 @@ describe('CollectionSearchResultListElementComponent', () => { declarations: [ CollectionSearchResultListElementComponent, TruncatePipe ], providers: [ { provide: TruncatableService, useValue: truncatableServiceStub }, - { provide: 'objectElementProvider', useValue: (mockCollectionWithAbstract) } ], - schemas: [ NO_ERRORS_SCHEMA ] }).overrideComponent(CollectionSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } @@ -59,6 +57,8 @@ describe('CollectionSearchResultListElementComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(CollectionSearchResultListElementComponent); collectionSearchResultListElementComponent = fixture.componentInstance; + collectionSearchResultListElementComponent.object = mockCollectionWithAbstract; + fixture.detectChanges(); })); describe('When the collection has an abstract', () => { diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.html index 9444a63771..32834fefee 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.html @@ -1,2 +1,3 @@ - + +
diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.spec.ts index 691a69dde4..2bf61c2ab9 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.spec.ts @@ -47,7 +47,6 @@ describe('CommunitySearchResultListElementComponent', () => { declarations: [ CommunitySearchResultListElementComponent, TruncatePipe ], providers: [ { provide: TruncatableService, useValue: truncatableServiceStub }, - { provide: 'objectElementProvider', useValue: (mockCommunityWithAbstract) } ], schemas: [ NO_ERRORS_SCHEMA ] @@ -59,6 +58,8 @@ describe('CommunitySearchResultListElementComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(CommunitySearchResultListElementComponent); communitySearchResultListElementComponent = fixture.componentInstance; + communitySearchResultListElementComponent.object = mockCommunityWithAbstract; + fixture.detectChanges(); })); describe('When the community has an abstract', () => { diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html index 62b9bc5e74..3d2604585d 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html @@ -1,9 +1,11 @@ - + + (; -const mockItemWithMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), { + indexableObject: + Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.contributor.author': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'dc.publisher': [ + { + language: 'en_US', + value: 'a publisher' + } + ], + 'dc.date.issued': [ + { + language: 'en_US', + value: '2015-06-26' + } + ], + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'This is the abstract' + } + ] } - ], - 'dc.contributor.author': [ - { - language: 'en_US', - value: 'Smith, Donald' - } - ], - 'dc.publisher': [ - { - language: 'en_US', - value: 'a publisher' - } - ], - 'dc.date.issued': [ - { - language: 'en_US', - value: '2015-06-26' - } - ], - 'dc.description.abstract': [ - { - language: 'en_US', - value: 'This is the abstract' - } - ] - } + }) }); -const mockItemWithoutMetadata: Item = Object.assign(new Item(), { - bitstreams: observableOf({}), - metadata: { - 'dc.title': [ - { - language: 'en_US', - value: 'This is just another title' +const mockItemWithoutMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), { + indexableObject: + Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] } - ] - } + }) }); describe('PublicationListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ PublicationSearchResultListElementComponent , TruncatePipe], + declarations: [PublicationSearchResultListElementComponent, TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], - schemas: [ NO_ERRORS_SCHEMA ] + schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(PublicationSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); From 7ca88021c953ab9c6ce5790474ab875aa0e08f15 Mon Sep 17 00:00:00 2001 From: lotte Date: Tue, 15 Oct 2019 15:58:40 +0200 Subject: [PATCH 10/17] added tests, aot fixes, lint fixes --- .../edit-relationship-list.component.spec.ts | 2 +- .../publication/publication.component.html | 2 +- .../publication/publication.component.ts | 2 +- .../item-types/shared/item.component.ts | 3 - .../metadata-representation-list.component.ts | 6 -- src/app/+search-page/search-result.model.ts | 5 +- src/app/core/metadata/metadata-field.model.ts | 5 +- .../core/metadata/metadata-schema.model.ts | 5 +- .../core/registry/registry.service.spec.ts | 27 ++++--- src/app/core/shared/browse-entry.model.ts | 5 +- src/app/core/shared/dspace-object.model.ts | 5 +- src/app/core/shared/item.model.ts | 7 +- src/app/core/shared/view-mode.model.ts | 1 - ...urnal-issue-grid-element.component.spec.ts | 68 +++++++++--------- ...rnal-volume-grid-element.component.spec.ts | 68 +++++++++--------- .../journal-grid-element.component.spec.ts | 67 +++++++++--------- ...urnal-issue-list-element.component.spec.ts | 65 +++++++++-------- ...rnal-volume-list-element.component.spec.ts | 63 ++++++++--------- .../journal-list-element.component.spec.ts | 65 ++++++++--------- .../orgunit-grid-element.component.spec.ts | 66 +++++++++-------- .../person-grid-element.component.spec.ts | 66 +++++++++-------- .../project-grid-element.component.spec.ts | 69 +++++++++--------- ...arch-result-grid-element.component.spec.ts | 2 +- .../orgunit-list-element.component.spec.ts | 64 ++++++++--------- .../person-list-element.component.spec.ts | 65 ++++++++--------- .../project-list-element.component.spec.ts | 64 ++++++++--------- ...etadata-representation-loader.component.ts | 2 +- .../metadata-representation.decorator.spec.ts | 63 +++++++++++++++++ .../metadata-representation.decorator.ts | 13 ++-- .../metadata-representation.directive.ts | 2 +- .../collection-element-link.type.ts | 2 +- .../shared/item-search-result.model.ts | 12 ++++ .../shared/listable-object.model.ts | 3 +- ...table-object-component-loader.component.ts | 8 +-- .../listable-object.decorator.spec.ts | 63 +++++++++++++++-- .../listable-object.decorator.ts | 16 ++--- .../listable-object.directive.ts | 2 +- ...-search-result-detail-element.component.ts | 3 +- ...-search-result-detail-element.component.ts | 3 +- ...-search-result-detail-element.component.ts | 2 +- ...-search-result-detail-element.component.ts | 2 +- .../object-detail.component.spec.ts | 21 +++--- .../collection-grid-element.component.ts | 2 +- .../community-grid-element.component.ts | 2 +- ...publication-grid-element.component.spec.ts | 70 +++++++++---------- .../publication-grid-element.component.ts | 2 +- ...on-search-result-grid-element.component.ts | 2 +- ...ty-search-result-grid-element.component.ts | 2 +- .../browse-entry-list-element.component.ts | 3 +- .../collection-list-element.component.ts | 2 +- .../community-list-element.component.ts | 2 +- ...publication-list-element.component.spec.ts | 64 ++++++++--------- .../publication-list-element.component.ts | 2 +- ...ed-search-result-list-element.component.ts | 3 +- ...esult-list-element-submission.component.ts | 10 +-- ...ol-search-result-list-element.component.ts | 3 +- ...em-search-result-list-element.component.ts | 4 +- ...em-search-result-list-element.component.ts | 2 +- ...on-search-result-list-element.component.ts | 4 +- ...ty-search-result-list-element.component.ts | 5 +- ...on-search-result-list-element.component.ts | 2 +- .../publication/publication.component.html | 28 ++++---- .../journal-issue.component.html | 18 ++--- .../journal-volume.component.html | 12 ++-- .../item-pages/journal/journal.component.html | 16 ++--- .../item-pages/orgunit/orgunit.component.html | 16 ++--- .../item-pages/person/person.component.html | 22 +++--- .../item-pages/project/project.component.html | 18 ++--- 68 files changed, 749 insertions(+), 651 deletions(-) create mode 100644 src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts index c8e4c35b8b..3748ebca9d 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts @@ -117,7 +117,7 @@ describe('EditRelationshipListComponent', () => { fixture = TestBed.createComponent(EditRelationshipListComponent); comp = fixture.componentInstance; de = fixture.debugElement; - comp.object = item; + comp.item = item; comp.url = url; comp.relationshipLabel = relationshipType.leftLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index 09952354a5..bc945bc234 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -4,7 +4,7 @@
- + diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index 5bc118a4ca..777f42d1f0 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -8,7 +8,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; @listableObjectComponent('Publication', ViewMode.StandalonePage) -@listableObjectComponent(Item.name, ViewMode.StandalonePage) +@listableObjectComponent(Item, ViewMode.StandalonePage) @Component({ selector: 'ds-publication', styleUrls: ['./publication.component.scss'], diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 398228856b..fa55872a67 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -66,9 +66,6 @@ export class ItemComponent implements OnInit { resolvedRelsAndTypes$: Observable<[Relationship[], RelationshipType[]]>; @Input() object: Item; - constructor( - ) {} - ngOnInit(): void { const relationships$ = this.object.relationships; if (relationships$) { diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts index b585c9971b..f88bb12386 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -20,10 +20,4 @@ export class MetadataRepresentationListComponent { * An i18n label to use as a title for the list */ @Input() label: string; - - /** - * The view-mode we're currently on - * @type {ElementViewMode} - */ - viewMode = ViewMode.MetadataField; } diff --git a/src/app/+search-page/search-result.model.ts b/src/app/+search-page/search-result.model.ts index 693f81e65b..4f15656d59 100644 --- a/src/app/+search-page/search-result.model.ts +++ b/src/app/+search-page/search-result.model.ts @@ -1,6 +1,7 @@ import { DSpaceObject } from '../core/shared/dspace-object.model'; import { MetadataMap } from '../core/shared/metadata.models'; import { ListableObject } from '../shared/object-collection/shared/listable-object.model'; +import { GenericConstructor } from '../core/shared/generic-constructor'; /** * Represents a search result object of a certain () DSpaceObject @@ -16,7 +17,7 @@ export class SearchResult implements ListableObject { */ hitHighlights: MetadataMap; - getRenderTypes(): string[] { - return this.indexableObject.getRenderTypes().map((type) => type +'SearchResult'); + getRenderTypes(): Array> { + return [this.constructor as GenericConstructor]; } } diff --git a/src/app/core/metadata/metadata-field.model.ts b/src/app/core/metadata/metadata-field.model.ts index b4a20924b9..1712ba0379 100644 --- a/src/app/core/metadata/metadata-field.model.ts +++ b/src/app/core/metadata/metadata-field.model.ts @@ -2,6 +2,7 @@ import { ListableObject } from '../../shared/object-collection/shared/listable-o import { isNotEmpty } from '../../shared/empty.util'; import { MetadataSchema } from './metadata-schema.model'; import { ResourceType } from '../shared/resource-type'; +import { GenericConstructor } from '../shared/generic-constructor'; /** * Class the represents a metadata field @@ -51,7 +52,7 @@ export class MetadataField implements ListableObject { return key; } - getRenderTypes(): string[] { - return [this.constructor.name]; + getRenderTypes(): Array> { + return [this.constructor as GenericConstructor]; } } diff --git a/src/app/core/metadata/metadata-schema.model.ts b/src/app/core/metadata/metadata-schema.model.ts index f1551327a5..36ccaae36d 100644 --- a/src/app/core/metadata/metadata-schema.model.ts +++ b/src/app/core/metadata/metadata-schema.model.ts @@ -1,5 +1,6 @@ import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { ResourceType } from '../shared/resource-type'; +import { GenericConstructor } from '../shared/generic-constructor'; /** * Class that represents a metadata schema @@ -27,7 +28,7 @@ export class MetadataSchema implements ListableObject { */ namespace: string; - getRenderTypes(): string[] { - return [this.constructor.name]; + getRenderTypes(): Array> { + return [this.constructor as GenericConstructor]; } } diff --git a/src/app/core/registry/registry.service.spec.ts b/src/app/core/registry/registry.service.spec.ts index 455a8043da..03a7c132de 100644 --- a/src/app/core/registry/registry.service.spec.ts +++ b/src/app/core/registry/registry.service.spec.ts @@ -55,22 +55,24 @@ describe('RegistryService', () => { }); const mockSchemasList = [ - { + Object.assign(new MetadataSchema(), { id: 1, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1', prefix: 'dc', namespace: 'http://dublincore.org/documents/dcmi-terms/', type: MetadataSchema.type -}, - { +}), + Object.assign(new MetadataSchema(), { + id: 2, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/2', prefix: 'mock', namespace: 'http://dspace.org/mockschema', type: MetadataSchema.type - } + }) ]; const mockFieldsList = [ + Object.assign(new MetadataField(), { id: 1, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/8', @@ -79,8 +81,9 @@ describe('RegistryService', () => { scopeNote: null, schema: mockSchemasList[0], type: MetadataField.type - }, - { + }), + Object.assign(new MetadataField(), + { id: 2, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/9', element: 'contributor', @@ -88,8 +91,9 @@ describe('RegistryService', () => { scopeNote: null, schema: mockSchemasList[0], type: MetadataField.type - }, - { + }), + Object.assign(new MetadataField(), + { id: 3, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/10', element: 'contributor', @@ -97,8 +101,9 @@ describe('RegistryService', () => { scopeNote: 'test scope note', schema: mockSchemasList[1], type: MetadataField.type - }, - { + }), + Object.assign(new MetadataField(), + { id: 4, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/11', element: 'contributor', @@ -106,7 +111,7 @@ describe('RegistryService', () => { scopeNote: null, schema: mockSchemasList[1], type: MetadataField.type - } + }) ]; const pageInfo = new PageInfo(); diff --git a/src/app/core/shared/browse-entry.model.ts b/src/app/core/shared/browse-entry.model.ts index a8b41894f5..b2470032ad 100644 --- a/src/app/core/shared/browse-entry.model.ts +++ b/src/app/core/shared/browse-entry.model.ts @@ -1,6 +1,7 @@ import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { TypedObject } from '../cache/object-cache.reducer'; import { ResourceType } from './resource-type'; +import { GenericConstructor } from './generic-constructor'; /** * Class object representing a browse entry @@ -29,7 +30,7 @@ export class BrowseEntry implements ListableObject { */ count: number; - getRenderTypes(): string[] { - return [this.constructor.name]; + getRenderTypes(): Array> { + return [this.constructor as GenericConstructor]; } } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 16f4002b7f..685f886b19 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -12,6 +12,7 @@ import { CacheableObject } from '../cache/object-cache.reducer'; import { RemoteData } from '../data/remote-data'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { ResourceType } from './resource-type'; +import { GenericConstructor } from './generic-constructor'; /** * An abstract model class for a DSpaceObject. @@ -146,7 +147,7 @@ export class DSpaceObject implements CacheableObject, ListableObject { }); } - getRenderTypes(): string[] { - return [this.constructor.name]; + getRenderTypes(): Array> { + return [this.constructor as GenericConstructor]; } } diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index 2f553a58db..191a258c4f 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -10,6 +10,9 @@ import { PaginatedList } from '../data/paginated-list'; import { Relationship } from './item-relationships/relationship.model'; import { ResourceType } from './resource-type'; import { getSucceededRemoteData } from './operators'; +import { GenericConstructor } from './generic-constructor'; +import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; +import { DEFAULT_ENTITY_TYPE } from '../../shared/metadata-representation/metadata-representation.decorator'; export class Item extends DSpaceObject { static type = new ResourceType('item'); @@ -110,10 +113,10 @@ export class Item extends DSpaceObject { })); } - getRenderTypes(): string[] { + getRenderTypes(): Array> { let entityType = this.firstMetadataValue('relationship.type'); if (isEmpty(entityType)) { - entityType = 'Publication'; + entityType = DEFAULT_ENTITY_TYPE; } return [entityType, ...super.getRenderTypes()]; } diff --git a/src/app/core/shared/view-mode.model.ts b/src/app/core/shared/view-mode.model.ts index f49f3b490c..c2f076a5e5 100644 --- a/src/app/core/shared/view-mode.model.ts +++ b/src/app/core/shared/view-mode.model.ts @@ -7,5 +7,4 @@ export enum ViewMode { GridElement = 'gridElement', DetailedListElement = 'detailedListElement', StandalonePage = 'standalonePage', - MetadataField = 'metadataField' } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts index 4ad7770e1e..9a147637fa 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts @@ -1,6 +1,4 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { JournalIssueGridElementComponent } from './journal-issue-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; @@ -37,43 +35,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('JournalIssueGridElementComponent', - () => { - let comp; - let fixture; +describe('JournalIssueGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [JournalIssueGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(JournalIssueGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [JournalIssueGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalIssueGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalIssueGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalIssueGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the journal issue is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a JournalIssueSearchResultGridElementComponent`, () => { - const journalIssueGridElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-grid-element`)); - expect(journalIssueGridElement).not.toBeNull(); - }); - }); + describe(`when the journal issue is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); + }); + it(`should contain a JournalIssueSearchResultGridElementComponent`, () => { + const journalIssueGridElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-grid-element`)); + expect(journalIssueGridElement).not.toBeNull(); + }); }); +}); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts index 427f1db3cd..6f74f97ac1 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts @@ -1,4 +1,3 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; import { JournalVolumeGridElementComponent } from './journal-volume-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; @@ -7,7 +6,6 @@ import { PageInfo } from '../../../../core/shared/page-info.model'; import { of as observableOf } from 'rxjs'; import { async, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { JournalIssueGridElementComponent } from '../journal-issue/journal-issue-grid-element.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; @@ -37,43 +35,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('JournalVolumeGridElementComponent', - () => { - let comp; - let fixture; +describe('JournalVolumeGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [JournalVolumeGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(JournalVolumeGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [JournalVolumeGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalVolumeGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalVolumeGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalVolumeGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the journal volume is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a JournalVolumeSearchResultGridElementComponent`, () => { - const journalVolumeGridElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-grid-element`)); - expect(journalVolumeGridElement).not.toBeNull(); - }); + describe(`when the journal volume is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a JournalVolumeSearchResultGridElementComponent`, () => { + const journalVolumeGridElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-grid-element`)); + expect(journalVolumeGridElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts index d0f3753840..0619309d09 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts @@ -1,4 +1,3 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { JournalGridElementComponent } from './journal-grid-element.component'; @@ -42,43 +41,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('JournalGridElementComponent', - () => { - let comp; - let fixture; +describe('JournalGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [JournalGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(JournalGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [JournalGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the journal is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a JournalGridElementComponent`, () => { - const journalGridElement = fixture.debugElement.query(By.css(`ds-journal-search-result-grid-element`)); - expect(journalGridElement).not.toBeNull(); - }); + describe(`when the journal is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a JournalGridElementComponent`, () => { + const journalGridElement = fixture.debugElement.query(By.css(`ds-journal-search-result-grid-element`)); + expect(journalGridElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts index 1a06e9f29c..a7dfcbbf36 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts @@ -31,42 +31,41 @@ const mockItem: Item = Object.assign(new Item(), { } }); -describe('JournalIssueListElementComponent', - () => { - let comp; - let fixture; +describe('JournalIssueListElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [JournalIssueListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(JournalIssueListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [JournalIssueListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalIssueListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalIssueListElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalIssueListElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the journal issue is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a JournalIssueListElementComponent`, () => { - const journalIssueListElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-list-element`)); - expect(journalIssueListElement).not.toBeNull(); - }); + describe(`when the journal issue is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a JournalIssueListElementComponent`, () => { + const journalIssueListElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-list-element`)); + expect(journalIssueListElement).not.toBeNull(); + }); + }); + +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts index 0d1401068b..ba43805525 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts @@ -30,42 +30,41 @@ const mockItem: Item = Object.assign(new Item(), { ] } }); -describe('JournalVolumeListElementComponent', - () => { - let comp; - let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; +describe('JournalVolumeListElementComponent', () => { + let comp; + let fixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [JournalVolumeListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(JournalVolumeListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalVolumeListElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [JournalVolumeListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalVolumeListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - describe(`when the journal volume is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalVolumeListElementComponent); + comp = fixture.componentInstance; + })); - it(`should contain a JournalVolumeListElementComponent`, () => { - const journalVolumeListElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-list-element`)); - expect(journalVolumeListElement).not.toBeNull(); - }); + describe(`when the journal volume is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a JournalVolumeListElementComponent`, () => { + const journalVolumeListElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-list-element`)); + expect(journalVolumeListElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts index 432f81c171..6581619787 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts @@ -25,43 +25,40 @@ const mockItem: Item = Object.assign(new Item(), { } }); +describe('JournalListElementComponent', () => { + let comp; + let fixture; -describe('JournalListElementComponent', - () => { - let comp; - let fixture; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [JournalListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(JournalListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [JournalListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(JournalListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalListElementComponent); + comp = fixture.componentInstance; + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(JournalListElementComponent); - comp = fixture.componentInstance; - })); - - describe(`when the journal is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a JournalListElementComponent`, () => { - const journalListElement = fixture.debugElement.query(By.css(`ds-journal-search-result-list-element`)); - expect(journalListElement).not.toBeNull(); - }); + describe(`when the journal is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a JournalListElementComponent`, () => { + const journalListElement = fixture.debugElement.query(By.css(`ds-journal-search-result-list-element`)); + expect(journalListElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts index 1140f7d908..5cbe9f6d79 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts @@ -41,43 +41,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('OrgunitGridElementComponent', - () => { - let comp; - let fixture; +describe('OrgunitGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [OrgunitGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(OrgunitGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [OrgunitGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(OrgunitGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(OrgunitGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgunitGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the org unit is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a OrgunitGridElementComponent`, () => { - const orgunitGridElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-grid-element`)); - expect(orgunitGridElement).not.toBeNull(); - }); + describe(`when the org unit is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a OrgunitGridElementComponent`, () => { + const orgunitGridElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-grid-element`)); + expect(orgunitGridElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts index fdcc84d864..3edb0fdea7 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts @@ -35,43 +35,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('PersonGridElementComponent', - () => { - let comp; - let fixture; +describe('PersonGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [PersonGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(PersonGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [PersonGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PersonGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(PersonGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the person is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a PersonGridElementComponent`, () => { - const personGridElement = fixture.debugElement.query(By.css(`ds-person-search-result-grid-element`)); - expect(personGridElement).not.toBeNull(); - }); + describe(`when the person is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a PersonGridElementComponent`, () => { + const personGridElement = fixture.debugElement.query(By.css(`ds-person-search-result-grid-element`)); + expect(personGridElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts index 701ca46a73..8bd462b0e6 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts @@ -1,14 +1,11 @@ -import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; -import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; import { ProjectGridElementComponent } from './project-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { async, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { PersonGridElementComponent } from '../person/person-grid-element.component'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; @@ -32,43 +29,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('ProjectGridElementComponent', - () => { - let comp; - let fixture; +describe('ProjectGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [ProjectGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ProjectGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [ProjectGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(ProjectGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(ProjectGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(ProjectGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the project is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a ProjectGridElementComponent`, () => { - const projectGridElement = fixture.debugElement.query(By.css(`ds-project-search-result-grid-element`)); - expect(projectGridElement).not.toBeNull(); - }); + describe(`when the project is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a ProjectGridElementComponent`, () => { + const projectGridElement = fixture.debugElement.query(By.css(`ds-project-search-result-grid-element`)); + expect(projectGridElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts index a9c0774c8c..15e7432b65 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts @@ -3,8 +3,8 @@ import { Item } from '../../../../../core/shared/item.model'; import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; -import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; import { ProjectSearchResultGridElementComponent } from './project-search-result-grid-element.component'; +import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts index d0254e675d..3009197e10 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts @@ -25,42 +25,40 @@ const mockItem: Item = Object.assign(new Item(), { } }); -describe('OrgunitListElementComponent', - () => { - let comp; - let fixture; +describe('OrgunitListElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [OrgUnitListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(OrgUnitListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [OrgUnitListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(OrgUnitListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(OrgUnitListElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgUnitListElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the orgunit is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a OrgUnitListElementComponent`, () => { - const orgunitListElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-list-element`)); - expect(orgunitListElement).not.toBeNull(); - }); + describe(`when the orgunit is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a OrgUnitListElementComponent`, () => { + const orgunitListElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-list-element`)); + expect(orgunitListElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts index acc149c1df..6366ba5735 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts @@ -6,7 +6,6 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -import { OrgUnitListElementComponent } from '../orgunit/orgunit-list-element.component'; const mockItem: Item = Object.assign(new Item(), { bitstreams: observableOf({}), @@ -26,42 +25,40 @@ const mockItem: Item = Object.assign(new Item(), { } }); -describe('PersonListElementComponent', - () => { - let comp; - let fixture; +describe('PersonListElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [PersonListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(PersonListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PersonListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PersonListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(PersonListElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonListElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the person is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a PersonListElementComponent`, () => { - const personListElement = fixture.debugElement.query(By.css(`ds-person-search-result-list-element`)); - expect(personListElement).not.toBeNull(); - }); + describe(`when the person is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a PersonListElementComponent`, () => { + const personListElement = fixture.debugElement.query(By.css(`ds-person-search-result-list-element`)); + expect(personListElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts index 5591a5b625..dfa2f2506c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.spec.ts @@ -5,7 +5,6 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; -import { PersonListElementComponent } from '../person/person-list-element.component'; import { ProjectListElementComponent } from './project-list-element.component'; const mockItem: Item = Object.assign(new Item(), { @@ -25,42 +24,41 @@ const mockItem: Item = Object.assign(new Item(), { // ] } }); -describe('ProjectListElementComponent', - () => { - let comp; - let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; +describe('ProjectListElementComponent', () => { + let comp; + let fixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ProjectListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ProjectListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - fixture = TestBed.createComponent(ProjectListElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ProjectListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(ProjectListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - describe(`when the project is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); + beforeEach(async(() => { + fixture = TestBed.createComponent(ProjectListElementComponent); + comp = fixture.componentInstance; + })); - it(`should contain a ProjectListElementComponent`, () => { - const projectListElement = fixture.debugElement.query(By.css(`ds-project-search-result-list-element`)); - expect(projectListElement).not.toBeNull(); - }); + describe(`when the project is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a ProjectListElementComponent`, () => { + const projectListElement = fixture.debugElement.query(By.css(`ds-project-search-result-list-element`)); + expect(projectListElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts index ba3f6ed00b..9dcdeb14ec 100644 --- a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts +++ b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts @@ -32,7 +32,7 @@ export class MetadataRepresentationLoaderComponent implements OnInit { viewContainerRef.clear(); const componentRef = viewContainerRef.createComponent(componentFactory); - (componentRef.instance).metadataRepresentation = this.mdRepresentation; + (componentRef.instance as MetadataRepresentationListElementComponent).metadataRepresentation = this.mdRepresentation; } /** diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts new file mode 100644 index 0000000000..38d64d9ff5 --- /dev/null +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts @@ -0,0 +1,63 @@ +import { DEFAULT_ENTITY_TYPE, DEFAULT_REPRESENTATION_TYPE, getMetadataRepresentationComponent, metadataRepresentationComponent } from './metadata-representation.decorator'; +import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; +import { Context } from '../../core/shared/context.model'; +import * as uuidv4 from 'uuid/v4'; + +describe('MetadataRepresentation decorator function', () => { + const type1 = 'TestType'; + const type2 = 'TestType2'; + const type3 = 'TestType3'; + const type4 = 'RandomType'; + let prefix; + /* tslint:disable:max-classes-per-file */ + class Test1PlainText {}; + class Test1Authority {}; + class Test2Item {}; + class Test2ItemSubmission {}; + class Test3ItemSubmission {}; + /* tslint:enable:max-classes-per-file */ + + beforeEach(() => { + prefix = uuidv4(); + init(prefix); + }); + + function init(key) { + metadataRepresentationComponent(key + type1, MetadataRepresentationType.PlainText)(Test1PlainText); + metadataRepresentationComponent(key + type1, MetadataRepresentationType.AuthorityControlled)(Test1Authority); + + metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item)(Test2Item); + metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item, Context.Submission)(Test2ItemSubmission); + + metadataRepresentationComponent(key + type3, MetadataRepresentationType.Item, Context.Submission)(Test3ItemSubmission); + } + + describe('If there\'s an exact match', () => { + it('should return the matching class', () => { + const component = getMetadataRepresentationComponent(prefix + type3, MetadataRepresentationType.Item, Context.Submission); + expect(component).toEqual(Test3ItemSubmission); + }); + }); + + describe('If there isn\'nt an exact match', () => { + describe('If there is a match for the entity type and representation type', () => { + it('should return the class with the matching entity type and representation type and default context', () => { + const component = getMetadataRepresentationComponent(prefix + type1, MetadataRepresentationType.AuthorityControlled, Context.Submission); + expect(component).toEqual(Test1Authority); + }); + }); + describe('If there isn\'t a match for the representation type', () => { + it('should return the class with the matching entity type and the default representation type and default context', () => { + const component = getMetadataRepresentationComponent(prefix + type1, MetadataRepresentationType.Item); + expect(component).toEqual(Test1PlainText); + }); + describe('If there isn\'t a match for the entity type', () => { + it('should return the class with the default entity type and the default representation type and default context', () => { + const defaultComponent = getMetadataRepresentationComponent(DEFAULT_ENTITY_TYPE, DEFAULT_REPRESENTATION_TYPE); + const component = getMetadataRepresentationComponent(prefix + type4, MetadataRepresentationType.AuthorityControlled); + expect(component).toEqual(defaultComponent); + }); + }); + }); + }); +}); diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.ts index 913599b989..7ba626dbf7 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.ts @@ -1,10 +1,10 @@ import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; import { hasNoValue, hasValue } from '../empty.util'; import { Context } from '../../core/shared/context.model'; -import { Item } from '../../core/shared/item.model'; -const map = new Map(); +export const map = new Map(); +export const DEFAULT_ENTITY_TYPE = 'Publication'; export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; export const DEFAULT_CONTEXT = Context.Undefined; @@ -13,7 +13,6 @@ export function metadataRepresentationComponent(entityType: string, mdRepresenta if (hasNoValue(map.get(entityType))) { map.set(entityType, new Map()); } - if (hasNoValue(map.get(entityType).get(mdRepresentationType))) { map.get(entityType).set(mdRepresentationType, new Map()); } @@ -37,7 +36,9 @@ export function getMetadataRepresentationComponent(entityType: string, mdReprese return entityAndMDRepMap.get(DEFAULT_CONTEXT); } } - return mapForEntity.get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); + if (hasValue(mapForEntity.get(DEFAULT_REPRESENTATION_TYPE))) { + return mapForEntity.get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); + } } - return map.get(Item.name).get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); -} \ No newline at end of file + return map.get(DEFAULT_ENTITY_TYPE).get(DEFAULT_REPRESENTATION_TYPE).get(DEFAULT_CONTEXT); +} diff --git a/src/app/shared/metadata-representation/metadata-representation.directive.ts b/src/app/shared/metadata-representation/metadata-representation.directive.ts index c57d1ef4ac..c8c909d03f 100644 --- a/src/app/shared/metadata-representation/metadata-representation.directive.ts +++ b/src/app/shared/metadata-representation/metadata-representation.directive.ts @@ -5,4 +5,4 @@ import { Directive, ViewContainerRef } from '@angular/core'; }) export class MetadataRepresentationDirective { constructor(public viewContainerRef: ViewContainerRef) { } -} \ No newline at end of file +} diff --git a/src/app/shared/object-collection/collection-element-link.type.ts b/src/app/shared/object-collection/collection-element-link.type.ts index 7bef4cf393..5d50ac3bb2 100644 --- a/src/app/shared/object-collection/collection-element-link.type.ts +++ b/src/app/shared/object-collection/collection-element-link.type.ts @@ -1,3 +1,3 @@ export enum CollectionElementLinkType { None, Link, ExternalLink -} \ No newline at end of file +} diff --git a/src/app/shared/object-collection/shared/item-search-result.model.ts b/src/app/shared/object-collection/shared/item-search-result.model.ts index f20b3db1e3..defd4a99c8 100644 --- a/src/app/shared/object-collection/shared/item-search-result.model.ts +++ b/src/app/shared/object-collection/shared/item-search-result.model.ts @@ -1,7 +1,19 @@ import { SearchResult } from '../../../+search-page/search-result.model'; import { Item } from '../../../core/shared/item.model'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; +import { GenericConstructor } from '../../../core/shared/generic-constructor'; +import { ListableObject } from './listable-object.model'; +import { isEmpty } from '../../empty.util'; @searchResultFor(Item) export class ItemSearchResult extends SearchResult { + getRenderTypes(): Array> { + return this.indexableObject.getRenderTypes().map((type) => { + if (typeof type === 'string') { + return type + 'SearchResult' + } else { + return this.constructor as GenericConstructor; + } + }); + } } diff --git a/src/app/shared/object-collection/shared/listable-object.model.ts b/src/app/shared/object-collection/shared/listable-object.model.ts index cef068e47c..a81c9f4aeb 100644 --- a/src/app/shared/object-collection/shared/listable-object.model.ts +++ b/src/app/shared/object-collection/shared/listable-object.model.ts @@ -1,5 +1,6 @@ import { TypedObject } from '../../../core/cache/object-cache.reducer'; +import { GenericConstructor } from '../../../core/shared/generic-constructor'; export interface ListableObject extends TypedObject { - getRenderTypes(): string[]; + getRenderTypes(): Array>; } diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index fb315303f6..2b90d3f94f 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -21,7 +21,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit { */ @Input() object: ListableObject; - //TODO DO SOMETHING WITH THIS + // TODO DO SOMETHING WITH THIS @Input() index: number; /** * The preferred view-mode to display @@ -42,9 +42,9 @@ export class ListableObjectComponentLoaderComponent implements OnInit { viewContainerRef.clear(); const componentRef = viewContainerRef.createComponent(componentFactory); - (componentRef.instance as any).object = this.object; - (componentRef.instance as any).index = this.index; - (componentRef.instance as any).linkType = this.linkType; + (componentRef.instance as any).object = this.object; + (componentRef.instance as any).index = this.index; + (componentRef.instance as any).linkType = this.linkType; } /** diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts index c628378c6f..2873c4fce8 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts @@ -1,10 +1,35 @@ import { Item } from '../../../../core/shared/item.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { listableObjectComponent } from './listable-object.decorator'; +import { getListableObjectComponent, listableObjectComponent } from './listable-object.decorator'; +import { Context } from '../../../../core/shared/context.model'; -describe('ElementDecorator', () => { - const gridDecorator = listableObjectComponent(Item, ViewMode.GridElement); - const listDecorator = listableObjectComponent(Item, ViewMode.ListElement); +describe('ListableObject decorator function', () => { + const type1 = 'TestType'; + const type2 = 'TestType2'; + const type3 = 'TestType3'; + + /* tslint:disable:max-classes-per-file */ + class Test1List {}; + class Test1Grid {}; + class Test2List {}; + class Test2ListSubmission {}; + class Test3List {}; + class Test3DetailedSubmission {}; + /* tslint:enable:max-classes-per-file */ + + beforeEach(() => { + listableObjectComponent(type1, ViewMode.ListElement)(Test1List); + listableObjectComponent(type1, ViewMode.GridElement)(Test1Grid); + + listableObjectComponent(type2, ViewMode.ListElement)(Test2List); + listableObjectComponent(type2, ViewMode.ListElement, Context.Submission)(Test2ListSubmission); + + listableObjectComponent(type3, ViewMode.ListElement)(Test3List); + listableObjectComponent(type3, ViewMode.DetailedListElement, Context.Submission)(Test3DetailedSubmission); + }); + + const gridDecorator = listableObjectComponent('Item', ViewMode.GridElement); + const listDecorator = listableObjectComponent('Item', ViewMode.ListElement); it('should have a decorator for both list and grid', () => { expect(listDecorator.length).not.toBeNull(); expect(gridDecorator.length).not.toBeNull(); @@ -13,4 +38,34 @@ describe('ElementDecorator', () => { expect(listDecorator).not.toEqual(gridDecorator); }); + describe('If there\'s an exact match', () => { + it('should return the matching class', () => { + const component = getListableObjectComponent([type3], ViewMode.DetailedListElement, Context.Submission); + expect(component).toEqual(Test3DetailedSubmission); + + const component2 = getListableObjectComponent([type3, type2], ViewMode.ListElement, Context.Submission); + expect(component2).toEqual(Test2ListSubmission); + }); + }); + + describe('If there isn\'nt an exact match', () => { + describe('If there is a match for one of the entity types and the view mode', () => { + it('should return the class with the matching entity type and view mode and default context', () => { + const component = getListableObjectComponent([type3], ViewMode.ListElement, Context.Submission); + expect(component).toEqual(Test3List); + + const component2 = getListableObjectComponent([type3, type1], ViewMode.GridElement, Context.Submission); + expect(component2).toEqual(Test1Grid); + }); + }); + describe('If there isn\'t a match for the representation type', () => { + it('should return the class with the matching entity type and the default view mode and default context', () => { + const component = getListableObjectComponent([type1], ViewMode.DetailedListElement); + expect(component).toEqual(Test1List); + + const component2 = getListableObjectComponent([type2, type1], ViewMode.DetailedListElement); + expect(component2).toEqual(Test2List); + }); + }); + }); }); diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts index 6098875b4d..1a0daa6505 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts @@ -2,10 +2,11 @@ import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Context } from '../../../../core/shared/context.model'; import { hasNoValue, hasValue } from '../../../empty.util'; import { DEFAULT_CONTEXT } from '../../../metadata-representation/metadata-representation.decorator'; +import { GenericConstructor } from '../../../../core/shared/generic-constructor'; +import { ListableObject } from '../listable-object.model'; export const DEFAULT_VIEW_MODE = ViewMode.ListElement; - const map = new Map(); /** @@ -13,7 +14,7 @@ const map = new Map(); * @param type * @param viewMode */ -export function listableObjectComponent(objectType: string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { +export function listableObjectComponent(objectType: string | GenericConstructor, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { return function decorator(component: any) { if (hasNoValue(objectType)) { return; @@ -28,12 +29,11 @@ export function listableObjectComponent(objectType: string, viewMode: ViewMode, }; } - -export function getListableObjectComponent(types: string[], viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { - let bestMatch = undefined; +export function getListableObjectComponent(types: Array>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { + let bestMatch; let bestMatchValue = 0; - for (let i = 0; i < types.length; i++) { - const typeMap = map.get(types[i]); + for (const type of types) { + const typeMap = map.get(type); if (hasValue(typeMap)) { const typeModeMap = typeMap.get(viewMode); if (hasValue(typeModeMap)) { @@ -52,4 +52,4 @@ export function getListableObjectComponent(types: string[], viewMode: ViewMode, } } return bestMatch; -} \ No newline at end of file +} diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts index 3b0decd7bd..ef84c8d7aa 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts @@ -5,4 +5,4 @@ import { Directive, ViewContainerRef } from '@angular/core'; }) export class ListableObjectDirective { constructor(public viewContainerRef: ViewContainerRef) { } -} \ No newline at end of file +} diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts index 80e0fe0048..01086897c5 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts @@ -12,6 +12,7 @@ import { SearchResultDetailElementComponent } from '../search-result-detail-elem import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; /** * This component renders claimed task object for the mydspace result in the detail view. @@ -22,7 +23,7 @@ import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claim templateUrl: './claimed-task-search-result-detail-element.component.html' }) -@listableObjectComponent(ClaimedTaskSearchResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(ClaimedTaskSearchResult, ViewMode.DetailedListElement) export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts index 4a64d99a50..ad528b3877 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts @@ -11,6 +11,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; /** * This component renders pool task object for the mydspace result in the detail view. @@ -21,7 +22,7 @@ import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-tas templateUrl: './pool-search-result-detail-element.component.html', }) -@listableObjectComponent(PoolTaskSearchResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(PoolTaskSearchResult, ViewMode.DetailedListElement) export class PoolSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts index 20ef2148ad..6393e26dbb 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts @@ -21,7 +21,7 @@ import { WorkflowItemSearchResult } from '../../../object-collection/shared/work templateUrl: './workflow-item-search-result-detail-element.component.html', }) -@listableObjectComponent(WorkflowItemSearchResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(WorkflowItemSearchResult, ViewMode.DetailedListElement) export class WorkflowItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts index a3527f0713..fc2c6a87cc 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts @@ -22,7 +22,7 @@ import { WorkspaceItemSearchResult } from '../../../object-collection/shared/wor templateUrl: './workspace-item-search-result-detail-element.component.html', }) -@listableObjectComponent(WorkspaceItemSearchResult.name, ViewMode.DetailedListElement) +@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.DetailedListElement) export class WorkspaceItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/object-detail.component.spec.ts b/src/app/shared/object-detail/object-detail.component.spec.ts index 651e6a89a8..7bec565562 100644 --- a/src/app/shared/object-detail/object-detail.component.spec.ts +++ b/src/app/shared/object-detail/object-detail.component.spec.ts @@ -9,6 +9,7 @@ import { PaginatedList } from '../../core/data/paginated-list'; import { PageInfo } from '../../core/shared/page-info.model'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { createSuccessfulRemoteDataObject } from '../testing/utils'; +import { DSpaceObject } from '../../core/shared/dspace-object.model'; describe('ObjectDetailComponent', () => { let comp: ObjectDetailComponent; @@ -16,16 +17,16 @@ describe('ObjectDetailComponent', () => { const testEvent = {test: 'test'}; const testObjects = [ - { one: 1 }, - { two: 2 }, - { three: 3 }, - { four: 4 }, - { five: 5 }, - { six: 6 }, - { seven: 7 }, - { eight: 8 }, - { nine: 9 }, - { ten: 10 } + Object.assign (new DSpaceObject(), { one: 1 }), + Object.assign (new DSpaceObject(), { two: 2 }), + Object.assign (new DSpaceObject(), { three: 3 }), + Object.assign (new DSpaceObject(), { four: 4 }), + Object.assign (new DSpaceObject(), { five: 5 }), + Object.assign (new DSpaceObject(), { six: 6 }), + Object.assign (new DSpaceObject(), { seven: 7 }), + Object.assign (new DSpaceObject(), { eight: 8 }), + Object.assign (new DSpaceObject(), { nine: 9 }), + Object.assign (new DSpaceObject(), { ten: 10 }), ]; const pageInfo = Object.assign(new PageInfo(), {elementsPerPage: 1, totalElements: 10, totalPages: 10, currentPage: 1}) const mockRD = createSuccessfulRemoteDataObject(new PaginatedList(pageInfo, testObjects)); diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts index a113e0dffd..1261cd6dfd 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './collection-grid-element.component.html' }) -@listableObjectComponent(Collection.name, ViewMode.GridElement) +@listableObjectComponent(Collection, ViewMode.GridElement) export class CollectionGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts index 498222466d..67d4ac663c 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './community-grid-element.component.html' }) -@listableObjectComponent(Community.name, ViewMode.GridElement) +@listableObjectComponent(Community, ViewMode.GridElement) export class CommunityGridElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts index a3103268fe..6171eb1e9d 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; @@ -6,12 +6,10 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { PublicationGridElementComponent } from './publication-grid-element.component'; import { of as observableOf } from 'rxjs/internal/observable/of'; -import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; -import { JournalGridElementComponent } from '../../../../../entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component'; const mockItem = Object.assign(new Item(), { bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), @@ -43,43 +41,41 @@ const mockItem = Object.assign(new Item(), { } }); -describe('PublicationGridElementComponent', - () => { - let comp; - let fixture; +describe('PublicationGridElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule], - declarations: [PublicationGridElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(PublicationGridElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [PublicationGridElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PublicationGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(PublicationGridElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(PublicationGridElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the publication is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a PublicationGridElementComponent`, () => { - const publicationGridElement = fixture.debugElement.query(By.css(`ds-publication-search-result-grid-element`)); - expect(publicationGridElement).not.toBeNull(); - }); + describe(`when the publication is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a PublicationGridElementComponent`, () => { + const publicationGridElement = fixture.debugElement.query(By.css(`ds-publication-search-result-grid-element`)); + expect(publicationGridElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts index 4927b18b9d..8450150dcb 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts @@ -6,7 +6,7 @@ import { AbstractListableElementComponent } from '../../../../object-collection/ import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.GridElement) -@listableObjectComponent(Item.name, ViewMode.GridElement) +@listableObjectComponent(Item, ViewMode.GridElement) @Component({ selector: 'ds-publication-grid-element', styleUrls: ['./publication-grid-element.component.scss'], diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts index 983b895e9c..1d0f47b70b 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts @@ -12,5 +12,5 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'collection-search-result-grid-element.component.html' }) -@listableObjectComponent(CollectionSearchResult.name, ViewMode.GridElement) +@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement) export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent {} diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts index e8e19c27d8..806e6a44e3 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts @@ -11,7 +11,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'community-search-result-grid-element.component.html' }) -@listableObjectComponent(CommunitySearchResult.name, ViewMode.GridElement) +@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement) export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts index ed61badbbd..3c1ef298a8 100644 --- a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts +++ b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts @@ -4,6 +4,7 @@ import { AbstractListableElementComponent } from '../../object-collection/shared import { BrowseEntry } from '../../../core/shared/browse-entry.model'; import { ViewMode } from '../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; +import { Collection } from '../../../core/shared/collection.model'; @Component({ selector: 'ds-browse-entry-list-element', @@ -14,5 +15,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable /** * This component is automatically used to create a list view for BrowseEntry objects when used in ObjectCollectionComponent */ -@listableObjectComponent(BrowseEntry.name, ViewMode.ListElement) +@listableObjectComponent(BrowseEntry, ViewMode.ListElement) export class BrowseEntryListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts index 7d57044ba4..685a990409 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './collection-list-element.component.html' }) -@listableObjectComponent(Collection.name, ViewMode.ListElement) +@listableObjectComponent(Collection, ViewMode.ListElement) export class CollectionListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/community-list-element/community-list-element.component.ts b/src/app/shared/object-list/community-list-element/community-list-element.component.ts index 4c3e8bbd6f..4581c2c0da 100644 --- a/src/app/shared/object-list/community-list-element/community-list-element.component.ts +++ b/src/app/shared/object-list/community-list-element/community-list-element.component.ts @@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable templateUrl: './community-list-element.component.html' }) -@listableObjectComponent(Community.name, ViewMode.ListElement) +@listableObjectComponent(Community, ViewMode.ListElement) export class CommunityListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts index 24bc774b1f..4814123072 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts @@ -43,42 +43,40 @@ const mockItem: Item = Object.assign(new Item(), { } }); -describe('PublicationListElementComponent', - () => { - let comp; - let fixture; +describe('PublicationListElementComponent', () => { + let comp; + let fixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [PublicationListElementComponent, TruncatePipe], - providers: [ - { provide: TruncatableService, useValue: truncatableServiceStub }, - ], - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(PublicationListElementComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default } - }).compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PublicationListElementComponent, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PublicationListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); - beforeEach(async(() => { - fixture = TestBed.createComponent(PublicationListElementComponent); - comp = fixture.componentInstance; - })); + beforeEach(async(() => { + fixture = TestBed.createComponent(PublicationListElementComponent); + comp = fixture.componentInstance; + })); - describe(`when the publication is rendered`, () => { - beforeEach(() => { - comp.object = mockItem; - fixture.detectChanges(); - }); - - it(`should contain a PublicationListElementComponent`, () => { - const publicationListElement = fixture.debugElement.query(By.css(`ds-publication-search-result-list-element`)); - expect(publicationListElement).not.toBeNull(); - }); + describe(`when the publication is rendered`, () => { + beforeEach(() => { + comp.object = mockItem; + fixture.detectChanges(); }); - }); \ No newline at end of file + it(`should contain a PublicationListElementComponent`, () => { + const publicationListElement = fixture.debugElement.query(By.css(`ds-publication-search-result-list-element`)); + expect(publicationListElement).not.toBeNull(); + }); + }); +}); diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 73cdf978ac..59d0249aef 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -5,7 +5,7 @@ import { AbstractListableElementComponent } from '../../../../object-collection/ import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.ListElement) -@listableObjectComponent(Item.name, ViewMode.ListElement) +@listableObjectComponent(Item, ViewMode.ListElement) @Component({ selector: 'ds-publication-list-element', styleUrls: ['./publication-list-element.component.scss'], diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts index 1e74487a97..aba6482bd1 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts @@ -13,6 +13,7 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; +import { Item } from '../../../../core/shared/item.model'; /** * This component renders claimed task object for the mydspace result in the list view. @@ -24,7 +25,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) -@listableObjectComponent(ClaimedTaskSearchResult.name, ViewMode.ListElement) +@listableObjectComponent(ClaimedTaskSearchResult, ViewMode.ListElement) export class ClaimedSearchResultListElementComponent extends SearchResultListElementComponent { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index 31d2977304..72ee0ba235 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -17,14 +17,14 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme templateUrl: './item-search-result-list-element-submission.component.html' }) -@listableObjectComponent(ItemSearchResult.name, ViewMode.ListElement, Context.Submission) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Submission) export class ItemSearchResultListElementSubmissionComponent extends SearchResultListElementComponent implements OnInit { - ngOnInit() { - super.ngOnInit(); - } - /** * Represent item's status */ public status = MyDspaceItemStatusType.ARCHIVED; + + ngOnInit() { + super.ngOnInit(); + } } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts index 92e0ea3818..5597a2126d 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts @@ -13,6 +13,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { TruncatableService } from '../../../truncatable/truncatable.service'; +import { Item } from '../../../../core/shared/item.model'; /** * This component renders pool task object for the mydspace result in the list view. @@ -23,7 +24,7 @@ import { TruncatableService } from '../../../truncatable/truncatable.service'; templateUrl: './pool-search-result-list-element.component.html', }) -@listableObjectComponent(PoolTaskSearchResult.name, ViewMode.ListElement) +@listableObjectComponent(PoolTaskSearchResult, ViewMode.ListElement) export class PoolSearchResultListElementComponent extends SearchResultListElementComponent implements OnInit { /** diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts index 6a9013b9af..cb985b9906 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts @@ -22,9 +22,9 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme templateUrl: './workflow-item-search-result-list-element.component.html', }) -@listableObjectComponent(WorkflowItemSearchResult.name, ViewMode.ListElement) +@listableObjectComponent(WorkflowItemSearchResult, ViewMode.ListElement) export class WorkflowItemSearchResultListElementComponent extends SearchResultListElementComponent { - + /** * The item object that belonging to the result object */ diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts index dd32f56aba..ed2770f852 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts @@ -22,7 +22,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme templateUrl: './workspace-item-search-result-list-element.component.html', }) -@listableObjectComponent(WorkspaceItemSearchResult.name, ViewMode.ListElement) +@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.ListElement) export class WorkspaceItemSearchResultListElementComponent extends SearchResultListElementComponent { /** diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts index 014763c53a..b42186e367 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts @@ -1,6 +1,4 @@ import { Component } from '@angular/core'; - - import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Collection } from '../../../../core/shared/collection.model'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; @@ -13,5 +11,5 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista templateUrl: 'collection-search-result-list-element.component.html' }) -@listableObjectComponent(CollectionSearchResult.name, ViewMode.ListElement) +@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement) export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent {} diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts index fd3bba85e9..a1da9a04ff 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts @@ -1,12 +1,9 @@ import { Component } from '@angular/core'; - - import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Community } from '../../../../core/shared/community.model'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { BrowseEntry } from '../../../../core/shared/browse-entry.model'; @Component({ selector: 'ds-community-search-result-list-element', @@ -14,7 +11,7 @@ import { BrowseEntry } from '../../../../core/shared/browse-entry.model'; templateUrl: 'community-search-result-list-element.component.html' }) -@listableObjectComponent(CommunitySearchResult.name, ViewMode.ListElement) +@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement) export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts index 3a72b8ef26..7b376ead8e 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts @@ -6,7 +6,7 @@ import { SearchResultListElementComponent } from '../../../search-result-list-el import { Item } from '../../../../../../core/shared/item.model'; @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) -@listableObjectComponent(ItemSearchResult.name, ViewMode.ListElement) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement) @Component({ selector: 'ds-publication-search-result-list-element', styleUrls: ['./publication-search-result-list-element.component.scss'], diff --git a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html index 6b6f484183..b9b1b25462 100644 --- a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html +++ b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html @@ -4,53 +4,53 @@
- +
- - + + - + - -
- - + - - - + +
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index a25a474eb0..cfb23f4b94 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -4,11 +4,11 @@
- + @@ -17,33 +17,33 @@

{{'journalissue.page.titleprefix' | translate}} + [mdValues]="object?.allMetadata(['dc.title'])">

- - -
- - - diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html index c20e9a775a..5435fea118 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html @@ -4,11 +4,11 @@
- + @@ -17,22 +17,22 @@

{{'journalvolume.page.titleprefix' | translate}} + [mdValues]="object?.allMetadata(['dc.title'])">

- -
- diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index ef827af590..978f77fbbb 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -3,11 +3,11 @@
- + @@ -16,26 +16,26 @@

{{'journal.page.titleprefix' | translate}} + [mdValues]="object?.allMetadata(['dc.title'])">

- - -
- @@ -61,7 +61,7 @@

{{"item.page.journal.search.title" | translate}}

-
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html index 6bb925c93f..b2424e7963 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html @@ -4,12 +4,12 @@
- @@ -18,29 +18,29 @@

{{'orgunit.page.titleprefix' | translate}} + [mdValues]="object?.allMetadata(['orgunit.identifier.name'])">

- - -
- - diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html index 54d7962b97..cb5bd8f1ae 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -4,12 +4,12 @@
- @@ -17,37 +17,37 @@

{{'person.page.titleprefix' | translate}} + [mdValues]="object?.allMetadata(['dc.contributor.author'])">

- - - -
- - - @@ -79,7 +79,7 @@

{{"item.page.person.search.title" | translate}}

-
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html index aa4a107247..bdbcac5b52 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -4,12 +4,12 @@
- @@ -18,7 +18,7 @@

{{'project.page.titleprefix' | translate}} + [mdValues]="object?.allMetadata(['project.identifier.name'])">

@@ -26,29 +26,29 @@ [label]="'project.page.contributor' | translate" [representations]="contributors$ | async"> - - -
- - - From d962e40c58d1fc46c9e2c8fe2b525fda9bafa1e3 Mon Sep 17 00:00:00 2001 From: lotte Date: Wed, 16 Oct 2019 11:21:25 +0200 Subject: [PATCH 11/17] added TypeDoc --- .../generic-item-page-field.component.ts | 2 +- .../+item-page/simple/item-page.component.ts | 8 +-- .../publication/publication.component.ts | 7 ++ .../metadata-representation-list.component.ts | 1 - .../my-dspace-new-submission.component.ts | 3 + src/app/+search-page/search-page.module.ts | 4 -- src/app/+search-page/search-result.model.ts | 3 + .../search-results.component.ts | 3 + .../search-result-element-decorator.ts | 1 - .../models/normalized-eperson.model.ts | 1 - .../eperson/models/normalized-group.model.ts | 1 - src/app/core/metadata/metadata-field.model.ts | 3 + .../core/metadata/metadata-schema.model.ts | 3 + src/app/core/shared/browse-entry.model.ts | 3 + src/app/core/shared/dspace-object.model.ts | 5 +- src/app/core/shared/item.model.ts | 6 ++ .../journal/journal-grid-element.component.ts | 1 - ...ue-search-result-grid-element.component.ts | 2 +- ...me-search-result-grid-element.component.ts | 2 +- ...al-search-result-grid-element.component.ts | 2 +- ...ue-search-result-list-element.component.ts | 2 +- ...me-search-result-list-element.component.ts | 2 +- ...al-search-result-list-element.component.ts | 2 +- .../journal-issue/journal-issue.component.ts | 3 + .../journal-volume.component.ts | 3 + .../item-pages/journal/journal.component.ts | 3 + ...it-search-result-grid-element.component.ts | 2 +- ...on-search-result-grid-element.component.ts | 2 +- ...ct-search-result-grid-element.component.ts | 2 +- ...rgunit-item-page-list-element.component.ts | 2 +- ...person-item-page-list-element.component.ts | 4 +- ...it-search-result-list-element.component.ts | 2 +- ...on-search-result-list-element.component.ts | 2 +- ...ct-search-result-list-element.component.ts | 2 +- .../dso-selector/dso-selector.component.ts | 3 + .../dso-input-suggestions.component.ts | 8 +++ ...etadata-representation-loader.component.ts | 15 +++- .../metadata-representation.decorator.ts | 13 ++++ .../metadata-representation.directive.ts | 3 + .../collection-element-link.type.ts | 6 ++ .../object-collection.component.ts | 71 +++++++++++++++++-- .../claimed-task-search-result.model.ts | 1 - .../shared/item-search-result.model.ts | 5 +- .../shared/listable-object.model.ts | 4 ++ ...table-object-component-loader.component.ts | 23 +++++- .../listable-object.decorator.ts | 13 +++- .../listable-object.directive.ts | 3 + .../abstract-listable-element.component.ts | 11 +++ .../shared/pool-task-search-result.model.ts | 1 - ...-search-result-detail-element.component.ts | 2 +- .../item-detail-preview-field.component.ts | 2 +- .../item-detail-preview.component.ts | 2 +- ...-search-result-detail-element.component.ts | 10 +-- ...-search-result-detail-element.component.ts | 7 +- .../search-result-detail-element.component.ts | 6 ++ ...-search-result-detail-element.component.ts | 2 +- ...-search-result-detail-element.component.ts | 2 +- .../object-detail/object-detail.component.ts | 11 +++ .../collection-grid-element.component.ts | 3 + .../community-grid-element.component.ts | 3 + .../object-grid/object-grid.component.ts | 67 ++++++++++++++++- ...on-search-result-grid-element.component.ts | 4 +- ...ty-search-result-grid-element.component.ts | 5 +- ...on-search-result-grid-element.component.ts | 2 +- .../search-result-grid-element.component.ts | 10 +++ .../collection-list-element.component.ts | 4 +- .../community-list-element.component.ts | 4 +- .../item-type-badge.component.ts | 6 ++ .../item-metadata-list-element.component.ts | 2 +- ...a-representation-list-element.component.ts | 3 + ...ed-search-result-list-element.component.ts | 3 +- .../item-list-preview.component.ts | 2 +- ...esult-list-element-submission.component.ts | 2 +- ...ol-search-result-list-element.component.ts | 8 ++- ...em-search-result-list-element.component.ts | 2 +- ...em-search-result-list-element.component.ts | 2 +- .../object-list/object-list.component.ts | 69 +++++++++++++++++- ...on-search-result-list-element.component.ts | 4 +- ...ty-search-result-list-element.component.ts | 4 +- ...on-search-result-list-element.component.ts | 2 +- .../search-result-list-element.component.ts | 11 ++- src/app/shared/shared.module.ts | 10 +++ .../view-mode-switch.component.ts | 18 +++++ src/backend/api.ts | 4 +- 84 files changed, 479 insertions(+), 93 deletions(-) diff --git a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.ts b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.ts index ee7d27a11f..3b8d261dcc 100644 --- a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.ts +++ b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.ts @@ -10,7 +10,7 @@ import { ItemPageFieldComponent } from '../item-page-field.component'; /** * This component can be used to represent metadata on a simple item page. * It is the most generic way of displaying metadata values - * It expects 4 parameters: The item, a seperator, the metadata keys and an i18n key + * It expects 4 parameters: The item, a separator, the metadata keys and an i18n key */ export class GenericItemPageFieldComponent extends ItemPageFieldComponent { diff --git a/src/app/+item-page/simple/item-page.component.ts b/src/app/+item-page/simple/item-page.component.ts index 3b51357e00..10deef23e4 100644 --- a/src/app/+item-page/simple/item-page.component.ts +++ b/src/app/+item-page/simple/item-page.component.ts @@ -1,19 +1,16 @@ - -import { mergeMap, filter, map, take, tap } from 'rxjs/operators'; +import { map } from 'rxjs/operators'; import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Observable } from 'rxjs'; import { ItemDataService } from '../../core/data/item-data.service'; import { RemoteData } from '../../core/data/remote-data'; -import { Bitstream } from '../../core/shared/bitstream.model'; import { Item } from '../../core/shared/item.model'; import { MetadataService } from '../../core/metadata/metadata.service'; import { fadeInOut } from '../../shared/animations/fade'; -import { hasValue } from '../../shared/empty.util'; import { redirectToPageNotFoundOn404 } from '../../core/shared/operators'; import { ViewMode } from '../../core/shared/view-mode.model'; @@ -53,6 +50,9 @@ export class ItemPageComponent implements OnInit { private metadataService: MetadataService, ) { } + /** + * Initialize instance variables + */ ngOnInit(): void { this.itemRD$ = this.route.data.pipe( map((data) => data.item as RemoteData), diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index 777f42d1f0..7f49e41995 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -7,6 +7,10 @@ import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +/** + * Component that represents a publication Item page + */ + @listableObjectComponent('Publication', ViewMode.StandalonePage) @listableObjectComponent(Item, ViewMode.StandalonePage) @Component({ @@ -36,6 +40,9 @@ export class PublicationComponent extends ItemComponent implements OnInit { */ journalIssues$: Observable; + /** + * Initialize instance variables + */ ngOnInit(): void { super.ngOnInit(); diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts index f88bb12386..20512733f1 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -1,6 +1,5 @@ import { Component, Input } from '@angular/core'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; -import { ViewMode } from '../../../core/shared/view-mode.model'; @Component({ selector: 'ds-metadata-representation-list', diff --git a/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts b/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts index 09adc16af6..76853db924 100644 --- a/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts +++ b/src/app/+my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts @@ -25,6 +25,9 @@ import { SearchResult } from '../../+search-page/search-result.model'; templateUrl: './my-dspace-new-submission.component.html' }) export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit { + /** + * Output that emits the workspace item when the upload has completed + */ @Output() uploadEnd = new EventEmitter>>(); /** diff --git a/src/app/+search-page/search-page.module.ts b/src/app/+search-page/search-page.module.ts index 940ac45442..da6d5856d5 100644 --- a/src/app/+search-page/search-page.module.ts +++ b/src/app/+search-page/search-page.module.ts @@ -43,8 +43,6 @@ const components = [ SearchResultsComponent, SearchSidebarComponent, SearchSettingsComponent, - CollectionSearchResultGridElementComponent, - CommunitySearchResultGridElementComponent, SearchFiltersComponent, SearchFilterComponent, SearchFacetFilterComponent, @@ -83,8 +81,6 @@ const components = [ SearchConfigurationService ], entryComponents: [ - CollectionSearchResultGridElementComponent, - CommunitySearchResultGridElementComponent, SearchFacetFilterComponent, SearchRangeFilterComponent, SearchTextFilterComponent, diff --git a/src/app/+search-page/search-result.model.ts b/src/app/+search-page/search-result.model.ts index 4f15656d59..95359209d9 100644 --- a/src/app/+search-page/search-result.model.ts +++ b/src/app/+search-page/search-result.model.ts @@ -17,6 +17,9 @@ export class SearchResult implements ListableObject { */ hitHighlights: MetadataMap; + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array> { return [this.constructor as GenericConstructor]; } diff --git a/src/app/+search-page/search-results/search-results.component.ts b/src/app/+search-page/search-results/search-results.component.ts index 46d15d97d9..24c973e296 100644 --- a/src/app/+search-page/search-results/search-results.component.ts +++ b/src/app/+search-page/search-results/search-results.component.ts @@ -25,6 +25,9 @@ import { CollectionElementLinkType } from '../../shared/object-collection/collec export class SearchResultsComponent { hasNoValue = hasNoValue; + /** + * The link type of the listed search results + */ @Input() linkType: CollectionElementLinkType; /** diff --git a/src/app/+search-page/search-service/search-result-element-decorator.ts b/src/app/+search-page/search-service/search-result-element-decorator.ts index 34e61abc01..62887387c5 100644 --- a/src/app/+search-page/search-service/search-result-element-decorator.ts +++ b/src/app/+search-page/search-service/search-result-element-decorator.ts @@ -18,7 +18,6 @@ export function searchResultFor(domainConstructor: GenericConstructor> { return [this.constructor as GenericConstructor]; } diff --git a/src/app/core/metadata/metadata-schema.model.ts b/src/app/core/metadata/metadata-schema.model.ts index 36ccaae36d..78d5338f2e 100644 --- a/src/app/core/metadata/metadata-schema.model.ts +++ b/src/app/core/metadata/metadata-schema.model.ts @@ -28,6 +28,9 @@ export class MetadataSchema implements ListableObject { */ namespace: string; + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array> { return [this.constructor as GenericConstructor]; } diff --git a/src/app/core/shared/browse-entry.model.ts b/src/app/core/shared/browse-entry.model.ts index b2470032ad..977afb40f6 100644 --- a/src/app/core/shared/browse-entry.model.ts +++ b/src/app/core/shared/browse-entry.model.ts @@ -30,6 +30,9 @@ export class BrowseEntry implements ListableObject { */ count: number; + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array> { return [this.constructor as GenericConstructor]; } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 685f886b19..2e50f19c4f 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -110,7 +110,7 @@ export class DSpaceObject implements CacheableObject, ListableObject { * Like [[firstMetadata]], but only returns a string value, or `undefined`. * * @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]]. - * @param {MetadataValueFilter} filter The value filter to use. If unspecified, no filtering will be done. + * @param {MetadataValueFilter} valueFilter The value filter to use. If unspecified, no filtering will be done. * @returns {string} the first matching string value, or `undefined`. */ firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter): string { @@ -147,6 +147,9 @@ export class DSpaceObject implements CacheableObject, ListableObject { }); } + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array> { return [this.constructor as GenericConstructor]; } diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index 191a258c4f..733a8f941c 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -14,6 +14,9 @@ import { GenericConstructor } from './generic-constructor'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { DEFAULT_ENTITY_TYPE } from '../../shared/metadata-representation/metadata-representation.decorator'; +/** + * Class representing a DSpace Item + */ export class Item extends DSpaceObject { static type = new ResourceType('item'); @@ -113,6 +116,9 @@ export class Item extends DSpaceObject { })); } + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array> { let entityType = this.firstMetadataValue('relationship.type'); if (isEmpty(entityType)) { diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts index c86529317b..1d7c1e5b73 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts @@ -1,5 +1,4 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts index ceda357559..9d27842c16 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model'; animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Journal Issue + * The component for displaying a grid element for an item search result of the type Journal Issue */ export class JournalIssueSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts index 9ce106f962..802a6d8692 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { focusShadow } from '../../../../../shared/animations/focus'; animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Journal Volume + * The component for displaying a grid element for an item search result of the type Journal Volume */ export class JournalVolumeSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts index 5f24601223..97d43356c6 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model'; animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Journal + * The component for displaying a grid element for an item search result of the type Journal */ export class JournalSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts index 65969752ea..1d320cbfe8 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts @@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model'; templateUrl: './journal-issue-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Journal Issue + * The component for displaying a list element for an item search result of the type Journal Issue */ export class JournalIssueSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts index 05ffe5ea57..41795b8022 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts @@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model'; templateUrl: './journal-volume-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Journal Volume + * The component for displaying a list element for an item search result of the type Journal Volume */ export class JournalVolumeSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts index 3e389dcc83..01de0d4626 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts @@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model'; templateUrl: './journal-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Journal + * The component for displaying a list element for an item search result of the type Journal */ export class JournalSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts index 151a60a198..3643d5ad91 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts @@ -27,6 +27,9 @@ export class JournalIssueComponent extends ItemComponent { */ publications$: Observable; + /** + * Initialize the instance variables + */ ngOnInit(): void { super.ngOnInit(); diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts index b1d83c25f2..8864e05695 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts @@ -27,6 +27,9 @@ export class JournalVolumeComponent extends ItemComponent { */ issues$: Observable; + /** + * Initialize the instance variables + */ ngOnInit(): void { super.ngOnInit(); diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts index 1282144a2f..239993aa08 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts @@ -22,6 +22,9 @@ export class JournalComponent extends ItemComponent { */ volumes$: Observable; + /** + * Initialize the instance variables + */ ngOnInit(): void { super.ngOnInit(); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts index 535fb0cdbc..71a435762a 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model'; animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Organisation Unit + * The component for displaying a grid element for an item search result of the type Organisation Unit */ export class OrgunitSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts index 19293c9ed4..55bc4f5a0d 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model'; animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Person + * The component for displaying a grid element for an item search result of the type Person */ export class PersonSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts index 57c57c6cb1..a352d2dcb0 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { focusShadow } from '../../../../../shared/animations/focus'; animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Project + * The component for displaying a grid element for an item search result of the type Project */ export class ProjectSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts index 2025faac75..7121670b38 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -9,7 +9,7 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep templateUrl: './orgunit-item-page-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type OrgUnit + * The component for displaying an item of the type OrgUnit as a metadata field */ export class OrgunitItemPageListElementComponent { metadataRepresentation: ItemMetadataRepresentation; diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts index 6679852cdb..d7666237ad 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts @@ -12,8 +12,8 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep templateUrl: './person-item-page-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Person - */ + * The component for displaying an item of the type Person as a metadata field +*/ export class PersonItemPageListElementComponent { metadataRepresentation: ItemMetadataRepresentation; } diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts index 860e1154ef..5e3cdedd60 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts @@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model'; templateUrl: './orgunit-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Organisation Unit + * The component for displaying a list element for an item search result of the type Organisation Unit */ export class OrgunitSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts index b53a369504..b4b4621261 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts @@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model'; templateUrl: './person-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Person + * The component for displaying a list element for an item search result of the type Person */ export class PersonSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts index c00ae53d6c..faa15add31 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts @@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model'; templateUrl: './project-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Project + * The component for displaying a list element for an item search result of the type Project */ export class ProjectSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 32149e29dc..af26f3f04f 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -32,6 +32,9 @@ import { ViewMode } from '../../../core/shared/view-mode.model'; * The user can search the list by using the input field */ export class DSOSelectorComponent implements OnInit { + /** + * The view mode of the listed objects + */ viewMode = ViewMode.ListElement; /** * The initially selected DSO's uuid diff --git a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts index 92775f25c6..cf3658d5c9 100644 --- a/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts +++ b/src/app/shared/input-suggestions/dso-input-suggestions/dso-input-suggestions.component.ts @@ -24,8 +24,16 @@ import { CollectionElementLinkType } from '../../object-collection/collection-el * Component representing a form with a autocomplete functionality for DSpaceObjects */ export class DsoInputSuggestionsComponent extends InputSuggestionsComponent { + /** + * The view mode of the listed object suggestions + */ viewMode = ViewMode.ListElement; + + /** + * The available link types + */ linkTypes = CollectionElementLinkType; + /** * The suggestions that should be shown */ diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts index 9dcdeb14ec..eb385b5afd 100644 --- a/src/app/shared/metadata-representation/metadata-representation-loader.component.ts +++ b/src/app/shared/metadata-representation/metadata-representation-loader.component.ts @@ -12,19 +12,30 @@ import { MetadataRepresentationDirective } from './metadata-representation.direc templateUrl: './metadata-representation-loader.component.html' }) /** - * Component for determining what component to use depending on the item's relationship type (relationship.type) + * Component for determining what component to use depending on the item's relationship type (relationship.type), its metadata representation and, optionally, its context */ export class MetadataRepresentationLoaderComponent implements OnInit { /** * The item or metadata to determine the component for */ @Input() mdRepresentation: MetadataRepresentation; + + /** + * The optional context + */ @Input() context: Context; + + /** + * Directive to determine where the dynamic child component is located + */ @ViewChild(MetadataRepresentationDirective) mdRepDirective: MetadataRepresentationDirective; constructor(private componentFactoryResolver: ComponentFactoryResolver) { } + /** + * Set up the dynamic child component + */ ngOnInit(): void { const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); @@ -36,7 +47,7 @@ export class MetadataRepresentationLoaderComponent implements OnInit { } /** - * Fetch the component depending on the item's relationship type + * Fetch the component depending on the item's relationship type, metadata representation type and context * @returns {string} */ private getComponent(): GenericConstructor { diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.ts index 7ba626dbf7..0903e05f56 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.ts @@ -8,6 +8,13 @@ export const DEFAULT_ENTITY_TYPE = 'Publication'; export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; export const DEFAULT_CONTEXT = Context.Undefined; + +/** + * Decorator function to store metadata representation mapping + * @param entityType The entity type the component represents + * @param mdRepresentationType The metadata representation type the component represents + * @param context The optional context the component represents + */ export function metadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { return function decorator(component: any) { if (hasNoValue(map.get(entityType))) { @@ -24,6 +31,12 @@ export function metadataRepresentationComponent(entityType: string, mdRepresenta } } +/** + * Getter to retrieve a matching component by entity type, metadata representation and context + * @param entityType The entity type to match + * @param mdRepresentationType The metadata representation to match + * @param context The context to match + */ export function getMetadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { const mapForEntity = map.get(entityType); if (hasValue(mapForEntity)) { diff --git a/src/app/shared/metadata-representation/metadata-representation.directive.ts b/src/app/shared/metadata-representation/metadata-representation.directive.ts index c8c909d03f..9ff0573baf 100644 --- a/src/app/shared/metadata-representation/metadata-representation.directive.ts +++ b/src/app/shared/metadata-representation/metadata-representation.directive.ts @@ -3,6 +3,9 @@ import { Directive, ViewContainerRef } from '@angular/core'; @Directive({ selector: '[dsMetadataRepresentation]', }) +/** + * Directive used as a hook to know where to inject the dynamic metadata representation component + */ export class MetadataRepresentationDirective { constructor(public viewContainerRef: ViewContainerRef) { } } diff --git a/src/app/shared/object-collection/collection-element-link.type.ts b/src/app/shared/object-collection/collection-element-link.type.ts index 5d50ac3bb2..78b690b5ab 100644 --- a/src/app/shared/object-collection/collection-element-link.type.ts +++ b/src/app/shared/object-collection/collection-element-link.type.ts @@ -1,3 +1,9 @@ +/** + * Enumeration used to render links in listable elements + * None: Don't render the link as a link, but as plain text + * Link: Render the link as a simple link + * ExternalLink: Render the link as a link that opens in a new tab + */ export enum CollectionElementLinkType { None, Link, ExternalLink } diff --git a/src/app/shared/object-collection/object-collection.component.ts b/src/app/shared/object-collection/object-collection.component.ts index 2756d38639..955c21a26a 100644 --- a/src/app/shared/object-collection/object-collection.component.ts +++ b/src/app/shared/object-collection/object-collection.component.ts @@ -15,21 +15,55 @@ import { CollectionElementLinkType } from './collection-element-link.type'; import { PaginatedList } from '../../core/data/paginated-list'; import { Context } from '../../core/shared/context.model'; +/** + * Component that can render a list of listable objects in different view modes + */ @Component({ selector: 'ds-viewable-collection', styleUrls: ['./object-collection.component.scss'], templateUrl: './object-collection.component.html', }) export class ObjectCollectionComponent implements OnInit { - + /** + * The list of listable objects to render in this component + */ @Input() objects: RemoteData>; + + /** + * The current pagination configuration + */ @Input() config?: PaginationComponentOptions; + + /** + * The current sorting configuration + */ @Input() sortConfig: SortOptions; + + /** + * Whether or not the list elements have a border or not + */ @Input() hasBorder = false; + + /** + * Whether or not to hide the gear to change the sort and pagination configuration + */ @Input() hideGear = false; + + /** + * The link type of the rendered list elements + */ @Input() linkType: CollectionElementLinkType; + + /** + * The context of the rendered list elements + */ @Input() context: Context; + + /** + * the page info of the list + */ pageInfo: Observable; + /** * An event fired when the page is changed. * Event's payload equals to the newly selected page. @@ -48,6 +82,9 @@ export class ObjectCollectionComponent implements OnInit { */ @Output() sortDirectionChange: EventEmitter = new EventEmitter(); + /** + * An event fired one of the pagination parameters is changed + */ @Output() paginationChange: EventEmitter = new EventEmitter(); /** @@ -55,8 +92,15 @@ export class ObjectCollectionComponent implements OnInit { * Event's payload equals to the newly selected sort field. */ @Output() sortFieldChange: EventEmitter = new EventEmitter(); - data: any = {}; + + /** + * Emits the current view mode + */ currentMode$: Observable; + + /** + * The available view modes + */ viewModeEnum = ViewMode; ngOnInit(): void { @@ -83,22 +127,39 @@ export class ObjectCollectionComponent implements OnInit { private router: Router) { } + /** + * Updates the page + * @param event The new page number + */ onPageChange(event) { this.pageChange.emit(event); } - + /** + * Updates the page size + * @param event The new page size + */ onPageSizeChange(event) { this.pageSizeChange.emit(event); } - + /** + * Updates the sort direction + * @param event The new sort direction + */ onSortDirectionChange(event) { this.sortDirectionChange.emit(event); } - + /** + * Updates the sort field + * @param event The new sort field + */ onSortFieldChange(event) { this.sortFieldChange.emit(event); } + /** + * Updates the pagination + * @param event The new pagination + */ onPaginationChange(event) { this.paginationChange.emit(event); } diff --git a/src/app/shared/object-collection/shared/claimed-task-search-result.model.ts b/src/app/shared/object-collection/shared/claimed-task-search-result.model.ts index 734b4716ba..4a7bf97850 100644 --- a/src/app/shared/object-collection/shared/claimed-task-search-result.model.ts +++ b/src/app/shared/object-collection/shared/claimed-task-search-result.model.ts @@ -1,6 +1,5 @@ import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.model'; import { SearchResult } from '../../../+search-page/search-result.model'; -import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; /** diff --git a/src/app/shared/object-collection/shared/item-search-result.model.ts b/src/app/shared/object-collection/shared/item-search-result.model.ts index defd4a99c8..d38968ce76 100644 --- a/src/app/shared/object-collection/shared/item-search-result.model.ts +++ b/src/app/shared/object-collection/shared/item-search-result.model.ts @@ -3,10 +3,13 @@ import { Item } from '../../../core/shared/item.model'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { ListableObject } from './listable-object.model'; -import { isEmpty } from '../../empty.util'; @searchResultFor(Item) export class ItemSearchResult extends SearchResult { + + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array> { return this.indexableObject.getRenderTypes().map((type) => { if (typeof type === 'string') { diff --git a/src/app/shared/object-collection/shared/listable-object.model.ts b/src/app/shared/object-collection/shared/listable-object.model.ts index a81c9f4aeb..d7eaf0750f 100644 --- a/src/app/shared/object-collection/shared/listable-object.model.ts +++ b/src/app/shared/object-collection/shared/listable-object.model.ts @@ -2,5 +2,9 @@ import { TypedObject } from '../../../core/cache/object-cache.reducer'; import { GenericConstructor } from '../../../core/shared/generic-constructor'; export interface ListableObject extends TypedObject { + + /** + * Method that returns as which type of object this object should be rendered + */ getRenderTypes(): Array>; } diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 2b90d3f94f..648298b0fe 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -21,20 +21,37 @@ export class ListableObjectComponentLoaderComponent implements OnInit { */ @Input() object: ListableObject; - // TODO DO SOMETHING WITH THIS + /** + * The index of the object in the list + */ @Input() index: number; + /** * The preferred view-mode to display */ @Input() viewMode: ViewMode; + /** + * The context of listable object + */ @Input() context: Context; + + /** + * The type of link used to render the links inside the listable object + */ @Input() linkType: CollectionElementLinkType; + + /** + * Directive hook used to place the dynamic child component + */ @ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective; constructor(private componentFactoryResolver: ComponentFactoryResolver) { } + /** + * Setup the dynamic child component + */ ngOnInit(): void { const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); @@ -48,8 +65,8 @@ export class ListableObjectComponentLoaderComponent implements OnInit { } /** - * Fetch the component depending on the item's relationship type - * @returns {string} + * Fetch the component depending on the item's relationship type, view mode and context + * @returns {GenericConstructor} */ private getComponent(): GenericConstructor { return getListableObjectComponent(this.object.getRenderTypes(), this.viewMode, this.context) diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts index 1a0daa6505..66110516bb 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.ts @@ -10,9 +10,10 @@ export const DEFAULT_VIEW_MODE = ViewMode.ListElement; const map = new Map(); /** - * Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) - * @param type - * @param viewMode + * Decorator used for rendering a listable object + * @param type The object type or entity type the component represents + * @param viewMode The view mode the component represents + * @param context The optional context the component represents */ export function listableObjectComponent(objectType: string | GenericConstructor, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { return function decorator(component: any) { @@ -29,6 +30,12 @@ export function listableObjectComponent(objectType: string | GenericConstructor< }; } +/** + * Getter to retrieve the matching listable object component + * @param types The types of which one should match the listable component + * @param viewMode The view mode that should match the components + * @param context The context that should match the components + */ export function getListableObjectComponent(types: Array>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { let bestMatch; let bestMatchValue = 0; diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts index ef84c8d7aa..93c06961f4 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.directive.ts @@ -3,6 +3,9 @@ import { Directive, ViewContainerRef } from '@angular/core'; @Directive({ selector: '[dsListableObject]', }) +/** + * Directive used as a hook to know where to inject the dynamic listable object component + */ export class ListableObjectDirective { constructor(public viewContainerRef: ViewContainerRef) { } } diff --git a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts index 6d9f0289dd..c09f7df18c 100644 --- a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts +++ b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts @@ -7,7 +7,18 @@ import { CollectionElementLinkType } from '../../collection-element-link.type'; template: ``, }) export class AbstractListableElementComponent { + /** + * The object to render in this list element + */ @Input() object: T; + + /** + * The link type to determine the type of link rendered in this element + */ @Input() linkType: CollectionElementLinkType; + + /** + * The available link types + */ linkTypes = CollectionElementLinkType; } diff --git a/src/app/shared/object-collection/shared/pool-task-search-result.model.ts b/src/app/shared/object-collection/shared/pool-task-search-result.model.ts index b44b172acb..0af55d31a4 100644 --- a/src/app/shared/object-collection/shared/pool-task-search-result.model.ts +++ b/src/app/shared/object-collection/shared/pool-task-search-result.model.ts @@ -1,6 +1,5 @@ import { PoolTask } from '../../../core/tasks/models/pool-task-object.model'; import { SearchResult } from '../../../+search-page/search-result.model'; -import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts index 01086897c5..fa51fa61f6 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts @@ -15,7 +15,7 @@ import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claim import { Item } from '../../../../core/shared/item.model'; /** - * This component renders claimed task object for the mydspace result in the detail view. + * This component renders claimed task object for the search result in the detail view. */ @Component({ selector: 'ds-claimed-task-search-result-detail-element', diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts index c87a771f51..2456913080 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component.ts @@ -19,7 +19,7 @@ export class ItemDetailPreviewFieldComponent { @Input() item: Item; /** - * The mydspace result object + * The search result object */ @Input() object: SearchResult; diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts index 772ba3e50a..d9b0785559 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.ts @@ -25,7 +25,7 @@ export class ItemDetailPreviewComponent { @Input() item: Item; /** - * The mydspace result object + * The search result object */ @Input() object: SearchResult; diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts index 4a9b4d6380..7e611ec3c8 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component.ts @@ -8,7 +8,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; /** - * This component renders item object for the mydspace result in the detail view. + * This component renders item object for the search result in the detail view. */ @Component({ selector: 'ds-item-search-result-detail-element', @@ -16,13 +16,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search- templateUrl: './item-search-result-detail-element.component.html' }) -@listableObjectComponent('PublicationSearchResult', ViewMode.DetailedListElement) -@listableObjectComponent('OrgUnitSearchResult', ViewMode.DetailedListElement) -@listableObjectComponent('PersonSearchResult', ViewMode.DetailedListElement) -@listableObjectComponent('JournalSearchResult', ViewMode.DetailedListElement) -@listableObjectComponent('JournalIssueSearchResult', ViewMode.DetailedListElement) -@listableObjectComponent('JournalVolumeSearchResult', ViewMode.DetailedListElement) -@listableObjectComponent('ProjectSearchResult', ViewMode.DetailedListElement) +@listableObjectComponent(Item, ViewMode.DetailedListElement) export class ItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent { /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts index ad528b3877..f0ffe0b44f 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; @@ -11,7 +11,6 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; /** * This component renders pool task object for the mydspace result in the detail view. @@ -40,10 +39,6 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl */ public workflowitem: WorkflowItem; - constructor() { - super(); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts index b5b60c9035..f1e9fe698c 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts @@ -6,6 +6,9 @@ import { Metadata } from '../../../core/shared/metadata.utils'; import { SearchResult } from '../../../+search-page/search-result.model'; import { hasValue } from '../../empty.util'; +/** + * Component representing Search Results with ViewMode.DetailedElement + */ @Component({ selector: 'ds-search-result-detail-element', template: `` @@ -17,6 +20,9 @@ export class SearchResultDetailElementComponent, K ext */ dso: K; + /** + * Initialize instance variables + */ ngOnInit(): void { if (hasValue(this.object)) { this.dso = this.object.indexableObject; diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts index 6393e26dbb..830c842223 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts @@ -13,7 +13,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; /** - * This component renders workflowitem object for the mydspace result in the detail view. + * This component renders workflowitem object for the search result in the detail view. */ @Component({ selector: 'ds-workflow-item-search-result-detail-element', diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts index fc2c6a87cc..0f8e1a65cb 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts @@ -14,7 +14,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model'; /** - * This component renders workspaceitem object for the mydspace result in the detail view. + * This component renders workspace item object for the search result in the detail view. */ @Component({ selector: 'ds-workspace-item-search-result-detail-element', diff --git a/src/app/shared/object-detail/object-detail.component.ts b/src/app/shared/object-detail/object-detail.component.ts index 36963b2f5d..fb68316251 100644 --- a/src/app/shared/object-detail/object-detail.component.ts +++ b/src/app/shared/object-detail/object-detail.component.ts @@ -31,6 +31,9 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme animations: [fadeIn] }) export class ObjectDetailComponent { + /** + * The view mode of this component + */ viewMode = ViewMode.DetailedListElement; /** @@ -52,7 +55,15 @@ export class ObjectDetailComponent { * A boolean representing if to hide pagination when there is only a page */ @Input() hidePagerWhenSinglePage = true; + + /** + * The link type of the rendered listable elements + */ @Input() linkType: CollectionElementLinkType; + + /** + * The context of the rendered listable elements + */ @Input() context: Context; /** diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts index 1261cd6dfd..6f8bf5264e 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts @@ -5,6 +5,9 @@ import { AbstractListableElementComponent } from '../../object-collection/shared import { ViewMode } from '../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; +/** + * Component representing a grid element for collection + */ @Component({ selector: 'ds-collection-grid-element', styleUrls: ['./collection-grid-element.component.scss'], diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts index 67d4ac663c..05c84b683b 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts @@ -5,6 +5,9 @@ import { AbstractListableElementComponent } from '../../object-collection/shared import { ViewMode } from '../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; +/** + * Component representing a grid element for a community + */ @Component({ selector: 'ds-community-grid-element', styleUrls: ['./community-grid-element.component.scss'], diff --git a/src/app/shared/object-grid/object-grid.component.ts b/src/app/shared/object-grid/object-grid.component.ts index 6b61e6bfd8..2da4abe13b 100644 --- a/src/app/shared/object-grid/object-grid.component.ts +++ b/src/app/shared/object-grid/object-grid.component.ts @@ -34,20 +34,57 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme }) export class ObjectGridComponent implements OnInit { + /** + * The view mode of the this component + */ viewMode = ViewMode.GridElement; + /** + * The current pagination configuration + */ @Input() config: PaginationComponentOptions; + + /** + * The current sort configuration + */ @Input() sortConfig: SortOptions; + + /** + * The whether or not the gear is hidden + */ @Input() hideGear = false; + + /** + * Whether or not the pager is visible when there is only a single page of results + */ @Input() hidePagerWhenSinglePage = true; + + /** + * The link type of the listable elements + */ @Input() linkType: CollectionElementLinkType; + + /** + * The context of the listable elements + */ @Input() context: Context; + + /** + * Behavior subject to output the current listable objects + */ private _objects$: BehaviorSubject>>; + /** + * Setter to make sure the observable is turned into an observable + * @param objects The new objects to output + */ @Input() set objects(objects: RemoteData>) { this._objects$.next(objects); } + /** + * Getter to return the current objects + */ get objects() { return this._objects$.getValue(); } @@ -82,7 +119,10 @@ export class ObjectGridComponent implements OnInit { */ @Output() sortDirectionChange: EventEmitter = new EventEmitter(); - @Output() paginationChange: EventEmitter = new EventEmitter(); + /** + * An event fired when on of the pagination parameters changes + */ + @Output() paginationChange: EventEmitter = new EventEmitter(); /** * An event fired when the sort field is changed. @@ -96,6 +136,9 @@ export class ObjectGridComponent implements OnInit { this._objects$ = new BehaviorSubject(undefined); } + /** + * Initialize the instance variables + */ ngOnInit(): void { const nbColumns$ = this.hostWindow.widthCategory.pipe( map((widthCat: WidthCategory) => { @@ -139,22 +182,40 @@ export class ObjectGridComponent implements OnInit { })); } + /** + * Emits the current page when it changes + * @param event The new page + */ onPageChange(event) { this.pageChange.emit(event); } - + /** + * Emits the current page size when it changes + * @param event The new page size + */ onPageSizeChange(event) { this.pageSizeChange.emit(event); } - + /** + * Emits the current sort direction when it changes + * @param event The new sort direction + */ onSortDirectionChange(event) { this.sortDirectionChange.emit(event); } + /** + * Emits the current sort field when it changes + * @param event The new sort field + */ onSortFieldChange(event) { this.sortFieldChange.emit(event); } + /** + * Emits the current pagination when it changes + * @param event The new pagination + */ onPaginationChange(event) { this.paginationChange.emit(event); } diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts index 1d0f47b70b..a834327736 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts @@ -11,6 +11,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista styleUrls: ['../search-result-grid-element.component.scss', 'collection-search-result-grid-element.component.scss'], templateUrl: 'collection-search-result-grid-element.component.html' }) - +/** + * Component representing a grid element for a collection search result + */ @listableObjectComponent(CollectionSearchResult, ViewMode.GridElement) export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent {} diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts index 806e6a44e3..e726c3e803 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts @@ -10,8 +10,9 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista styleUrls: ['../search-result-grid-element.component.scss', 'community-search-result-grid-element.component.scss'], templateUrl: 'community-search-result-grid-element.component.html' }) - +/** + * Component representing a grid element for a community search result + */ @listableObjectComponent(CommunitySearchResult, ViewMode.GridElement) export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent { - } diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts index bda211532a..76618f18f2 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts @@ -14,7 +14,7 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear animations: [focusShadow] }) /** - * The component for displaying a grid element for an item of the type Publication + * The component for displaying a grid element for an item search result of the type Publication */ export class PublicationSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts index a136636cda..75345338e7 100644 --- a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts @@ -14,7 +14,14 @@ import { hasValue } from '../../empty.util'; }) export class SearchResultGridElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent implements OnInit { + /** + * The DSpaceObject of the search result + */ dso: K; + + /** + * Whether or not the grid element is currently collapsed + */ isCollapsed$: Observable; public constructor(protected truncatableService: TruncatableService) { @@ -24,6 +31,9 @@ export class SearchResultGridElementComponent, K exten } } + /** + * Retrieve the dso from the search result + */ ngOnInit(): void { if (hasValue(this.object)) { this.dso = this.object.indexableObject; diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts index 685a990409..48bd6697a0 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.ts @@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../object-collection/shared/listable styleUrls: ['./collection-list-element.component.scss'], templateUrl: './collection-list-element.component.html' }) - +/** + * Component representing list element for a collection + */ @listableObjectComponent(Collection, ViewMode.ListElement) export class CollectionListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/community-list-element/community-list-element.component.ts b/src/app/shared/object-list/community-list-element/community-list-element.component.ts index 4581c2c0da..aa583378de 100644 --- a/src/app/shared/object-list/community-list-element/community-list-element.component.ts +++ b/src/app/shared/object-list/community-list-element/community-list-element.component.ts @@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../object-collection/shared/listable styleUrls: ['./community-list-element.component.scss'], templateUrl: './community-list-element.component.html' }) - +/** + * Component representing a list element for a community + */ @listableObjectComponent(Community, ViewMode.ListElement) export class CommunityListElementComponent extends AbstractListableElementComponent {} diff --git a/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts b/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts index a4e12959f4..5518ede202 100644 --- a/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts +++ b/src/app/shared/object-list/item-type-badge/item-type-badge.component.ts @@ -7,6 +7,12 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; selector: 'ds-item-type-badge', templateUrl: './item-type-badge.component.html' }) +/** + * Component rendering the type of an item as a badge + */ export class ItemTypeBadgeComponent { + /** + * The component used to retrieve the type from + */ @Input() object: DSpaceObject; } diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts index 4f27bf05dd..3be16bcb5e 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts @@ -17,7 +17,7 @@ import { metadataRepresentationComponent } from '../../../metadata-representatio export class ItemMetadataListElementComponent extends MetadataRepresentationListElementComponent { /** * The view-mode we're currently on - * @type {ElementViewMode} + * @type {ViewMode} */ viewMode = ViewMode.ListElement; } diff --git a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts index 7b8e0d7f9c..2e14485fbb 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts @@ -9,5 +9,8 @@ import { MetadataRepresentation } from '../../../core/shared/metadata-representa * An abstract class for displaying a single MetadataRepresentation */ export class MetadataRepresentationListElementComponent { + /** + * The metadata representation of this component + */ metadataRepresentation: MetadataRepresentation; } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts index aba6482bd1..6c1250773f 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts @@ -13,10 +13,9 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; -import { Item } from '../../../../core/shared/item.model'; /** - * This component renders claimed task object for the mydspace result in the list view. + * This component renders claimed task object for the search result in the list view. */ @Component({ selector: 'ds-claimed-search-result-list-element', diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts index 8324e748f1..0395c8c84b 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts @@ -22,7 +22,7 @@ export class ItemListPreviewComponent { @Input() item: Item; /** - * The mydspace result object + * The search result object */ @Input() object: SearchResult; diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index 72ee0ba235..db0216908d 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -9,7 +9,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search- import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** - * This component renders item object for the mydspace result in the list view. + * This component renders item object for the search result in the list view for submission. */ @Component({ selector: 'ds-item-search-result-list-element-submission', diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts index 5597a2126d..93941f8a81 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; @@ -13,10 +13,9 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { Item } from '../../../../core/shared/item.model'; /** - * This component renders pool task object for the mydspace result in the list view. + * This component renders pool task object for the search result in the list view. */ @Component({ selector: 'ds-pool-search-result-list-element', @@ -42,6 +41,9 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen */ public workflowitem: WorkflowItem; + /** + * The index of this list element + */ public index: number; constructor(protected truncatableService: TruncatableService) { diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts index cb985b9906..8182342c3a 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts @@ -14,7 +14,7 @@ import { WorkflowItemSearchResult } from '../../../object-collection/shared/work import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** - * This component renders workflowitem object for the mydspace result in the list view. + * This component renders workflowitem object for the search result in the list view. */ @Component({ selector: 'ds-workflow-item-my-dspace-result-list-element', diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts index ed2770f852..2e9363decc 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts @@ -14,7 +14,7 @@ import { WorkspaceItemSearchResult } from '../../../object-collection/shared/wor import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** - * This component renders workspaceitem object for the mydspace result in the list view. + * This component renders workspaceitem object for the search result in the list view. */ @Component({ selector: 'ds-workspace-item-search-result-list-element', diff --git a/src/app/shared/object-list/object-list.component.ts b/src/app/shared/object-list/object-list.component.ts index 9704dee70e..e1dabce943 100644 --- a/src/app/shared/object-list/object-list.component.ts +++ b/src/app/shared/object-list/object-list.component.ts @@ -25,19 +25,63 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme animations: [fadeIn] }) export class ObjectListComponent { + /** + * The view mode of the this component + */ viewMode = ViewMode.ListElement; + + /** + * The current pagination configuration + */ @Input() config: PaginationComponentOptions; + + /** + * The current sort configuration + */ @Input() sortConfig: SortOptions; + + /** + * Whether or not the list elements have a border + */ @Input() hasBorder = false; + + /** + * The whether or not the gear is hidden + */ @Input() hideGear = false; + + /** + * Whether or not the pager is visible when there is only a single page of results + */ @Input() hidePagerWhenSinglePage = true; + + /** + * The link type of the listable elements + */ @Input() linkType: CollectionElementLinkType; + + /** + * The context of the listable elements + */ @Input() context: Context; + + /** + * The current listable objects + */ private _objects: RemoteData>; + + + /** + * Setter for the objects + * @param objects The new objects + */ @Input() set objects(objects: RemoteData>) { this._objects = objects; } + /** + * Getter to return the current objects + */ get objects() { return this._objects; } @@ -72,6 +116,9 @@ export class ObjectListComponent { */ @Output() sortDirectionChange: EventEmitter = new EventEmitter(); + /** + * An event fired when on of the pagination parameters changes + */ @Output() paginationChange: EventEmitter = new EventEmitter(); /** @@ -79,24 +126,42 @@ export class ObjectListComponent { * Event's payload equals to the newly selected sort field. */ @Output() sortFieldChange: EventEmitter = new EventEmitter(); - data: any = {}; + /** + * Emits the current page when it changes + * @param event The new page + */ onPageChange(event) { this.pageChange.emit(event); } + /** + * Emits the current page size when it changes + * @param event The new page size + */ onPageSizeChange(event) { this.pageSizeChange.emit(event); } - + /** + * Emits the current sort direction when it changes + * @param event The new sort direction + */ onSortDirectionChange(event) { this.sortDirectionChange.emit(event); } + /** + * Emits the current sort field when it changes + * @param event The new sort field + */ onSortFieldChange(event) { this.sortFieldChange.emit(event); } + /** + * Emits the current pagination when it changes + * @param event The new pagination + */ onPaginationChange(event) { this.paginationChange.emit(event); } diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts index b42186e367..9e09068ddf 100644 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component.ts @@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista styleUrls: ['../search-result-list-element.component.scss', 'collection-search-result-list-element.component.scss'], templateUrl: 'collection-search-result-list-element.component.html' }) - +/** + * Component representing a collection search result in list view + */ @listableObjectComponent(CollectionSearchResult, ViewMode.ListElement) export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent {} diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts index a1da9a04ff..b2fd695b39 100644 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component.ts @@ -10,7 +10,9 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista styleUrls: ['../search-result-list-element.component.scss', 'community-search-result-list-element.component.scss'], templateUrl: 'community-search-result-list-element.component.html' }) - +/** + * Component representing a community search result in list view + */ @listableObjectComponent(CommunitySearchResult, ViewMode.ListElement) export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent { diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts index 7b376ead8e..3e0db60b4c 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts @@ -13,7 +13,7 @@ import { Item } from '../../../../../../core/shared/item.model'; templateUrl: './publication-search-result-list-element.component.html' }) /** - * The component for displaying a list element for an item of the type Publication + * The component for displaying a list element for an item search result of the type Publication */ export class PublicationSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts index 3d4bf9224b..93fc00bc87 100644 --- a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts @@ -7,7 +7,6 @@ import { hasValue } from '../../empty.util'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { TruncatableService } from '../../truncatable/truncatable.service'; import { Metadata } from '../../../core/shared/metadata.utils'; -import { MetadataMap } from '../../../core/shared/metadata.models'; @Component({ selector: 'ds-search-result-list-element', @@ -15,13 +14,18 @@ import { MetadataMap } from '../../../core/shared/metadata.models'; }) export class SearchResultListElementComponent, K extends DSpaceObject> extends AbstractListableElementComponent implements OnInit { + /** + * The DSpaceObject of the search result + */ dso: K; - metadata: MetadataMap; public constructor(protected truncatableService: TruncatableService) { super(); } + /** + * Retrieve the dso from the search result + */ ngOnInit(): void { if (hasValue(this.object)) { this.dso = this.object.indexableObject; @@ -48,6 +52,9 @@ export class SearchResultListElementComponent, K exten return Metadata.firstValue([this.object.hitHighlights, this.dso.metadata], keyOrKeys); } + /** + * Emits if the list element is currently collapsed or not + */ isCollapsed(): Observable { return this.truncatableService.isCollapsed(this.dso.id); } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 57bf6ae8bf..98fc375630 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -139,6 +139,8 @@ import { ListableObjectComponentLoaderComponent } from './object-collection/shar import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component'; import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component'; import { ListableObjectDirective } from './object-collection/shared/listable-object/listable-object.directive'; +import { CommunitySearchResultGridElementComponent } from './object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component'; +import { CollectionSearchResultGridElementComponent } from './object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -253,7 +255,13 @@ const COMPONENTS = [ EditItemSelectorComponent, CommunitySearchResultListElementComponent, CollectionSearchResultListElementComponent, + CommunitySearchResultGridElementComponent, + CollectionSearchResultGridElementComponent, ListableObjectComponentLoaderComponent, + CollectionListElementComponent, + CommunityListElementComponent, + CollectionGridElementComponent, + CommunityGridElementComponent, BrowseByComponent, ItemTypeBadgeComponent, MetadataRepresentationLoaderComponent @@ -268,6 +276,8 @@ const ENTRY_COMPONENTS = [ CollectionSearchResultListElementComponent, CollectionGridElementComponent, CommunityGridElementComponent, + CommunitySearchResultGridElementComponent, + CollectionSearchResultGridElementComponent, SearchResultGridElementComponent, PublicationListElementComponent, PublicationGridElementComponent, diff --git a/src/app/shared/view-mode-switch/view-mode-switch.component.ts b/src/app/shared/view-mode-switch/view-mode-switch.component.ts index cd0d8ce47d..d406573646 100644 --- a/src/app/shared/view-mode-switch/view-mode-switch.component.ts +++ b/src/app/shared/view-mode-switch/view-mode-switch.component.ts @@ -22,13 +22,23 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy { */ @Input() inPlaceSearch; + /** + * The current view mode + */ currentMode: ViewMode = ViewMode.ListElement; + + /** + * All available view modes + */ viewModeEnum = ViewMode; private sub: Subscription; constructor(private searchService: SearchService) { } + /** + * Initialize the instance variables + */ ngOnInit(): void { if (isEmpty(this.viewModeList)) { this.viewModeList = [ViewMode.ListElement, ViewMode.GridElement]; @@ -39,6 +49,10 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy { }); } + /** + * Switch view modes + * @param viewMode The new view mode + */ switchViewTo(viewMode: ViewMode) { this.searchService.setViewMode(viewMode, this.getSearchLinkParts()); } @@ -49,6 +63,10 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy { } } + /** + * Whether or not to show a certain view mode + * @param viewMode The view mode to check for + */ isToShow(viewMode: ViewMode) { return this.viewModeList && this.viewModeList.includes(viewMode); } diff --git a/src/backend/api.ts b/src/backend/api.ts index da83b1ba12..e1943b5d30 100644 --- a/src/backend/api.ts +++ b/src/backend/api.ts @@ -117,7 +117,7 @@ export function createMockApi() { const id = req.params.item_id; try { req.item_id = id; - req.object = ITEMS.items.find((item) => { + req.item = ITEMS.items.find((item) => { return item.id === id; }); next(); @@ -127,7 +127,7 @@ export function createMockApi() { }); router.route('/items/:item_id').get((req, res) => { - res.json(toHALResponse(req, req.object)); + res.json(toHALResponse(req, req.item)); }); router.route('/bundles').get((req, res) => { From ac851f3812f1557dd5ec6fbf912836dbb114dbaf Mon Sep 17 00:00:00 2001 From: lotte Date: Wed, 16 Oct 2019 14:48:17 +0200 Subject: [PATCH 12/17] renaming fixes, new tests --- .../org-unit-grid-element.component.html | 1 + .../org-unit-grid-element.component.scss} | 0 .../org-unit-grid-element.component.spec.ts} | 16 ++--- .../org-unit-grid-element.component.ts} | 8 +-- .../orgunit-grid-element.component.html | 1 - ...search-result-grid-element.component.html} | 0 ...search-result-grid-element.component.scss} | 0 ...rch-result-grid-element.component.spec.ts} | 4 +- ...t-search-result-grid-element.component.ts} | 8 +-- .../org-unit-list-element.component.html | 1 + .../org-unit-list-element.component.scss} | 0 .../org-unit-list-element.component.spec.ts} | 10 +-- .../org-unit-list-element.component.ts} | 6 +- .../orgunit-list-element.component.html | 1 - ...search-result-list-element.component.html} | 0 ...search-result-list-element.component.scss} | 0 ...rch-result-list-element.component.spec.ts} | 24 +++---- ...t-search-result-list-element.component.ts} | 8 +-- .../org-unit.component.html} | 0 .../org-unit.component.scss} | 0 .../org-unit.component.spec.ts} | 4 +- .../org-unit.component.ts} | 8 +-- ...item-metadata-list-element.component.html} | 0 ...em-metadata-list-element.component.spec.ts | 47 ++++++++++++++ ...t-item-metadata-list-element.component.ts} | 6 +- ...item-metadata-list-element.component.html} | 0 ...em-metadata-list-element.component.spec.ts | 48 ++++++++++++++ ...n-item-metadata-list-element.component.ts} | 11 ++-- .../research-entities.module.ts | 26 ++++---- ...ta-representation-loader.component.spec.ts | 63 +++++++++++++++++++ .../metadata-representation.decorator.ts | 1 - .../claimed-task-actions.component.ts | 2 +- .../workflowitem-actions.component.ts | 2 +- .../workspaceitem-actions.component.ts | 3 +- ...-object-component-loader.component.spec.ts | 58 +++++++++++++++++ ...s => workflow-item-search-result.model.ts} | 0 ... => workspace-item-search-result.model.ts} | 0 ...-search-result-detail-element.component.ts | 6 +- ...-search-result-detail-element.component.ts | 3 +- ...ch-result-detail-element.component.spec.ts | 2 +- ...-search-result-detail-element.component.ts | 3 +- ...ch-result-detail-element.component.spec.ts | 2 +- ...-search-result-detail-element.component.ts | 3 +- .../item-metadata-list-element.component.html | 3 +- ...em-metadata-list-element.component.spec.ts | 6 +- ...ed-search-result-list-element.component.ts | 2 +- ...esult-list-element-submission.component.ts | 2 +- ...-dspace-result-list-element.component.scss | 1 - ...ol-search-result-list-element.component.ts | 2 +- ...arch-result-list-element.component.spec.ts | 2 +- ...em-search-result-list-element.component.ts | 4 +- ...arch-result-list-element.component.spec.ts | 2 +- ...em-search-result-list-element.component.ts | 4 +- .../object-list/object-list.component.ts | 1 - src/app/shared/testing/utils.ts | 11 ++++ 55 files changed, 324 insertions(+), 102 deletions(-) create mode 100644 src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.html rename src/app/entity-groups/research-entities/item-grid-elements/{orgunit/orgunit-grid-element.component.scss => org-unit/org-unit-grid-element.component.scss} (100%) rename src/app/entity-groups/research-entities/item-grid-elements/{orgunit/orgunit-grid-element.component.spec.ts => org-unit/org-unit-grid-element.component.spec.ts} (79%) rename src/app/entity-groups/research-entities/item-grid-elements/{orgunit/orgunit-grid-element.component.ts => org-unit/org-unit-grid-element.component.ts} (75%) delete mode 100644 src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html rename src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/{orgunit/orgunit-search-result-grid-element.component.html => org-unit/org-unit-search-result-grid-element.component.html} (100%) rename src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/{orgunit/orgunit-search-result-grid-element.component.scss => org-unit/org-unit-search-result-grid-element.component.scss} (100%) rename src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/{orgunit/orgunit-search-result-grid-element.component.spec.ts => org-unit/org-unit-search-result-grid-element.component.spec.ts} (88%) rename src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/{orgunit/orgunit-search-result-grid-element.component.ts => org-unit/org-unit-search-result-grid-element.component.ts} (77%) create mode 100644 src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.html rename src/app/entity-groups/research-entities/item-list-elements/{orgunit/orgunit-list-element.component.scss => org-unit/org-unit-list-element.component.scss} (100%) rename src/app/entity-groups/research-entities/item-list-elements/{orgunit/orgunit-list-element.component.spec.ts => org-unit/org-unit-list-element.component.spec.ts} (82%) rename src/app/entity-groups/research-entities/item-list-elements/{orgunit/orgunit-list-element.component.ts => org-unit/org-unit-list-element.component.ts} (82%) delete mode 100644 src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html rename src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/{orgunit/orgunit-search-result-list-element.component.html => org-unit/org-unit-search-result-list-element.component.html} (100%) rename src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/{orgunit/orgunit-search-result-list-element.component.scss => org-unit/org-unit-search-result-list-element.component.scss} (100%) rename src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/{orgunit/orgunit-search-result-list-element.component.spec.ts => org-unit/org-unit-search-result-list-element.component.spec.ts} (72%) rename src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/{orgunit/orgunit-search-result-list-element.component.ts => org-unit/org-unit-search-result-list-element.component.ts} (76%) rename src/app/entity-groups/research-entities/item-pages/{orgunit/orgunit.component.html => org-unit/org-unit.component.html} (100%) rename src/app/entity-groups/research-entities/item-pages/{orgunit/orgunit.component.scss => org-unit/org-unit.component.scss} (100%) rename src/app/entity-groups/research-entities/item-pages/{orgunit/orgunit.component.spec.ts => org-unit/org-unit.component.spec.ts} (94%) rename src/app/entity-groups/research-entities/item-pages/{orgunit/orgunit.component.ts => org-unit/org-unit.component.ts} (90%) rename src/app/entity-groups/research-entities/{item-list-elements/orgunit/orgunit-item-page-list-element.component.html => metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html} (100%) create mode 100644 src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts rename src/app/entity-groups/research-entities/{item-list-elements/orgunit/orgunit-item-page-list-element.component.ts => metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts} (78%) rename src/app/entity-groups/research-entities/{item-list-elements/person/person-item-page-list-element.component.html => metadata-representations/person/person-item-metadata-list-element.component.html} (100%) create mode 100644 src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts rename src/app/entity-groups/research-entities/{item-list-elements/person/person-item-page-list-element.component.ts => metadata-representations/person/person-item-metadata-list-element.component.ts} (54%) create mode 100644 src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts create mode 100644 src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts rename src/app/shared/object-collection/shared/{workflowitem-search-result.model.ts => workflow-item-search-result.model.ts} (100%) rename src/app/shared/object-collection/shared/{workspaceitem-search-result.model.ts => workspace-item-search-result.model.ts} (100%) delete mode 100644 src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.scss diff --git a/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.html new file mode 100644 index 0000000000..e4522398a6 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.html @@ -0,0 +1 @@ + diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.scss similarity index 100% rename from src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.scss rename to src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.scss diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts similarity index 79% rename from src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts rename to src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts index 5cbe9f6d79..953cc78535 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; -import { OrgunitGridElementComponent } from './orgunit-grid-element.component'; +import { OrgUnitGridElementComponent } from './org-unit-grid-element.component'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; @@ -41,7 +41,7 @@ const mockItem = Object.assign(new Item(), { } }); -describe('OrgunitGridElementComponent', () => { +describe('OrgUnitGridElementComponent', () => { let comp; let fixture; @@ -52,18 +52,18 @@ describe('OrgunitGridElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], - declarations: [OrgunitGridElementComponent, TruncatePipe], + declarations: [OrgUnitGridElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: truncatableServiceStub }, ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(OrgunitGridElementComponent, { + }).overrideComponent(OrgUnitGridElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(OrgunitGridElementComponent); + fixture = TestBed.createComponent(OrgUnitGridElementComponent); comp = fixture.componentInstance; })); @@ -73,9 +73,9 @@ describe('OrgunitGridElementComponent', () => { fixture.detectChanges(); }); - it(`should contain a OrgunitGridElementComponent`, () => { - const orgunitGridElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-grid-element`)); - expect(orgunitGridElement).not.toBeNull(); + it(`should contain a OrgUnitGridElementComponent`, () => { + const orgUnitGridElement = fixture.debugElement.query(By.css(`ds-org-unit-search-result-grid-element`)); + expect(orgUnitGridElement).not.toBeNull(); }); }); }); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.ts similarity index 75% rename from src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts rename to src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.ts index 1bdcbdc370..05a7f6c8c5 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.ts @@ -6,12 +6,12 @@ import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.GridElement) @Component({ - selector: 'ds-orgunit-grid-element', - styleUrls: ['./orgunit-grid-element.component.scss'], - templateUrl: './orgunit-grid-element.component.html', + selector: 'ds-org-unit-grid-element', + styleUrls: ['./org-unit-grid-element.component.scss'], + templateUrl: './org-unit-grid-element.component.html', }) /** * The component for displaying a grid element for an item of the type Organisation Unit */ -export class OrgunitGridElementComponent extends AbstractListableElementComponent { +export class OrgUnitGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html deleted file mode 100644 index f42ffb87e9..0000000000 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html rename to src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.html diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.scss similarity index 100% rename from src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss rename to src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.scss diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts similarity index 88% rename from src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts rename to src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts index bb4cb93a70..36324ad627 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts @@ -3,7 +3,7 @@ import { Item } from '../../../../../core/shared/item.model'; import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; -import { OrgunitSearchResultGridElementComponent } from './orgunit-search-result-grid-element.component'; +import { OrgUnitSearchResultGridElementComponent } from './org-unit-search-result-grid-element.component'; import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); @@ -52,4 +52,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('OrgunitSearchResultGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); +describe('OrgUnitSearchResultGridElementComponent', getEntityGridElementTestComponent(OrgUnitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.ts similarity index 77% rename from src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts rename to src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.ts index 71a435762a..64b4be4a11 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.ts @@ -8,13 +8,13 @@ import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('OrgUnitSearchResult', ViewMode.GridElement) @Component({ - selector: 'ds-orgunit-search-result-grid-element', - styleUrls: ['./orgunit-search-result-grid-element.component.scss'], - templateUrl: './orgunit-search-result-grid-element.component.html', + selector: 'ds-org-unit-search-result-grid-element', + styleUrls: ['./org-unit-search-result-grid-element.component.scss'], + templateUrl: './org-unit-search-result-grid-element.component.html', animations: [focusShadow] }) /** * The component for displaying a grid element for an item search result of the type Organisation Unit */ -export class OrgunitSearchResultGridElementComponent extends SearchResultGridElementComponent { +export class OrgUnitSearchResultGridElementComponent extends SearchResultGridElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.html new file mode 100644 index 0000000000..03ef45c7a4 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.scss similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.scss rename to src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.scss diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.spec.ts similarity index 82% rename from src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts rename to src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.spec.ts index 3009197e10..43ed9b0ec5 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.spec.ts @@ -1,7 +1,7 @@ import { async, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { OrgUnitListElementComponent } from './orgunit-list-element.component'; +import { OrgUnitListElementComponent } from './org-unit-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; @@ -25,7 +25,7 @@ const mockItem: Item = Object.assign(new Item(), { } }); -describe('OrgunitListElementComponent', () => { +describe('OrgUnitListElementComponent', () => { let comp; let fixture; @@ -50,15 +50,15 @@ describe('OrgunitListElementComponent', () => { comp = fixture.componentInstance; })); - describe(`when the orgunit is rendered`, () => { + describe(`when the org unit is rendered`, () => { beforeEach(() => { comp.object = mockItem; fixture.detectChanges(); }); it(`should contain a OrgUnitListElementComponent`, () => { - const orgunitListElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-list-element`)); - expect(orgunitListElement).not.toBeNull(); + const orgUnitListElement = fixture.debugElement.query(By.css(`ds-org-unit-search-result-list-element`)); + expect(orgUnitListElement).not.toBeNull(); }); }); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.ts similarity index 82% rename from src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts rename to src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.ts index 7e25cf614d..32254595aa 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/org-unit/org-unit-list-element.component.ts @@ -6,9 +6,9 @@ import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement) @Component({ - selector: 'ds-orgunit-list-element', - styleUrls: ['./orgunit-list-element.component.scss'], - templateUrl: './orgunit-list-element.component.html' + selector: 'ds-org-unit-list-element', + styleUrls: ['./org-unit-list-element.component.scss'], + templateUrl: './org-unit-list-element.component.html' }) /** * The component for displaying a list element for an item of the type Organisation Unit diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html deleted file mode 100644 index ad0eec0313..0000000000 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html rename to src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.html diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.scss similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss rename to src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.scss diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts similarity index 72% rename from src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts rename to src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts index 6093b5c680..0597c0032d 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts @@ -2,14 +2,14 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { of as observableOf } from 'rxjs'; -import { OrgunitSearchResultListElementComponent } from './orgunit-search-result-list-element.component'; +import { OrgUnitSearchResultListElementComponent } from './org-unit-search-result-list-element.component'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe'; import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; -let orgUnitListElementComponent: OrgunitSearchResultListElementComponent; -let fixture: ComponentFixture; +let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent; +let fixture: ComponentFixture; const mockItemWithMetadata: ItemSearchResult = Object.assign( new ItemSearchResult(), @@ -51,44 +51,44 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign( describe('OrgUnitSearchResultListElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe], + declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} } ], schemas: [ NO_ERRORS_SCHEMA ] - }).overrideComponent(OrgunitSearchResultListElementComponent, { + }).overrideComponent(OrgUnitSearchResultListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(OrgunitSearchResultListElementComponent); + fixture = TestBed.createComponent(OrgUnitSearchResultListElementComponent); orgUnitListElementComponent = fixture.componentInstance; })); - describe('When the item has an orgunit description', () => { + describe('When the item has an org unit description', () => { beforeEach(() => { orgUnitListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); it('should show the description span', () => { - const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); - expect(orgunitDescriptionField).not.toBeNull(); + const orgUnitDescriptionField = fixture.debugElement.query(By.css('span.item-list-org-unit-description')); + expect(orgUnitDescriptionField).not.toBeNull(); }); }); - describe('When the item has no orgunit description', () => { + describe('When the item has no org unit description', () => { beforeEach(() => { orgUnitListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); it('should not show the description span', () => { - const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); - expect(orgunitDescriptionField).toBeNull(); + const orgUnitDescriptionField = fixture.debugElement.query(By.css('span.item-list-org-unit-description')); + expect(orgUnitDescriptionField).toBeNull(); }); }); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.ts similarity index 76% rename from src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts rename to src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.ts index 5e3cdedd60..5b50e5a78c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.ts @@ -7,12 +7,12 @@ import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('OrgUnitSearchResult', ViewMode.ListElement) @Component({ - selector: 'ds-orgunit-search-result-list-element', - styleUrls: ['./orgunit-search-result-list-element.component.scss'], - templateUrl: './orgunit-search-result-list-element.component.html' + selector: 'ds-org-unit-search-result-list-element', + styleUrls: ['./org-unit-search-result-list-element.component.scss'], + templateUrl: './org-unit-search-result-list-element.component.html' }) /** * The component for displaying a list element for an item search result of the type Organisation Unit */ -export class OrgunitSearchResultListElementComponent extends SearchResultListElementComponent { +export class OrgUnitSearchResultListElementComponent extends SearchResultListElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html rename to src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.scss similarity index 100% rename from src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss rename to src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.scss diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.spec.ts b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts similarity index 94% rename from src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.spec.ts rename to src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts index a49105b2e3..28b014ddba 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts @@ -2,7 +2,7 @@ import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { OrgunitComponent } from './orgunit.component'; +import { OrgUnitComponent } from './org-unit.component'; import { of as observableOf } from 'rxjs'; import { createRelationshipsObservable, @@ -47,4 +47,4 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('OrgUnitComponent', getItemPageFieldsTest(mockItem, OrgunitComponent)); +describe('OrgUnitComponent', getItemPageFieldsTest(mockItem, OrgUnitComponent)); diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts similarity index 90% rename from src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts rename to src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts index c63a1c8a53..2e5ea3fb9b 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts @@ -9,14 +9,14 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh @listableObjectComponent('OrgUnit', ViewMode.StandalonePage) @Component({ - selector: 'ds-orgunit', - styleUrls: ['./orgunit.component.scss'], - templateUrl: './orgunit.component.html' + selector: 'ds-org-unit', + styleUrls: ['./org-unit.component.scss'], + templateUrl: './org-unit.component.html' }) /** * The component for displaying metadata and relations of an item of the type Organisation Unit */ -export class OrgunitComponent extends ItemComponent implements OnInit { +export class OrgUnitComponent extends ItemComponent implements OnInit { /** * The people related to this organisation unit */ diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html rename to src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts new file mode 100644 index 0000000000..8616e4fa01 --- /dev/null +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts @@ -0,0 +1,47 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { OrgUnitItemMetadataListElementComponent } from './org-unit-item-metadata-list-element.component'; +import { Item } from '../../../../core/shared/item.model'; +import { TooltipModule } from 'ngx-bootstrap'; + +const description = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'; +const organisation = 'Anonymous'; +const mockItem = Object.assign(new Item(), { metadata: { 'dc.description': [{ value: description }], 'organization.legalName': [{ value: organisation }] } }); +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); + +describe('OrgUnitItemMetadataListElementComponent', () => { + let comp: OrgUnitItemMetadataListElementComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TooltipModule.forRoot()], + declarations: [OrgUnitItemMetadataListElementComponent], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(OrgUnitItemMetadataListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgUnitItemMetadataListElementComponent); + comp = fixture.componentInstance; + comp.metadataRepresentation = mockItemMetadataRepresentation; + fixture.detectChanges(); + })); + + it('should show the name of the organisation as a link', () => { + const linkText = fixture.debugElement.query(By.css('a')).nativeElement.textContent; + expect(linkText).toBe(organisation); + }); + + it('should show the description on hover over the link in a tooltip', () => { + const link = fixture.debugElement.query(By.css('a')); + link.triggerEventHandler('mouseover', null); + fixture.detectChanges(); + const tooltip = fixture.debugElement.query(By.css('.item-list-job-title')).nativeElement.textContent; + expect(tooltip).toBe(description); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts similarity index 78% rename from src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts rename to src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts index 7121670b38..e0bb542241 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts @@ -5,12 +5,12 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep @metadataRepresentationComponent('OrgUnit', MetadataRepresentationType.Item) @Component({ - selector: 'ds-orgunit-item-page-list-element', - templateUrl: './orgunit-item-page-list-element.component.html' + selector: 'ds-org-unit-item-metadata-list-element', + templateUrl: './org-unit-item-metadata-list-element.component.html' }) /** * The component for displaying an item of the type OrgUnit as a metadata field */ -export class OrgunitItemPageListElementComponent { +export class OrgUnitItemMetadataListElementComponent { metadataRepresentation: ItemMetadataRepresentation; } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html similarity index 100% rename from src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html rename to src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts new file mode 100644 index 0000000000..0d4786f37e --- /dev/null +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts @@ -0,0 +1,48 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { Item } from '../../../../core/shared/item.model'; +import { PersonItemMetadataListElementComponent } from './person-item-metadata-list-element.component'; +import { TooltipModule } from 'ngx-bootstrap'; + +const jobTitle ='Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'; +const firstName = 'Joe'; +const lastName = 'Anonymous'; +const mockItem = Object.assign(new Item(), { metadata: { 'person.jobTitle': [{ value: jobTitle }], 'person.givenName': [{ value: firstName }], 'person.familyName': [{ value: lastName }] } }); +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); + +describe('PersonItemMetadataListElementComponent', () => { + let comp: PersonItemMetadataListElementComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TooltipModule.forRoot()], + declarations: [PersonItemMetadataListElementComponent], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PersonItemMetadataListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonItemMetadataListElementComponent); + comp = fixture.componentInstance; + comp.metadataRepresentation = mockItemMetadataRepresentation; + fixture.detectChanges(); + })); + + it('should show the person\'s name as a link', () => { + const linkText = fixture.debugElement.query(By.css('a')).nativeElement.textContent; + expect(linkText).toBe(lastName + ', ' + firstName); + }); + + it('should show the description on hover over the link in a tooltip', () => { + const link = fixture.debugElement.query(By.css('a')); + link.triggerEventHandler('mouseover', null); + fixture.detectChanges(); + const tooltip = fixture.debugElement.query(By.css('.item-list-job-title')).nativeElement.textContent; + expect(tooltip).toBe(jobTitle); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts similarity index 54% rename from src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts rename to src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts index d7666237ad..e39eb05948 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts @@ -1,19 +1,16 @@ import { Component } from '@angular/core'; -import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { Item } from '../../../../core/shared/item.model'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { MetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component'; import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; @metadataRepresentationComponent('Person', MetadataRepresentationType.Item) @Component({ - selector: 'ds-person-item-page-list-element', - templateUrl: './person-item-page-list-element.component.html' + selector: 'ds-person-item-metadata-list-element', + templateUrl: './person-item-metadata-list-element.component.html' }) /** * The component for displaying an item of the type Person as a metadata field -*/ -export class PersonItemPageListElementComponent { + */ +export class PersonItemMetadataListElementComponent { metadataRepresentation: ItemMetadataRepresentation; } diff --git a/src/app/entity-groups/research-entities/research-entities.module.ts b/src/app/entity-groups/research-entities/research-entities.module.ts index 2d4d95dfbf..8829318f34 100644 --- a/src/app/entity-groups/research-entities/research-entities.module.ts +++ b/src/app/entity-groups/research-entities/research-entities.module.ts @@ -2,42 +2,42 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SharedModule } from '../../shared/shared.module'; import { ItemPageModule } from '../../+item-page/item-page.module'; -import { OrgunitComponent } from './item-pages/orgunit/orgunit.component'; +import { OrgUnitComponent } from './item-pages/org-unit/org-unit.component'; import { PersonComponent } from './item-pages/person/person.component'; import { ProjectComponent } from './item-pages/project/project.component'; -import { OrgUnitListElementComponent } from './item-list-elements/orgunit/orgunit-list-element.component'; -import { OrgunitItemPageListElementComponent } from './item-list-elements/orgunit/orgunit-item-page-list-element.component'; -import { PersonItemPageListElementComponent } from './item-list-elements/person/person-item-page-list-element.component'; +import { OrgUnitListElementComponent } from './item-list-elements/org-unit/org-unit-list-element.component'; import { PersonListElementComponent } from './item-list-elements/person/person-list-element.component'; import { ProjectListElementComponent } from './item-list-elements/project/project-list-element.component'; import { TooltipModule } from 'ngx-bootstrap'; import { PersonGridElementComponent } from './item-grid-elements/person/person-grid-element.component'; -import { OrgunitGridElementComponent } from './item-grid-elements/orgunit/orgunit-grid-element.component'; +import { OrgUnitGridElementComponent } from './item-grid-elements/org-unit/org-unit-grid-element.component'; import { ProjectGridElementComponent } from './item-grid-elements/project/project-grid-element.component'; -import { OrgunitSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component'; +import { OrgUnitSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component'; import { PersonSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/person/person-search-result-list-element.component'; import { ProjectSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/project/project-search-result-list-element.component'; import { PersonSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component'; -import { OrgunitSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component'; +import { OrgUnitSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component'; import { ProjectSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component'; +import { PersonItemMetadataListElementComponent } from './metadata-representations/person/person-item-metadata-list-element.component'; +import { OrgUnitItemMetadataListElementComponent } from './metadata-representations/org-unit/org-unit-item-metadata-list-element.component'; const ENTRY_COMPONENTS = [ - OrgunitComponent, + OrgUnitComponent, PersonComponent, ProjectComponent, OrgUnitListElementComponent, - OrgunitItemPageListElementComponent, + OrgUnitItemMetadataListElementComponent, PersonListElementComponent, - PersonItemPageListElementComponent, + PersonItemMetadataListElementComponent, ProjectListElementComponent, PersonGridElementComponent, - OrgunitGridElementComponent, + OrgUnitGridElementComponent, ProjectGridElementComponent, - OrgunitSearchResultListElementComponent, + OrgUnitSearchResultListElementComponent, PersonSearchResultListElementComponent, ProjectSearchResultListElementComponent, PersonSearchResultGridElementComponent, - OrgunitSearchResultGridElementComponent, + OrgUnitSearchResultGridElementComponent, ProjectSearchResultGridElementComponent ]; diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts b/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts new file mode 100644 index 0000000000..4097fb99c4 --- /dev/null +++ b/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts @@ -0,0 +1,63 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, ComponentFactoryResolver, NO_ERRORS_SCHEMA } from '@angular/core'; +import { Context } from '../../core/shared/context.model'; +import { MetadataRepresentation, MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; +import { MetadataRepresentationLoaderComponent } from './metadata-representation-loader.component'; +import { PlainTextMetadataListElementComponent } from '../object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component'; +import { spyOnExported } from '../testing/utils'; +import { MetadataRepresentationDirective } from './metadata-representation.directive'; +import * as metadataRepresentationDecorator from './metadata-representation.decorator'; + +const testType = 'TestType'; +const testContext = Context.Search; +const testRepresentationType = MetadataRepresentationType.Item; + +class TestType implements MetadataRepresentation { + get itemType(): string { + return testType; + } + + get representationType(): MetadataRepresentationType { + return testRepresentationType; + } + + getValue(): string { + return ''; + } +} +describe('MetadataRepresentationLoaderComponent', () => { + let comp: MetadataRepresentationLoaderComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [MetadataRepresentationLoaderComponent, PlainTextMetadataListElementComponent, MetadataRepresentationDirective], + schemas: [NO_ERRORS_SCHEMA], + providers: [ComponentFactoryResolver] + }).overrideComponent(MetadataRepresentationLoaderComponent, { + set: { + changeDetection: ChangeDetectionStrategy.Default, + entryComponents: [PlainTextMetadataListElementComponent] + } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(MetadataRepresentationLoaderComponent); + comp = fixture.componentInstance; + + comp.mdRepresentation = new TestType(); + comp.context = testContext; + + spyOnExported(metadataRepresentationDecorator, 'getMetadataRepresentationComponent').and.returnValue(PlainTextMetadataListElementComponent); + fixture.detectChanges(); + + })); + + describe('When the component is rendered', () => { + it('should call the getMetadataRepresentationComponent function with the right entity type, representation type and context', () => { + expect(metadataRepresentationDecorator.getMetadataRepresentationComponent).toHaveBeenCalledWith(testType, testRepresentationType, testContext); + }) + }); +}); diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.ts index 0903e05f56..a5ea26aa89 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.ts @@ -8,7 +8,6 @@ export const DEFAULT_ENTITY_TYPE = 'Publication'; export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; export const DEFAULT_CONTEXT = Context.Undefined; - /** * Decorator function to store metadata representation mapping * @param entityType The entity type the component represents diff --git a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts index 0ddb24ec2f..554becdb27 100644 --- a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts +++ b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts @@ -15,7 +15,7 @@ import { MyDSpaceActionsComponent } from '../mydspace-actions'; import { NotificationsService } from '../../notifications/notifications.service'; /** - * This component represents mydspace actions related to ClaimedTask object. + * This component represents actions related to ClaimedTask object. */ @Component({ selector: 'ds-claimed-task-actions', diff --git a/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.ts b/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.ts index 71f854c5e7..453d875150 100644 --- a/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.ts +++ b/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.ts @@ -9,7 +9,7 @@ import { WorkflowItemDataService } from '../../../core/submission/workflowitem-d import { NotificationsService } from '../../notifications/notifications.service'; /** - * This component represents mydspace actions related to WorkflowItem object. + * This component represents actions related to WorkflowItem object. */ @Component({ selector: 'ds-workflowitem-actions', diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts index 69214e800e..ca0b416b60 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts @@ -8,11 +8,10 @@ import { TranslateService } from '@ngx-translate/core'; import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model'; import { MyDSpaceActionsComponent } from '../mydspace-actions'; import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service'; -import { ResourceType } from '../../../core/shared/resource-type'; import { NotificationsService } from '../../notifications/notifications.service'; /** - * This component represents mydspace actions related to WorkspaceItem object. + * This component represents actions related to WorkspaceItem object. */ @Component({ selector: 'ds-workspaceitem-actions', diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts new file mode 100644 index 0000000000..f470f566f0 --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts @@ -0,0 +1,58 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, ComponentFactoryResolver, NO_ERRORS_SCHEMA } from '@angular/core'; +import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component'; +import { ListableObject } from '../listable-object.model'; +import { GenericConstructor } from '../../../../core/shared/generic-constructor'; +import { Context } from '../../../../core/shared/context.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; +import * as listableObjectDecorators from './listable-object.decorator'; +import { PublicationListElementComponent } from '../../../object-list/item-list-element/item-types/publication/publication-list-element.component'; +import { ListableObjectDirective } from './listable-object.directive'; +import { spyOnExported } from '../../../testing/utils'; + +const testType = 'TestType'; +const testContext = Context.Search; +const testViewMode = ViewMode.StandalonePage; + +class TestType implements ListableObject { + getRenderTypes(): Array> { + return [testType]; + } +} + +describe('ListableObjectComponentLoaderComponent', () => { + let comp: ListableObjectComponentLoaderComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [ListableObjectComponentLoaderComponent, PublicationListElementComponent, ListableObjectDirective], + schemas: [NO_ERRORS_SCHEMA], + providers: [ComponentFactoryResolver] + }).overrideComponent(ListableObjectComponentLoaderComponent, { + set: { + changeDetection: ChangeDetectionStrategy.Default, + entryComponents: [PublicationListElementComponent] + } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(ListableObjectComponentLoaderComponent); + comp = fixture.componentInstance; + + comp.object = new TestType(); + comp.viewMode = testViewMode; + comp.context = testContext; + spyOnExported(listableObjectDecorators, 'getListableObjectComponent').and.returnValue(PublicationListElementComponent); + fixture.detectChanges(); + + })); + + describe('When the component is rendered', () => { + it('should call the getListableObjectComponent function with the right types, view mode and context', () => { + expect(listableObjectDecorators.getListableObjectComponent).toHaveBeenCalledWith([testType], testViewMode, testContext); + }) + }); +}); diff --git a/src/app/shared/object-collection/shared/workflowitem-search-result.model.ts b/src/app/shared/object-collection/shared/workflow-item-search-result.model.ts similarity index 100% rename from src/app/shared/object-collection/shared/workflowitem-search-result.model.ts rename to src/app/shared/object-collection/shared/workflow-item-search-result.model.ts diff --git a/src/app/shared/object-collection/shared/workspaceitem-search-result.model.ts b/src/app/shared/object-collection/shared/workspace-item-search-result.model.ts similarity index 100% rename from src/app/shared/object-collection/shared/workspaceitem-search-result.model.ts rename to src/app/shared/object-collection/shared/workspace-item-search-result.model.ts diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts index fa51fa61f6..72ffca4b98 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { find } from 'rxjs/operators'; @@ -12,7 +12,6 @@ import { SearchResultDetailElementComponent } from '../search-result-detail-elem import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; /** * This component renders claimed task object for the search result in the detail view. @@ -45,11 +44,12 @@ export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultD * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initWorkflowItem(this.dso.workflowitem as Observable>); } /** - * Retrieve workflowitem from result object + * Retrieve workflow item from result object */ initWorkflowItem(wfi$: Observable>) { wfi$.pipe( diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts index f0ffe0b44f..95de372713 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component.ts @@ -13,7 +13,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; /** - * This component renders pool task object for the mydspace result in the detail view. + * This component renders pool task object for the search result in the detail view. */ @Component({ selector: 'ds-pool-search-result-detail-element', @@ -43,6 +43,7 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initWorkflowItem(this.dso.workflowitem as Observable>); } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts index 0e1a3bd307..2e6ad0ef95 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.spec.ts @@ -9,7 +9,7 @@ import { WorkflowItemSearchResultDetailElementComponent } from './workflow-item- import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model'; let component: WorkflowItemSearchResultDetailElementComponent; let fixture: ComponentFixture; diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts index 830c842223..23a8ad9e18 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component.ts @@ -10,7 +10,7 @@ import { RemoteData } from '../../../../core/data/remote-data'; import { find } from 'rxjs/operators'; import { isNotUndefined } from '../../../empty.util'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model'; /** * This component renders workflowitem object for the search result in the detail view. @@ -38,6 +38,7 @@ export class WorkflowItemSearchResultDetailElementComponent extends SearchResult * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initItem(this.dso.item as Observable>); } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts index c841bf1dab..fb5793b3bb 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.spec.ts @@ -9,7 +9,7 @@ import { WorkspaceItemSearchResultDetailElementComponent } from './workspace-ite import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model'; let component: WorkspaceItemSearchResultDetailElementComponent; let fixture: ComponentFixture; diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts index 0f8e1a65cb..746fd02889 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component.ts @@ -11,7 +11,7 @@ import { SearchResultDetailElementComponent } from '../search-result-detail-elem import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model'; +import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspace-item-search-result.model'; /** * This component renders workspace item object for the search result in the detail view. @@ -39,6 +39,7 @@ export class WorkspaceItemSearchResultDetailElementComponent extends SearchResul * Initialize all instance variables */ ngOnInit() { + super.ngOnInit(); this.initItem(this.dso.item as Observable>); } diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html index 4ecb8c0c51..91219c7189 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html @@ -1,2 +1 @@ - - + diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts index fe2ada3aff..8c5cec4aba 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts @@ -27,9 +27,9 @@ describe('ItemMetadataListElementComponent', () => { fixture.detectChanges(); })); - it('should call an item-type-switcher component and pass the item-metadata-representation', () => { - const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-listable-object-component-loader')).nativeElement; - expect(itemTypeSwitcher.object).toBe(mockItemMetadataRepresentation); + it('should call a listable-object-component-loader component and pass the item-metadata-representation', () => { + const objectLoader = fixture.debugElement.query(By.css('ds-listable-object-component-loader')).nativeElement; + expect(objectLoader.object).toBe(mockItemMetadataRepresentation); }); }); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts index 6c1250773f..35371f40aa 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts @@ -19,7 +19,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme */ @Component({ selector: 'ds-claimed-search-result-list-element', - styleUrls: ['../my-dspace-result-list-element.component.scss'], + styleUrls: ['../../search-result-list-element/search-result-list-element.component.scss'], templateUrl: './claimed-search-result-list-element.component.html', providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index db0216908d..6a3cc3befb 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -13,7 +13,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme */ @Component({ selector: 'ds-item-search-result-list-element-submission', - styleUrls: ['../my-dspace-result-list-element.component.scss', './item-search-result-list-element-submission.component.scss'], + styleUrls: ['../../search-result-list-element/search-result-list-element.component.scss', './item-search-result-list-element-submission.component.scss'], templateUrl: './item-search-result-list-element-submission.component.html' }) diff --git a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.scss b/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.scss deleted file mode 100644 index 4cd8a2b697..0000000000 --- a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.scss +++ /dev/null @@ -1 +0,0 @@ -@import '../search-result-list-element/search-result-list-element.component.scss'; diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts index 93941f8a81..b34e23c3e6 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts @@ -19,7 +19,7 @@ import { TruncatableService } from '../../../truncatable/truncatable.service'; */ @Component({ selector: 'ds-pool-search-result-list-element', - styleUrls: ['../my-dspace-result-list-element.component.scss'], + styleUrls: ['../../search-result-list-element/search-result-list-element.component.scss'], templateUrl: './pool-search-result-list-element.component.html', }) diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts index 90036142c4..4ecdbea4d6 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.spec.ts @@ -9,7 +9,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; import { WorkflowItemSearchResultListElementComponent } from './workflow-item-search-result-list-element.component'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model'; import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: WorkflowItemSearchResultListElementComponent; diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts index 8182342c3a..faf03425f0 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component.ts @@ -10,7 +10,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** @@ -18,7 +18,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme */ @Component({ selector: 'ds-workflow-item-my-dspace-result-list-element', - styleUrls: ['../my-dspace-result-list-element.component.scss'], + styleUrls: ['../../search-result-list-element/search-result-list-element.component.scss'], templateUrl: './workflow-item-search-result-list-element.component.html', }) diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts index eac4320bd7..349f32dfd6 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.spec.ts @@ -9,7 +9,7 @@ import { WorkspaceItemSearchResultListElementComponent } from './workspace-item- import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; -import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; +import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model'; import { TruncatableService } from '../../../truncatable/truncatable.service'; let component: WorkspaceItemSearchResultListElementComponent; diff --git a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts index 2e9363decc..830726c677 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/workspace-item-search-result/workspace-item-search-result-list-element.component.ts @@ -10,7 +10,7 @@ import { isNotUndefined } from '../../../empty.util'; import { Item } from '../../../../core/shared/item.model'; import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; -import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model'; +import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspace-item-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** @@ -18,7 +18,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme */ @Component({ selector: 'ds-workspace-item-search-result-list-element', - styleUrls: ['../my-dspace-result-list-element.component.scss', './workspace-item-search-result-list-element.component.scss'], + styleUrls: ['../../search-result-list-element/search-result-list-element.component.scss', './workspace-item-search-result-list-element.component.scss'], templateUrl: './workspace-item-search-result-list-element.component.html', }) diff --git a/src/app/shared/object-list/object-list.component.ts b/src/app/shared/object-list/object-list.component.ts index e1dabce943..1158085bb0 100644 --- a/src/app/shared/object-list/object-list.component.ts +++ b/src/app/shared/object-list/object-list.component.ts @@ -70,7 +70,6 @@ export class ObjectListComponent { */ private _objects: RemoteData>; - /** * Setter for the objects * @param objects The new objects diff --git a/src/app/shared/testing/utils.ts b/src/app/shared/testing/utils.ts index 4a551582ee..afd048096a 100644 --- a/src/app/shared/testing/utils.ts +++ b/src/app/shared/testing/utils.ts @@ -121,3 +121,14 @@ export function createPendingRemoteDataObject(object?: T): RemoteData { export function createPendingRemoteDataObject$(object?: T): Observable> { return observableOf(createPendingRemoteDataObject(object)); } + +/** + * Creates a jasmine spy for an exported function + * @param target The object to spy on + * @param prop The property/function to spy on + */ +export function spyOnExported(target: T, prop: keyof T): jasmine.Spy { + const spy = jasmine.createSpy(`${prop}Spy`); + spyOnProperty(target, prop).and.returnValue(spy); + return spy; +} From ddbe0c825a882ddb115e35f95cc41ab0dbcbc30c Mon Sep 17 00:00:00 2001 From: lotte Date: Wed, 16 Oct 2019 16:32:22 +0200 Subject: [PATCH 13/17] fixed test issue --- .../org-unit/org-unit-search-result-list-element.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.html index 39a7add763..f08d0fdc11 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.html @@ -9,7 +9,7 @@ + class="item-list-org-unit-description"> From b1ff5765a61da372d463c9bac00fe3084459b765 Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 7 Nov 2019 16:41:28 +0100 Subject: [PATCH 14/17] Fixes after merge --- .../search-filters/search-filters.component.ts | 2 +- .../journal-issue/journal-issue.component.spec.ts | 7 +------ ...rg-unit-item-metadata-list-element.component.html | 4 ++-- ...unit-item-metadata-list-element.component.spec.ts | 4 +++- .../org-unit-item-metadata-list-element.component.ts | 5 ++--- .../person-item-metadata-list-element.component.html | 4 ++-- ...rson-item-metadata-list-element.component.spec.ts | 5 ++++- .../person-item-metadata-list-element.component.ts | 5 ++--- .../metadata-representation.decorator.spec.ts | 8 ++++---- .../listable-object.decorator.spec.ts | 12 ++++++------ ...metadata-representation-list-element.component.ts | 7 ++----- 11 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/app/+search-page/search-filters/search-filters.component.ts b/src/app/+search-page/search-filters/search-filters.component.ts index 9d0dfceb15..69bbb6234b 100644 --- a/src/app/+search-page/search-filters/search-filters.component.ts +++ b/src/app/+search-page/search-filters/search-filters.component.ts @@ -71,7 +71,7 @@ export class SearchFiltersComponent implements OnInit { /** * @returns {string} The base path to the search page, or the current page when inPlaceSearch is true */ - private getSearchLink(): string { + getSearchLink(): string { if (this.inPlaceSearch) { return './'; } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts index 00403473a7..4c67708b8b 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts @@ -1,13 +1,8 @@ import { Item } from '../../../../core/shared/item.model'; -import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { JournalIssueComponent } from './journal-issue.component'; -import { of as observableOf } from 'rxjs'; -import { - createRelationshipsObservable, - getItemPageFieldsTest -} from '../../../../+item-page/simple/item-types/shared/item.component.spec'; +import { createRelationshipsObservable, getItemPageFieldsTest } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; const mockItem: Item = Object.assign(new Item(), { diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html index bdeb37dcd8..0977413722 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html @@ -8,6 +8,6 @@ + [innerHTML]="metadataRepresentation.getValue()" + [tooltip]="metadataRepresentation.allMetadata(['dc.description']).length > 0 ? descTemplate : null"> diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts index 8616e4fa01..7d27b605ec 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts @@ -5,11 +5,13 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep import { OrgUnitItemMetadataListElementComponent } from './org-unit-item-metadata-list-element.component'; import { Item } from '../../../../core/shared/item.model'; import { TooltipModule } from 'ngx-bootstrap'; +import { MetadataValue } from '../../../../core/shared/metadata.models'; const description = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'; const organisation = 'Anonymous'; const mockItem = Object.assign(new Item(), { metadata: { 'dc.description': [{ value: description }], 'organization.legalName': [{ value: organisation }] } }); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); +const virtMD = Object.assign(new MetadataValue(), { value: organisation }); +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(virtMD), mockItem); describe('OrgUnitItemMetadataListElementComponent', () => { let comp: OrgUnitItemMetadataListElementComponent; diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts index e0bb542241..183bebe10c 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @metadataRepresentationComponent('OrgUnit', MetadataRepresentationType.Item) @Component({ @@ -11,6 +11,5 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep /** * The component for displaying an item of the type OrgUnit as a metadata field */ -export class OrgUnitItemMetadataListElementComponent { - metadataRepresentation: ItemMetadataRepresentation; +export class OrgUnitItemMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent { } diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html index fdc9dd8943..69cf463b3f 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html @@ -10,6 +10,6 @@ + [innerHTML]="metadataRepresentation.getValue()" + [tooltip]="metadataRepresentation.allMetadata(['person.jobTitle']).length > 0 ? descTemplate : null"> diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts index 0d4786f37e..1081e45884 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts @@ -5,12 +5,15 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep import { Item } from '../../../../core/shared/item.model'; import { PersonItemMetadataListElementComponent } from './person-item-metadata-list-element.component'; import { TooltipModule } from 'ngx-bootstrap'; +import { MetadataValue } from '../../../../core/shared/metadata.models'; const jobTitle ='Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'; const firstName = 'Joe'; const lastName = 'Anonymous'; const mockItem = Object.assign(new Item(), { metadata: { 'person.jobTitle': [{ value: jobTitle }], 'person.givenName': [{ value: firstName }], 'person.familyName': [{ value: lastName }] } }); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); +const virtMD = Object.assign(new MetadataValue(), { value: lastName + ', ' + firstName }); + +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(virtMD), mockItem); describe('PersonItemMetadataListElementComponent', () => { let comp: PersonItemMetadataListElementComponent; diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts index e39eb05948..f3d0a28fda 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @metadataRepresentationComponent('Person', MetadataRepresentationType.Item) @Component({ @@ -11,6 +11,5 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep /** * The component for displaying an item of the type Person as a metadata field */ -export class PersonItemMetadataListElementComponent { - metadataRepresentation: ItemMetadataRepresentation; +export class PersonItemMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent { } diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts index 38d64d9ff5..0ca7ebb9b9 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts @@ -27,14 +27,14 @@ describe('MetadataRepresentation decorator function', () => { metadataRepresentationComponent(key + type1, MetadataRepresentationType.AuthorityControlled)(Test1Authority); metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item)(Test2Item); - metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item, Context.Submission)(Test2ItemSubmission); + metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item, Context.Workspace)(Test2ItemSubmission); - metadataRepresentationComponent(key + type3, MetadataRepresentationType.Item, Context.Submission)(Test3ItemSubmission); + metadataRepresentationComponent(key + type3, MetadataRepresentationType.Item, Context.Workspace)(Test3ItemSubmission); } describe('If there\'s an exact match', () => { it('should return the matching class', () => { - const component = getMetadataRepresentationComponent(prefix + type3, MetadataRepresentationType.Item, Context.Submission); + const component = getMetadataRepresentationComponent(prefix + type3, MetadataRepresentationType.Item, Context.Workspace); expect(component).toEqual(Test3ItemSubmission); }); }); @@ -42,7 +42,7 @@ describe('MetadataRepresentation decorator function', () => { describe('If there isn\'nt an exact match', () => { describe('If there is a match for the entity type and representation type', () => { it('should return the class with the matching entity type and representation type and default context', () => { - const component = getMetadataRepresentationComponent(prefix + type1, MetadataRepresentationType.AuthorityControlled, Context.Submission); + const component = getMetadataRepresentationComponent(prefix + type1, MetadataRepresentationType.AuthorityControlled, Context.Workspace); expect(component).toEqual(Test1Authority); }); }); diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts index 2873c4fce8..0143984bd6 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts @@ -22,10 +22,10 @@ describe('ListableObject decorator function', () => { listableObjectComponent(type1, ViewMode.GridElement)(Test1Grid); listableObjectComponent(type2, ViewMode.ListElement)(Test2List); - listableObjectComponent(type2, ViewMode.ListElement, Context.Submission)(Test2ListSubmission); + listableObjectComponent(type2, ViewMode.ListElement, Context.Workspace)(Test2ListSubmission); listableObjectComponent(type3, ViewMode.ListElement)(Test3List); - listableObjectComponent(type3, ViewMode.DetailedListElement, Context.Submission)(Test3DetailedSubmission); + listableObjectComponent(type3, ViewMode.DetailedListElement, Context.Workspace)(Test3DetailedSubmission); }); const gridDecorator = listableObjectComponent('Item', ViewMode.GridElement); @@ -40,10 +40,10 @@ describe('ListableObject decorator function', () => { describe('If there\'s an exact match', () => { it('should return the matching class', () => { - const component = getListableObjectComponent([type3], ViewMode.DetailedListElement, Context.Submission); + const component = getListableObjectComponent([type3], ViewMode.DetailedListElement, Context.Workspace); expect(component).toEqual(Test3DetailedSubmission); - const component2 = getListableObjectComponent([type3, type2], ViewMode.ListElement, Context.Submission); + const component2 = getListableObjectComponent([type3, type2], ViewMode.ListElement, Context.Workspace); expect(component2).toEqual(Test2ListSubmission); }); }); @@ -51,10 +51,10 @@ describe('ListableObject decorator function', () => { describe('If there isn\'nt an exact match', () => { describe('If there is a match for one of the entity types and the view mode', () => { it('should return the class with the matching entity type and view mode and default context', () => { - const component = getListableObjectComponent([type3], ViewMode.ListElement, Context.Submission); + const component = getListableObjectComponent([type3], ViewMode.ListElement, Context.Workspace); expect(component).toEqual(Test3List); - const component2 = getListableObjectComponent([type3, type1], ViewMode.GridElement, Context.Submission); + const component2 = getListableObjectComponent([type3, type1], ViewMode.GridElement, Context.Workspace); expect(component2).toEqual(Test1Grid); }); }); diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts index 0fdca0d429..6c4d300e99 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts @@ -1,6 +1,5 @@ import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; -import { Component, Inject } from '@angular/core'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { Component } from '@angular/core'; import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; @Component({ @@ -11,7 +10,5 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep * An abstract class for displaying a single ItemMetadataRepresentation */ export class ItemMetadataRepresentationListElementComponent extends MetadataRepresentationListElementComponent { - constructor(@Inject(ITEM) public metadataRepresentation: ItemMetadataRepresentation) { - super(metadataRepresentation); - } + metadataRepresentation: ItemMetadataRepresentation; } From 575a1420224c67eb289959048782571b1be37e1c Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 7 Nov 2019 16:58:05 +0100 Subject: [PATCH 15/17] split up submission context --- .../my-dspace-page.component.html | 3 ++- .../+my-dspace-page/my-dspace-page.component.ts | 16 +++++++++++++++- .../my-dspace-results.component.ts | 2 +- src/app/core/shared/context.model.ts | 3 ++- ...h-result-list-element-submission.component.ts | 3 ++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/app/+my-dspace-page/my-dspace-page.component.html b/src/app/+my-dspace-page/my-dspace-page.component.html index 4c691028fc..e6d1a5c80d 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.html +++ b/src/app/+my-dspace-page/my-dspace-page.component.html @@ -39,7 +39,8 @@
+ [searchConfig]="searchOptions$ | async" + [context]="context$ | async">
diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index 1bad29f0d5..c8217f9ba8 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -8,7 +8,7 @@ import { } from '@angular/core'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; -import { switchMap, tap, } from 'rxjs/operators'; +import { map, switchMap, tap, } from 'rxjs/operators'; import { PaginatedList } from '../core/data/paginated-list'; import { RemoteData } from '../core/data/remote-data'; @@ -28,6 +28,7 @@ import { MyDSpaceConfigurationService } from './my-dspace-configuration.service' import { ViewMode } from '../core/shared/view-mode.model'; import { MyDSpaceRequest } from '../core/data/request.models'; import { SearchResult } from '../+search-page/search-result.model'; +import { Context } from '../core/shared/context.model'; export const MYDSPACE_ROUTE = '/mydspace'; export const SEARCH_CONFIG_SERVICE: InjectionToken = new InjectionToken('searchConfigurationService'); @@ -95,6 +96,8 @@ export class MyDSpacePageComponent implements OnInit { */ viewModeList = [ViewMode.ListElement, ViewMode.DetailedListElement]; + context$: Observable; + constructor(private service: SearchService, private sidebarService: SearchSidebarService, private windowService: HostWindowService, @@ -126,6 +129,17 @@ export class MyDSpacePageComponent implements OnInit { switchMap((scopeId) => this.service.getScopes(scopeId)) ); + this.context$ = this.searchConfigService.getCurrentConfiguration('workspace') + .pipe( + map((configuration: string) => { + if (configuration === 'workspace') { + return Context.Workspace + } else { + return Context.Workflow + } + }) + ); + } /** diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts index 61669277cf..96f11e7dba 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts @@ -37,7 +37,7 @@ export class MyDSpaceResultsComponent { */ @Input() viewMode: ViewMode; - context = Context.Submission; + @Input() context: Context; /** * A boolean representing if search results entry are separated by a line */ diff --git a/src/app/core/shared/context.model.ts b/src/app/core/shared/context.model.ts index a0e7f6a967..7bfd613b65 100644 --- a/src/app/core/shared/context.model.ts +++ b/src/app/core/shared/context.model.ts @@ -6,7 +6,8 @@ export enum Context { Undefined = 'undefined', ItemPage = 'itemPage', Search = 'search', - Submission = 'submission', + Workflow = 'workflow', + Workspace = 'workspace', AdminMenu = 'adminMenu', SubmissionModal = 'submissionModal', } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index 6a3cc3befb..3ef45d1c47 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -17,7 +17,8 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme templateUrl: './item-search-result-list-element-submission.component.html' }) -@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Submission) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Workspace) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Workflow) export class ItemSearchResultListElementSubmissionComponent extends SearchResultListElementComponent implements OnInit { /** * Represent item's status From 1e94a02da0adf106e43c680e3d1b8092024b6bb0 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 8 Nov 2019 07:44:10 +0100 Subject: [PATCH 16/17] added missing typedoc --- src/app/+my-dspace-page/my-dspace-page.component.ts | 6 ++++++ .../my-dspace-results/my-dspace-results.component.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index c8217f9ba8..3600a10d22 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -96,6 +96,9 @@ export class MyDSpacePageComponent implements OnInit { */ viewModeList = [ViewMode.ListElement, ViewMode.DetailedListElement]; + /** + * The current context of this page: workspace or workflow + */ context$: Observable; constructor(private service: SearchService, @@ -114,6 +117,9 @@ export class MyDSpacePageComponent implements OnInit { * * Listen to changes in the scope * If something changes, update the list of scopes for the dropdown + * + * Listen to changes in the configuration + * If something changes, update the current context */ ngOnInit(): void { this.configurationList$ = this.searchConfigService.getAvailableConfigurationOptions(); diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts index 96f11e7dba..91c206fc79 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts @@ -37,6 +37,9 @@ export class MyDSpaceResultsComponent { */ @Input() viewMode: ViewMode; + /** + * The current context for the search results + */ @Input() context: Context; /** * A boolean representing if search results entry are separated by a line From 40d740640d5af7dc238da123d8a250bf9204ab19 Mon Sep 17 00:00:00 2001 From: lotte Date: Tue, 12 Nov 2019 14:36:29 +0100 Subject: [PATCH 17/17] fixes after merge --- .../publication/publication.component.html | 8 ++++---- .../item-types/publication/publication.component.ts | 6 ++---- .../simple/item-types/shared/item.component.ts | 9 ++------- .../metadata-representation-list.component.ts | 3 +-- .../simple/related-items/related-items-component.ts | 3 --- .../journal-issue/journal-issue.component.html | 4 ++-- .../journal-issue/journal-issue.component.ts | 2 +- .../journal-volume/journal-volume.component.html | 4 ++-- .../journal-volume/journal-volume.component.ts | 2 +- .../item-pages/journal/journal.component.html | 2 +- .../item-pages/journal/journal.component.ts | 2 +- .../item-pages/org-unit/org-unit.component.html | 6 +++--- .../item-pages/org-unit/org-unit.component.ts | 2 +- .../item-pages/person/person.component.html | 8 ++++---- .../item-pages/person/person.component.ts | 2 +- .../item-pages/project/project.component.html | 12 ++++++------ .../item-pages/project/project.component.ts | 2 +- .../publication/publication.component.html | 8 ++++---- .../journal-issue/journal-issue.component.html | 4 ++-- .../journal-volume/journal-volume.component.html | 4 ++-- .../item-pages/journal/journal.component.html | 2 +- 21 files changed, 42 insertions(+), 53 deletions(-) diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index 0f049e5bf4..3cd4d0aa69 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -28,23 +28,23 @@
diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index d75a0cbf9e..a8c7539e64 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -1,10 +1,8 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { - DEFAULT_ITEM_TYPE, ItemViewMode, - rendersItemType -} from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { Item } from '../../../../core/shared/item.model'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; /** * Component that represents a publication Item page diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index ae3d660a4f..d4b0c8de89 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -1,6 +1,5 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, Input } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; -import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; @Component({ selector: 'ds-item', @@ -10,9 +9,5 @@ import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.compo * A generic component for displaying metadata and relations of an item */ export class ItemComponent { - - constructor( - @Inject(ITEM) public item: Item - ) {} - + @Input() object: Item; } diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts index ebaaa77816..b58290d87c 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -1,11 +1,10 @@ import { Component, Input, OnInit } from '@angular/core'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemViewMode } from '../../../shared/items/item-type-decorator'; import { Observable } from 'rxjs/internal/Observable'; import { RemoteData } from '../../../core/data/remote-data'; import { RelationshipService } from '../../../core/data/relationship.service'; import { Item } from '../../../core/shared/item.model'; -import { zip as observableZip, combineLatest as observableCombineLatest, of as observableOf } from 'rxjs'; +import { combineLatest as observableCombineLatest, of as observableOf, zip as observableZip } from 'rxjs'; import { MetadataValue } from '../../../core/shared/metadata.models'; import { MetadatumRepresentation } from '../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; import { filter, map, switchMap } from 'rxjs/operators'; diff --git a/src/app/+item-page/simple/related-items/related-items-component.ts b/src/app/+item-page/simple/related-items/related-items-component.ts index 3bcbf930fa..9cbfd2c28d 100644 --- a/src/app/+item-page/simple/related-items/related-items-component.ts +++ b/src/app/+item-page/simple/related-items/related-items-component.ts @@ -1,13 +1,10 @@ import { Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import { ItemViewMode } from '../../../shared/items/item-type-decorator'; import { Observable } from 'rxjs/internal/Observable'; import { RemoteData } from '../../../core/data/remote-data'; import { PaginatedList } from '../../../core/data/paginated-list'; import { RelationshipService } from '../../../core/data/relationship.service'; import { FindAllOptions } from '../../../core/data/request.models'; -import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators'; -import { hasNoValue, hasValueOperator } from '../../../shared/empty.util'; import { Subscription } from 'rxjs/internal/Subscription'; import { ViewMode } from '../../../core/shared/view-mode.model'; diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index cd982ff17d..87312f8784 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -29,13 +29,13 @@
diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts index 86675baf00..6f1cbf9923 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @listableObjectComponent('JournalIssue', ViewMode.StandalonePage) @Component({ diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html index 6ecc124978..e77b24a98b 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html @@ -17,12 +17,12 @@
diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts index 48b5433e53..4219609aab 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @listableObjectComponent('JournalVolume', ViewMode.StandalonePage) @Component({ diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index 1a48f525fa..ae6c3a8914 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -21,7 +21,7 @@
diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts index 660c5c3c28..dbbeb81662 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @listableObjectComponent('Journal', ViewMode.StandalonePage) @Component({ diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index e1bd4a90d6..4d97868b58 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -25,17 +25,17 @@
diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts index 25fd54347d..d9d4461bfa 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @listableObjectComponent('OrgUnit', ViewMode.StandalonePage) @Component({ diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.html b/src/app/entity-groups/research-entities/item-pages/person/person.component.html index 13522acec9..ff675ab057 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -10,7 +10,7 @@ [fields]="['person.email']" [label]="'person.page.email'"> - + @@ -18,19 +18,19 @@ [fields]="['person.birthDate']" [label]="'person.page.birthdate'"> - +
diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts index c83bf1c81e..15c7184702 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @listableObjectComponent('Person', ViewMode.StandalonePage) @Component({ diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 95b7b03ec7..bb6ce21cd1 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -6,12 +6,12 @@ - + @@ -24,24 +24,24 @@ [fields]="['dc.identifier']" [label]="'project.page.id'"> - +
diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts index 7d2416c8d2..8ac424af5b 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../core/shared/view-mode.model'; @listableObjectComponent('Project', ViewMode.StandalonePage) @Component({ diff --git a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html index fa629eec52..35dc903432 100644 --- a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html +++ b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html @@ -1,4 +1,4 @@ -
+a
@@ -63,19 +63,19 @@
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index 47dc756e11..9fa80d9c3c 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -62,13 +62,13 @@
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html index 0ca7c507ac..99d92d2af8 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html @@ -47,13 +47,13 @@
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index 27af0d3731..1b8a283da9 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -50,7 +50,7 @@