Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,024 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/app/+item-page/edit-item-page/item-version-history/item-version-history.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="mt-4"> | ||
<ds-alert [content]="'item.edit.tabs.versionhistory.under-construction'" [type]="AlertTypeEnum.Warning"></ds-alert> | ||
</div> | ||
<div class="mt-2" *ngVar="(itemRD$ | async)?.payload as item"> | ||
<ds-item-versions *ngIf="item" [item]="item" [displayWhenEmpty]="true" [displayTitle]="false"></ds-item-versions> | ||
</div> |
44 changes: 44 additions & 0 deletions
44
...app/+item-page/edit-item-page/item-version-history/item-version-history.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ItemVersionHistoryComponent } from './item-version-history.component'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { VarDirective } from '../../../shared/utils/var.directive'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { Item } from '../../../core/shared/item.model'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { of as observableOf } from 'rxjs'; | ||
import { createSuccessfulRemoteDataObject } from '../../../shared/testing/utils'; | ||
|
||
describe('ItemVersionHistoryComponent', () => { | ||
let component: ItemVersionHistoryComponent; | ||
let fixture: ComponentFixture<ItemVersionHistoryComponent>; | ||
|
||
const item = Object.assign(new Item(), { | ||
uuid: 'item-identifier-1', | ||
handle: '123456789/1', | ||
}); | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ItemVersionHistoryComponent, VarDirective], | ||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], | ||
providers: [ | ||
{ provide: ActivatedRoute, useValue: { parent: { data: observableOf({ item: createSuccessfulRemoteDataObject(item) }) } } } | ||
], | ||
schemas: [NO_ERRORS_SCHEMA] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ItemVersionHistoryComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should initialize the itemRD$ from the route\'s data', (done) => { | ||
component.itemRD$.subscribe((itemRD) => { | ||
expect(itemRD.payload).toBe(item); | ||
done(); | ||
}); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
src/app/+item-page/edit-item-page/item-version-history/item-version-history.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component } from '@angular/core'; | ||
import { Observable } from 'rxjs/internal/Observable'; | ||
import { RemoteData } from '../../../core/data/remote-data'; | ||
import { Item } from '../../../core/shared/item.model'; | ||
import { map } from 'rxjs/operators'; | ||
import { getSucceededRemoteData } from '../../../core/shared/operators'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { AlertType } from '../../../shared/alert/aletr-type'; | ||
|
||
@Component({ | ||
selector: 'ds-item-version-history', | ||
templateUrl: './item-version-history.component.html' | ||
}) | ||
/** | ||
* Component for listing and managing an item's version history | ||
*/ | ||
export class ItemVersionHistoryComponent { | ||
/** | ||
* The item to display the version history for | ||
*/ | ||
itemRD$: Observable<RemoteData<Item>>; | ||
|
||
/** | ||
* The AlertType enumeration | ||
* @type {AlertType} | ||
*/ | ||
AlertTypeEnum = AlertType; | ||
|
||
constructor(private route: ActivatedRoute) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.itemRD$ = this.route.parent.data.pipe(map((data) => data.item)).pipe(getSucceededRemoteData()) as Observable<RemoteData<Item>>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { DataService } from './data.service'; | ||
import { Version } from '../shared/version.model'; | ||
import { RequestService } from './request.service'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { Store } from '@ngrx/store'; | ||
import { CoreState } from '../core.reducers'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service'; | ||
import { FindListOptions } from './request.models'; | ||
import { Observable } from 'rxjs/internal/Observable'; | ||
import { dataService } from '../cache/builders/build-decorators'; | ||
import { VERSION } from '../shared/version.resource-type'; | ||
|
||
/** | ||
* Service responsible for handling requests related to the Version object | ||
*/ | ||
@Injectable() | ||
@dataService(VERSION) | ||
export class VersionDataService extends DataService<Version> { | ||
protected linkPath = 'versions'; | ||
|
||
constructor( | ||
protected requestService: RequestService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected store: Store<CoreState>, | ||
protected objectCache: ObjectCacheService, | ||
protected halService: HALEndpointService, | ||
protected notificationsService: NotificationsService, | ||
protected http: HttpClient, | ||
protected comparator: DefaultChangeAnalyzer<Version>) { | ||
super(); | ||
} | ||
|
||
/** | ||
* Get the endpoint for browsing versions | ||
*/ | ||
getBrowseEndpoint(options: FindListOptions = {}, linkPath?: string): Observable<string> { | ||
return this.halService.getEndpoint(this.linkPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { RequestService } from './request.service'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { VersionHistoryDataService } from './version-history-data.service'; | ||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub'; | ||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; | ||
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; | ||
import { GetRequest } from './request.models'; | ||
|
||
const url = 'fake-url'; | ||
|
||
describe('VersionHistoryDataService', () => { | ||
let service: VersionHistoryDataService; | ||
|
||
let requestService: RequestService; | ||
let notificationsService: any; | ||
let rdbService: RemoteDataBuildService; | ||
let objectCache: ObjectCacheService; | ||
let halService: any; | ||
|
||
beforeEach(() => { | ||
createService(); | ||
}); | ||
|
||
describe('getVersions', () => { | ||
let result; | ||
|
||
beforeEach(() => { | ||
result = service.getVersions('1'); | ||
}); | ||
|
||
it('should configure a GET request', () => { | ||
expect(requestService.configure).toHaveBeenCalledWith(jasmine.any(GetRequest)); | ||
}); | ||
}); | ||
|
||
/** | ||
* Create a VersionHistoryDataService used for testing | ||
* @param requestEntry$ Supply a requestEntry to be returned by the REST API (optional) | ||
*/ | ||
function createService(requestEntry$?) { | ||
requestService = getMockRequestService(requestEntry$); | ||
rdbService = jasmine.createSpyObj('rdbService', { | ||
buildList: jasmine.createSpy('buildList') | ||
}); | ||
objectCache = jasmine.createSpyObj('objectCache', { | ||
remove: jasmine.createSpy('remove') | ||
}); | ||
halService = new HALEndpointServiceStub(url); | ||
notificationsService = new NotificationsServiceStub(); | ||
|
||
service = new VersionHistoryDataService(requestService, rdbService, null, objectCache, halService, notificationsService, null, null); | ||
} | ||
}); |
Oops, something went wrong.