diff --git a/src/app/shared/object-collection/shared/collection-search-result.model.ts b/src/app/shared/object-collection/shared/collection-search-result.model.ts new file mode 100644 index 0000000000..63b6a0d37a --- /dev/null +++ b/src/app/shared/object-collection/shared/collection-search-result.model.ts @@ -0,0 +1,5 @@ +import { Collection } from '../../../core/shared/collection.model'; +import { SearchResult } from '../../../+search-page/search-result.model'; + +export class CollectionSearchResult extends SearchResult { +} diff --git a/src/app/shared/object-collection/shared/community-search-result.model.ts b/src/app/shared/object-collection/shared/community-search-result.model.ts new file mode 100644 index 0000000000..79ea34b6cd --- /dev/null +++ b/src/app/shared/object-collection/shared/community-search-result.model.ts @@ -0,0 +1,5 @@ +import { SearchResult } from '../../../+search-page/search-result.model'; +import { Community } from '../../../core/shared/community.model'; + +export class CommunitySearchResult extends SearchResult { +} diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.spec.ts b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.spec.ts index cb9e20449e..1fd98bf225 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.spec.ts @@ -5,7 +5,6 @@ import { ActivatedRoute, Router } from '@angular/router'; import { RouterStub } from '../../testing/router-stub'; import { Observable } from 'rxjs/Observable'; import { By } from '@angular/platform-browser'; -import { ListableObject } from '../../object-collection/shared/listable-object.model'; import { Community } from '../../../core/shared/community.model'; let communityGridElementComponent: CommunityGridElementComponent; @@ -51,6 +50,7 @@ describe('CommunityGridElementComponent', () => { })); it('should show the community cards in the grid element',() => { + console.log(fixture.debugElement.query(By.css('ds-community-grid-element'))); expect(fixture.debugElement.query(By.css('ds-community-grid-element'))).toBeDefined(); }) 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 b8bacfaf2e..47b5a6b2e6 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 @@ -6,7 +6,6 @@

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

-

{{authorMd.value}} ; 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 index 3be46965ee..8c7f856450 100644 --- 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 @@ -64,4 +64,4 @@ describe('ItemGridElementComponent', () => { } }); -}) +}); 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 0228107a57..e5747a1243 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 @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { renderElementsFor} from '../../../object-collection/shared/dso-element-decorator'; -import { CollectionSearchResult } from './collection-search-result.model'; +import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; import { SearchResultGridElementComponent } from '../search-result-grid-element.component'; import { Collection } from '../../../../core/shared/collection.model'; import { ViewMode } from '../../../../+search-page/search-options.model'; diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result.model.ts b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result.model.ts deleted file mode 100644 index ad48247e70..0000000000 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SearchResult } from '../../../../+search-page/search-result.model'; -import { Collection } from '../../../../core/shared/collection.model'; - -export class CollectionSearchResult extends SearchResult { -} 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 4876a784fc..d490560919 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,10 +1,10 @@ import { Component } from '@angular/core'; -import { CommunitySearchResult } from './community-search-result.model'; 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 { ViewMode } from '../../../../+search-page/search-options.model'; +import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; @Component({ selector: 'ds-community-search-result-grid-element', @@ -15,4 +15,4 @@ import { ViewMode } from '../../../../+search-page/search-options.model'; @renderElementsFor(CommunitySearchResult, ViewMode.Grid) export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent { -} +} \ No newline at end of file diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result.model.ts b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result.model.ts deleted file mode 100644 index efeb328e11..0000000000 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SearchResult } from '../../../../+search-page/search-result.model'; -import { Community } from '../../../../core/shared/community.model'; - -export class CommunitySearchResult extends SearchResult { -} 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 352ba4881d..b185caa18f 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 @@ -10,10 +10,10 @@

-

