Skip to content

Commit

Permalink
Merge 093a8e9 into 981284f
Browse files Browse the repository at this point in the history
  • Loading branch information
tdonohue committed Apr 23, 2019
2 parents 981284f + 093a8e9 commit 6f09f97
Show file tree
Hide file tree
Showing 206 changed files with 6,396 additions and 543 deletions.
4 changes: 2 additions & 2 deletions config/environment.default.js
Expand Up @@ -10,10 +10,10 @@ module.exports = {
// The REST API server settings.
rest: {
ssl: true,
host: 'dspace7.4science.it',
host: 'dspace7-entities.atmire.com',
port: 443,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
nameSpace: '/dspace-spring-rest/api'
nameSpace: '/rest/api'
},
// Caching settings
cache: {
Expand Down
107 changes: 105 additions & 2 deletions resources/i18n/en.json
Expand Up @@ -91,12 +91,14 @@
},
"item": {
"page": {
"author": "Author",
"author": "Authors",
"abstract": "Abstract",
"date": "Date",
"uri": "URI",
"files": "Files",
"collections": "Collections",
"subject": "Keywords",
"citation": "Citation",
"filesection": {
"download": "Download",
"name": "Name:",
Expand Down Expand Up @@ -270,6 +272,84 @@
}
}
},
"relationships": {
"isPublicationOf": "Publications",
"isProjectOf": "Projects",
"isOrgUnitOf": "Org Units",
"isAuthorOf": "Authors",
"isPersonOf": "Authors",
"isJournalOf": "Journals",
"isSingleJournalOf": "Journal",
"isVolumeOf": "Volumes",
"isSingleVolumeOf": "Volume",
"isIssueOf": "Issues",
"isJournalIssueOf": "Journal Issue",
"isPublicationOfJournalIssue": "Articles"
},
"person": {
"page": {
"jobtitle": "Job Title",
"lastname": "Last Name",
"firstname": "First Name",
"email": "Email Address",
"orcid": "ORCID",
"birthdate": "Birth Date",
"staffid": "Staff ID",
"link": {
"full": "Show all metadata"
}
}
},
"project": {
"page": {
"status": "Status",
"id": "ID",
"expectedcompletion": "Expected Completion",
"description": "Description",
"keyword": "Keywords"
}
},
"orgunit": {
"page": {
"dateestablished": "Date established",
"city": "City",
"country": "Country",
"id": "ID",
"description": "Description"
}
},
"journal": {
"page": {
"issn": "ISSN",
"publisher": "Publisher",
"description": "Description",
"editor": "Editor-in-Chief"
}
},
"journalvolume": {
"page": {
"volume": "Volume",
"issuedate": "Issue Date",
"description": "Description"
}
},
"journalissue": {
"page": {
"number": "Number",
"issuedate": "Issue Date",
"description": "Description",
"keyword": "Keywords",
"journal-title": "Journal Title",
"journal-issn": "Journal ISSN"
}
},
"publication": {
"page": {
"journal-title": "Journal Title",
"journal-issn": "Journal ISSN",
"volume-title": "Volume Title"
}
},
"nav": {
"browse": {
"header": "All of DSpace"
Expand Down Expand Up @@ -319,6 +399,24 @@
}
},
"search": {
"journal": {
"title": "DSpace Angular :: Journal Search",
"results": {
"head": "Journal Search Results"
}
},
"person": {
"title": "DSpace Angular :: Person Search",
"results": {
"head": "Person Search Results"
}
},
"publication": {
"title": "DSpace Angular :: Publication Search",
"results": {
"head": "Publication Search Results"
}
},
"title": "DSpace Angular :: Search",
"description": "",
"form": {
Expand Down Expand Up @@ -355,7 +453,8 @@
"f.dateIssued.min": "Start date",
"f.dateIssued.max": "End date",
"f.subject": "Subject",
"f.has_content_in_original_bundle": "Has files"
"f.has_content_in_original_bundle": "Has files",
"f.entityType": "Item Type"
},
"filter": {
"show-more": "Show more",
Expand Down Expand Up @@ -383,6 +482,10 @@
},
"has_content_in_original_bundle": {
"head": "Has files"
},
"entityType": {
"placeholder": "Item Type",
"head": "Item Type"
}
}
}
Expand Down
Binary file added resources/images/orgunit-placeholder.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/person-placeholder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/project-placeholder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 25 additions & 17 deletions src/app/+collection-page/collection-page.component.ts
@@ -1,8 +1,9 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { CollectionDataService } from '../core/data/collection-data.service';
import { ItemDataService } from '../core/data/item-data.service';
import { PaginatedList } from '../core/data/paginated-list';
import { RemoteData } from '../core/data/remote-data';

