mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +00:00
small UI tweaks, fix tests
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
[index]="index"
|
||||
[linkType]="linkType"
|
||||
[listID]="listID">
|
||||
<div class="card-footer text-center">
|
||||
<a class="btn btn-light btn-sm btn-auto my-1" [routerLink]="[getEditPath()]">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item text-center">
|
||||
<a class="btn btn-light btn-sm btn-auto my-1 edit-link" [routerLink]="[editPath]">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ds-collection-search-result-grid-element>
|
||||
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { mockTruncatableService } from '../../../mocks/mock-trucatable.service';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { CollectionAdminSearchResultGridElementComponent } from './collection-admin-search-result-grid-element.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
@@ -12,7 +16,7 @@ import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
||||
|
||||
describe('CollectionAdminSearchResultListElementComponent', () => {
|
||||
describe('CollectionAdminSearchResultGridElementComponent', () => {
|
||||
let component: CollectionAdminSearchResultGridElementComponent;
|
||||
let fixture: ComponentFixture<CollectionAdminSearchResultGridElementComponent>;
|
||||
let id;
|
||||
@@ -28,12 +32,15 @@ describe('CollectionAdminSearchResultListElementComponent', () => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
RouterTestingModule.withRoutes([])
|
||||
RouterTestingModule.withRoutes([]),
|
||||
SharedModule
|
||||
],
|
||||
declarations: [CollectionAdminSearchResultGridElementComponent],
|
||||
providers: [{ provide: TruncatableService, useValue: {} }],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||
{ provide: BitstreamDataService, useValue: {} },
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
@@ -53,7 +60,7 @@ describe('CollectionAdminSearchResultListElementComponent', () => {
|
||||
});
|
||||
|
||||
it('should render an edit button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a'));
|
||||
const a = fixture.debugElement.query(By.css('a.edit-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(getCollectionEditPath(id));
|
||||
})
|
||||
|
@@ -17,11 +17,10 @@ import { SearchResultGridElementComponent } from '../../search-result-grid-eleme
|
||||
* The component for displaying a list element for a collection search result on the admin search page
|
||||
*/
|
||||
export class CollectionAdminSearchResultGridElementComponent extends SearchResultGridElementComponent<CollectionSearchResult, Collection> {
|
||||
editPath: string;
|
||||
|
||||
/**
|
||||
* Returns the path to the edit page of this collection
|
||||
*/
|
||||
getEditPath(): string {
|
||||
return getCollectionEditPath(this.dso.uuid)
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.editPath = getCollectionEditPath(this.dso.uuid);
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,12 @@
|
||||
[index]="index"
|
||||
[linkType]="linkType"
|
||||
[listID]="listID">
|
||||
<div class="card-footer text-center">
|
||||
<a class="btn btn-light btn-sm btn-auto my-1" [routerLink]="[getEditPath()]">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item text-center">
|
||||
<a class="btn btn-light btn-sm btn-auto my-1 edit-link" [routerLink]="[editPath]">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ds-community-search-result-grid-element>
|
||||
|
||||
|
@@ -1,7 +1,11 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { mockTruncatableService } from '../../../mocks/mock-trucatable.service';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
@@ -12,7 +16,7 @@ import { CommunityAdminSearchResultGridElementComponent } from './community-admi
|
||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
||||
|
||||
describe('CommunityAdminSearchResultListElementComponent', () => {
|
||||
describe('CommunityAdminSearchResultGridElementComponent', () => {
|
||||
let component: CommunityAdminSearchResultGridElementComponent;
|
||||
let fixture: ComponentFixture<CommunityAdminSearchResultGridElementComponent>;
|
||||
let id;
|
||||
@@ -28,11 +32,15 @@ describe('CommunityAdminSearchResultListElementComponent', () => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
RouterTestingModule.withRoutes([])
|
||||
RouterTestingModule.withRoutes([]),
|
||||
SharedModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||
{ provide: BitstreamDataService, useValue: {} },
|
||||
],
|
||||
declarations: [CommunityAdminSearchResultGridElementComponent],
|
||||
providers: [{ provide: TruncatableService, useValue: {} }],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
@@ -53,7 +61,7 @@ describe('CommunityAdminSearchResultListElementComponent', () => {
|
||||
});
|
||||
|
||||
it('should render an edit button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a'));
|
||||
const a = fixture.debugElement.query(By.css('a.edit-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(getCommunityEditPath(id));
|
||||
})
|
||||
|
@@ -17,11 +17,10 @@ import { SearchResultGridElementComponent } from '../../search-result-grid-eleme
|
||||
* The component for displaying a list element for a community search result on the admin search page
|
||||
*/
|
||||
export class CommunityAdminSearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult, Community> {
|
||||
editPath: string;
|
||||
|
||||
/**
|
||||
* Returns the path to the edit page of this community
|
||||
*/
|
||||
getEditPath(): string {
|
||||
return getCommunityEditPath(this.dso.uuid)
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.editPath = getCommunityEditPath(this.dso.uuid);
|
||||
}
|
||||
}
|
||||
|
@@ -8,32 +8,34 @@
|
||||
<span class="badge badge-warning">{{ "admin.search.item.withdrawn" | translate }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div #buttons class="card-footer d-flex justify-content-between">
|
||||
<ul #buttons class="list-group list-group-flush">
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<a class="btn btn-light btn-sm my-1 edit-link" [routerLink]="[getEditPath()]" [title]="'admin.search.item.edit' | translate">
|
||||
<i class="fa fa-edit"></i>
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<a *ngIf="dso && !dso.isWithdrawn" class="btn btn-light btn-sm my-1 withdraw-link" [routerLink]="[getWithdrawPath()]" [title]="'admin.search.item.withdraw' | translate">
|
||||
<i class="fa fa-box"></i>
|
||||
<i class="fa fa-ban"></i>
|
||||
</a>
|
||||
|
||||
<a *ngIf="dso && dso.isWithdrawn" class="btn btn-light btn-sm my-1 reinstate-link" [routerLink]="[getReinstatePath()]" [title]="'admin.search.item.reinstate' | translate">
|
||||
<i class="fa fa-box-open"></i>
|
||||
<i class="fa fa-undo"></i>
|
||||
</a>
|
||||
|
||||
<a *ngIf="dso && dso.isDiscoverable" class="btn btn-light btn-sm my-1 private-link" [routerLink]="[getPrivatePath()]" [title]="'admin.search.item.make-private' | translate">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</a>
|
||||
|
||||
<a *ngIf="dso && !dso.isDiscoverable" class="btn btn-light btn-sm my-1 public-link" [routerLink]="[getPublicPath()]" [title]="'admin.search.item.make-public' | translate">
|
||||
<i class="fa fa-eye"></i>
|
||||
<i class="fa fa-eye"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-light btn-sm my-1 delete-link" [routerLink]="[getDeletePath()]" [title]="'admin.search.item.delete' | translate">
|
||||
<i class="fa fa-trash"></i>
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-light btn-sm my-1 move-link" [routerLink]="[getMovePath()]" [title]="'admin.search.item.move' | translate">
|
||||
<i class="fa fa-arrow-circle-right"></i>
|
||||
<i class="fa fa-arrow-circle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
@@ -1,7 +1,16 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { mockTruncatableService } from '../../../mocks/mock-trucatable.service';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../testing/utils';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
@@ -20,6 +29,12 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
let id;
|
||||
let searchResult;
|
||||
|
||||
const mockBitstreamDataService = {
|
||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||
}
|
||||
};
|
||||
|
||||
function init() {
|
||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||
searchResult = new ItemSearchResult();
|
||||
@@ -30,11 +45,15 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
RouterTestingModule.withRoutes([])
|
||||
RouterTestingModule.withRoutes([]),
|
||||
SharedModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
],
|
||||
declarations: [ItemAdminSearchResultGridElementComponent],
|
||||
providers: [{ provide: TruncatableService, useValue: {} }],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
|
@@ -6,6 +6,7 @@ import { Store } from '@ngrx/store';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||
import { DefaultChangeAnalyzer } from '../../../../core/data/default-change-analyzer.service';
|
||||
import { DSOChangeAnalyzer } from '../../../../core/data/dso-change-analyzer.service';
|
||||
@@ -62,6 +63,7 @@ describe('CollectionSearchResultGridElementComponent', () => {
|
||||
{ provide: UUIDService, useValue: {} },
|
||||
{ provide: Store, useValue: {} },
|
||||
{ provide: RemoteDataBuildService, useValue: {} },
|
||||
{ provide: BitstreamDataService, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {} },
|
||||
{ provide: HALEndpointService, useValue: {} },
|
||||
{ provide: NotificationsService, useValue: {} },
|
||||
|
@@ -6,6 +6,7 @@ import { Store } from '@ngrx/store';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||
import { DefaultChangeAnalyzer } from '../../../../core/data/default-change-analyzer.service';
|
||||
import { DSOChangeAnalyzer } from '../../../../core/data/dso-change-analyzer.service';
|
||||
@@ -62,6 +63,7 @@ describe('CommunitySearchResultGridElementComponent', () => {
|
||||
{ provide: UUIDService, useValue: {} },
|
||||
{ provide: Store, useValue: {} },
|
||||
{ provide: RemoteDataBuildService, useValue: {} },
|
||||
{ provide: BitstreamDataService, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {} },
|
||||
{ provide: HALEndpointService, useValue: {} },
|
||||
{ provide: NotificationsService, useValue: {} },
|
||||
|
@@ -1,43 +1,44 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<ng-content></ng-content>
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])"
|
||||
class="item-authors card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.hasMetadata('dc.date.issued')" class="item-date">{{firstMetadataValue('dc.date.issued')}}</span>
|
||||
<span *ngFor="let author of allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
||||
<span [innerHTML]="author"></span>
|
||||
</span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<p *ngIf="dso.hasMetadata('dc.description.abstract')" class="item-abstract card-text">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</ds-truncatable>
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<ng-content></ng-content>
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])"
|
||||
class="item-authors card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.hasMetadata('dc.date.issued')" class="item-date">{{firstMetadataValue('dc.date.issued')}}</span>
|
||||
<span *ngFor="let author of allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
||||
<span [innerHTML]="author"></span>
|
||||
</span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<p *ngIf="dso.hasMetadata('dc.description.abstract')" class="item-abstract card-text">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
</ds-truncatable>
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user