- {{dso.findMetadata("dc.date.issued")}} + {{dso.findMetadata("dc.date.issued")}} , 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 172888e98c..fbb267b8e6 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 @@ -3,11 +3,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Observable } from 'rxjs/Observable'; import { ActivatedRoute, Router } from '@angular/router'; import { RouterStub } from '../../../testing/router-stub'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } 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'; let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent; let fixture: ComponentFixture; @@ -24,7 +26,10 @@ const truncatableServiceStub: any = { isCollapsed: (id: number) => Observable.of(true), }; -const mockItem: Item = Object.assign(new Item(), { +const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult(); +mockItemWithAuthorAndDate.hitHighlights = []; +mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), { + bitstreams: Observable.of({}), metadata: [ { key: 'dc.contributor.author', @@ -34,14 +39,33 @@ const mockItem: Item = Object.assign(new Item(), { { key: 'dc.date.issued', language: null, - value: '1650-06-26' + value: '2015-06-26' }] }); -const createdGridElementComponent: ItemSearchResultGridElementComponent = new ItemSearchResultGridElementComponent(mockItem, truncatableServiceStub as TruncatableService); + +const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutAuthorAndDate.hitHighlights = []; +mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), { + bitstream: Observable.of({}), + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'This is just another title' + }, + { + key: 'dc.type', + language: null, + value: 'Article' + }] +}); + +const createdGridElementComponent: ItemSearchResultGridElementComponent = new ItemSearchResultGridElementComponent(mockItemWithAuthorAndDate, truncatableServiceStub as TruncatableService); describe('ItemSearchResultGridElementComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], declarations: [ItemSearchResultGridElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: truncatableServiceStub }, @@ -49,9 +73,10 @@ describe('ItemSearchResultGridElementComponent', () => { { provide: Router, useClass: RouterStub }, { provide: 'objectElementProvider', useValue: (createdGridElementComponent) } ], - schemas: [NO_ERRORS_SCHEMA] - }).compileComponents(); // compile template and css + }).overrideComponent(ItemSearchResultGridElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); })); beforeEach(async(() => { @@ -59,28 +84,48 @@ describe('ItemSearchResultGridElementComponent', () => { itemSearchResultGridElementComponent = fixture.componentInstance; })); - it('should show the item result cards in the grid element', () => { - expect(fixture.debugElement.query(By.css('ds-item-search-result-grid-element'))).toBeDefined(); + fdescribe('When the item has an author', () => { + beforeEach(() => { + itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.dspaceObject; + fixture.detectChanges(); + }); + + it('should show the author paragraph', () => { + const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors')); + expect(itemAuthorField).not.toBeNull(); + }); }); - it('should only show the author span if the author metadata is present', () => { - const itemAuthorField = expect(fixture.debugElement.query(By.css('p.item-authors'))); + describe('When the item has no author', () => { + beforeEach(() => { + itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.dspaceObject; + }); - if (mockItem.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0) { - expect(itemAuthorField).toBeDefined(); - } else { - expect(itemAuthorField).not.toBeDefined(); - } + it('should not show the author paragraph', () => { + const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors')); + expect(itemAuthorField).toBeNull(); + }); }); - it('should only show the date span if the issuedate is present', () => { - const dateField = expect(fixture.debugElement.query(By.css('span.item-list-date'))); + describe('When the item has an issuedate', () => { + beforeEach(() => { + itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.dspaceObject; + }); - if (mockItem.findMetadata('dc.date.issued').length > 0) { - expect(dateField).toBeDefined(); - } else { - expect(dateField).not.toBeDefined(); - } + 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(() => { + itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.dspaceObject; + }); + + 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/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 9be2647cba..c04c1d54f4 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 @@ -20,6 +20,7 @@ export class SearchResultGridElementComponent, K exten public constructor(@Inject('objectElementProvider') public gridable: ListableObject, private truncatableService: TruncatableService) { super(gridable); this.dso = this.object.dspaceObject; + console.log(JSON.stringify(this.object.hitHighlights)); } getValues(keys: string[]): string[] { @@ -43,6 +44,7 @@ export class SearchResultGridElementComponent, K exten getFirstValue(key: string): string { let result: string; + console.log(JSON.stringify(this.object.hitHighlights)); this.object.hitHighlights.some( (md: Metadatum) => { if (key === md.key) { diff --git a/src/app/shared/object-list/collection-list-element/collection-list-element.component.spec.ts b/src/app/shared/object-list/collection-list-element/collection-list-element.component.spec.ts index 0f1b7c4444..fe54b8195e 100644 --- a/src/app/shared/object-list/collection-list-element/collection-list-element.component.spec.ts +++ b/src/app/shared/object-list/collection-list-element/collection-list-element.component.spec.ts @@ -56,4 +56,4 @@ describe('CollectionListElementComponent', () => { expect(descriptionText).not.toBeDefined(); } }); -}) +}); 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 5545ea17ec..9a462c124e 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,10 +1,10 @@ import { Component } from '@angular/core'; import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; -import { CollectionSearchResult } from './collection-search-result.model'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Collection } from '../../../../core/shared/collection.model'; import { ViewMode } from '../../../../+search-page/search-options.model'; +import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; @Component({ selector: 'ds-collection-search-result-list-element', diff --git a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result.model.ts b/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result.model.ts deleted file mode 100644 index ad48247e70..0000000000 --- a/src/app/shared/object-list/search-result-list-element/collection-search-result/collection-search-result.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SearchResult } from '../../../../+search-page/search-result.model'; -import { Collection } from '../../../../core/shared/collection.model'; - -export class CollectionSearchResult extends SearchResult { -} 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 2d96f61833..5664e840e3 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,7 +1,7 @@ import { Component } from '@angular/core'; import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; -import { CommunitySearchResult } from './community-search-result.model'; +import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; import { Community } from '../../../../core/shared/community.model'; import { ViewMode } from '../../../../+search-page/search-options.model'; diff --git a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result.model.ts b/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result.model.ts deleted file mode 100644 index efeb328e11..0000000000 --- a/src/app/shared/object-list/search-result-list-element/community-search-result/community-search-result.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SearchResult } from '../../../../+search-page/search-result.model'; -import { Community } from '../../../../core/shared/community.model'; - -export class CommunitySearchResult extends SearchResult { -} diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html index 964e52603f..72f41cd770 100644 --- a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html +++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html @@ -1,4 +1,4 @@ -

+
diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss index 698f1fb1aa..bb26239c57 100644 --- a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss +++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss @@ -25,7 +25,11 @@ background: linear-gradient(to right, rgba(255, 255, 255, 0), $body-bg 70%); } } +} +@mixin min($lines, $size-factor: 1, $line-height: $line-height-base) { + $height: $line-height * $font-size-base * $size-factor; + min-height: $lines * $height; } $h4-factor: strip-unit($h4-font-size); @@ -42,7 +46,18 @@ $h4-factor: strip-unit($h4-font-size); } } - .clamp-none { overflow: hidden; + @for $i from 1 through 15 { + &.min-#{$i} { + transition: height 1s; + @include min($i); + &.title { + @include min($i, 1.25); + } + &.h4 { + @include min($i, $h4-factor, $headings-line-height); + } + } + } } \ No newline at end of file