Expand All @@ -15,7 +16,7 @@ import { Item } from '../core/shared/item.model';
import { fadeIn, fadeInOut } from '../shared/animations/fade';
import { hasValue, isNotEmpty } from '../shared/empty.util';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { filter, flatMap, map, tap } from 'rxjs/operators';
import { combineLatest, filter, first, flatMap, map } from 'rxjs/operators';
import { SearchService } from '../+search-page/search-service/search.service';
import { PaginatedSearchOptions } from '../+search-page/paginated-search-options.model';
import { toDSpaceObjectListRD } from '../core/shared/operators';
Expand All @@ -42,21 +43,21 @@ export class CollectionPageComponent implements OnInit, OnDestroy {

constructor(
private collectionDataService: CollectionDataService,
private searchService: SearchService,
private itemDataService: ItemDataService,
private metadata: MetadataService,
private route: ActivatedRoute
) {
this.paginationConfig = new PaginationComponentOptions();
this.paginationConfig.id = 'collection-page-pagination';
this.paginationConfig.pageSize = 5;
this.paginationConfig.currentPage = 1;
this.sortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
this.sortConfig = new SortOptions('dc.date.issued', SortDirection.DESC);
}

ngOnInit(): void {
this.collectionRD$ = this.route.data.pipe(
map((data) => data.collection),
tap((data) => this.collectionId = data.payload.id)
first()
);
this.logoRD$ = this.collectionRD$.pipe(
map((rd: RemoteData<Collection>) => rd.payload),
Expand All @@ -68,26 +69,33 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
this.metadata.processRemoteData(this.collectionRD$);
const page = +params.page || this.paginationConfig.currentPage;
const pageSize = +params.pageSize || this.paginationConfig.pageSize;
const sortDirection = +params.page || this.sortConfig.direction;
const pagination = Object.assign({},
this.paginationConfig,
{ currentPage: page, pageSize: pageSize }
);
this.updatePage({
pagination: pagination,
sort: this.sortConfig
const sort = Object.assign({},
this.sortConfig,
{ direction: sortDirection, field: this.sortConfig.field }
);
this.collectionRD$.subscribe((rd: RemoteData<Collection>) => {
this.collectionId = rd.payload.id;
this.updatePage({
pagination: pagination,
sort: sort
});
});
}));

})
);
}

updatePage(searchOptions) {
this.itemRD$ = this.searchService.search(
new PaginatedSearchOptions({
scope: this.collectionId,
pagination: searchOptions.pagination,
sort: searchOptions.sort,
dsoType: DSpaceObjectType.ITEM
})).pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
this.itemRD$ = this.itemDataService.findAll({
scopeID: this.collectionId,
currentPage: searchOptions.pagination.currentPage,
elementsPerPage: searchOptions.pagination.pageSize,
sort: searchOptions.sort
});
}

ngOnDestroy(): void {
Expand Down
5 changes: 4 additions & 1 deletion src/app/+collection-page/collection-page.module.ts
Expand Up @@ -7,9 +7,9 @@ import { CollectionPageComponent } from './collection-page.component';
import { CollectionPageRoutingModule } from './collection-page-routing.module';
import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component';
import { CollectionFormComponent } from './collection-form/collection-form.component';
import { SearchPageModule } from '../+search-page/search-page.module';
import { EditCollectionPageComponent } from './edit-collection-page/edit-collection-page.component';
import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component';
import { SearchService } from '../+search-page/search-service/search.service';

@NgModule({
imports: [
Expand All @@ -23,6 +23,9 @@ import { DeleteCollectionPageComponent } from './delete-collection-page/delete-c
EditCollectionPageComponent,
DeleteCollectionPageComponent,
CollectionFormComponent
],
providers: [
SearchService
]
})
export class CollectionPageModule {
Expand Down
@@ -1,4 +1,4 @@
<div class="simple-view-element" [class.d-none]="content.textContent.trim().length === 0">
<div class="simple-view-element" [class.d-none]="content.textContent.trim().length === 0 && hasNoValue(content.querySelector('img'))">
<h5 class="simple-view-element-header" *ngIf="label">{{ label }}</h5>
<div #content class="simple-view-element-body">
<ng-content></ng-content>
Expand Down
@@ -1,26 +1,49 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Component, DebugElement } from '@angular/core';
import { Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.component';

/* tslint:disable:max-classes-per-file */
@Component({
selector: 'ds-component-with-content',
selector: 'ds-component-without-content',
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
' <div class="my-content">\n' +
'</ds-metadata-field-wrapper>'
})
class NoContentComponent {}

@Component({
selector: 'ds-component-with-empty-spans',
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
' <span></span>\n' +
' <span></span>\n' +
' </div>\n' +
'</ds-metadata-field-wrapper>'
})
class ContentComponent {}
class SpanContentComponent {}

@Component({
selector: 'ds-component-with-text',
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
' <span>The quick brown fox jumps over the lazy dog</span>\n' +
'</ds-metadata-field-wrapper>'
})
class TextContentComponent {}

@Component({
selector: 'ds-component-with-image',
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
' <img src="https://some/image.png" alt="an alt text">\n' +
'</ds-metadata-field-wrapper>'
})
class ImgContentComponent {}
/* tslint:enable:max-classes-per-file */

describe('MetadataFieldWrapperComponent', () => {
let component: MetadataFieldWrapperComponent;
let fixture: ComponentFixture<MetadataFieldWrapperComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [MetadataFieldWrapperComponent, ContentComponent]
declarations: [MetadataFieldWrapperComponent, NoContentComponent, SpanContentComponent, TextContentComponent, ImgContentComponent]
}).compileComponents();
}));

Expand All @@ -30,35 +53,40 @@ describe('MetadataFieldWrapperComponent', () => {
});

const wrapperSelector = '.simple-view-element';
const labelSelector = '.simple-view-element-header';
const contentSelector = '.my-content';

it('should create', () => {
expect(component).toBeDefined();
});

it('should not show the component when there is no content', () => {
component.label = 'test label';
fixture.detectChanges();
const parentNative = fixture.nativeElement;
const parentFixture = TestBed.createComponent(NoContentComponent);
parentFixture.detectChanges();
const parentNative = parentFixture.nativeElement;
const nativeWrapper = parentNative.querySelector(wrapperSelector);
expect(nativeWrapper.classList.contains('d-none')).toBe(true);
});

it('should not show the component when there is DOM content but no text', () => {
const parentFixture = TestBed.createComponent(ContentComponent);
it('should not show the component when there is DOM content but not text or an image', () => {
const parentFixture = TestBed.createComponent(SpanContentComponent);
parentFixture.detectChanges();
const parentNative = parentFixture.nativeElement;
const nativeWrapper = parentNative.querySelector(wrapperSelector);
expect(nativeWrapper.classList.contains('d-none')).toBe(true);
});

it('should show the component when there is text content', () => {
const parentFixture = TestBed.createComponent(ContentComponent);
const parentFixture = TestBed.createComponent(TextContentComponent);
parentFixture.detectChanges();
const parentNative = parentFixture.nativeElement;
const nativeWrapper = parentNative.querySelector(wrapperSelector);
parentFixture.detectChanges();
expect(nativeWrapper.classList.contains('d-none')).toBe(false);
});

it('should show the component when there is img content', () => {
const parentFixture = TestBed.createComponent(ImgContentComponent);
parentFixture.detectChanges();
const parentNative = parentFixture.nativeElement;
const nativeContent = parentNative.querySelector(contentSelector);
nativeContent.textContent = 'lorem ipsum';
const nativeWrapper = parentNative.querySelector(wrapperSelector);
parentFixture.detectChanges();
expect(nativeWrapper.classList.contains('d-none')).toBe(false);
Expand Down

0 comments on commit 6f09f97

Please sign in to comment.