mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
added functionality to view a previous version (#5913)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
"RESTORE": "Restore",
|
||||
"DELETE": "Delete",
|
||||
"DOWNLOAD": "Download",
|
||||
"VIEW": "View",
|
||||
"UPLOAD": {
|
||||
"TITLE": "Upload new version",
|
||||
"TOOLTIP": "Restriction: you must upload a file with the same name to create a new version of it",
|
||||
|
@@ -12,6 +12,14 @@
|
||||
<div *ngIf="showActions">
|
||||
<mat-menu [id]="'adf-version-list-action-menu-'+version.entry.id"
|
||||
#versionMenu="matMenu" yPosition="below" xPosition="before">
|
||||
<ng-container *adf-acs-version="'7'">
|
||||
<button *ngIf="allowViewVersions"
|
||||
[id]="'adf-version-list-action-view-'+version.entry.id"
|
||||
mat-menu-item
|
||||
(click)="onViewVersion(version.entry.id)">
|
||||
{{ 'ADF_VERSION_LIST.ACTIONS.VIEW' | translate }}
|
||||
</button>
|
||||
</ng-container>
|
||||
<button
|
||||
[id]="'adf-version-list-action-restore-'+version.entry.id"
|
||||
[disabled]="!canUpdate()"
|
||||
|
@@ -228,6 +228,13 @@ describe('VersionListComponent', () => {
|
||||
expect(alfrescoApiService.contentApi.getContentUrl).toHaveBeenCalledWith(nodeId, true);
|
||||
});
|
||||
|
||||
it('should be able to view a version', () => {
|
||||
spyOn(component.viewVersion, 'emit');
|
||||
component.onViewVersion('1.0');
|
||||
fixture.detectChanges();
|
||||
expect(component.viewVersion.emit).toHaveBeenCalledWith('1.0');
|
||||
});
|
||||
|
||||
it('should NOT be able to download a version if configured so', () => {
|
||||
const versionEntry = {
|
||||
entry: {
|
||||
|
@@ -48,6 +48,10 @@ export class VersionListComponent implements OnChanges {
|
||||
@Input()
|
||||
allowDownload = true;
|
||||
|
||||
/** Enable/disable viewing a version of the current node. */
|
||||
@Input()
|
||||
allowViewVersions = true;
|
||||
|
||||
/** Toggles showing/hiding of version actions */
|
||||
@Input()
|
||||
showActions = true;
|
||||
@@ -60,6 +64,10 @@ export class VersionListComponent implements OnChanges {
|
||||
@Output()
|
||||
deleted: EventEmitter<Node> = new EventEmitter<Node>();
|
||||
|
||||
/** Emitted when viewing a version */
|
||||
@Output()
|
||||
viewVersion: EventEmitter<string> = new EventEmitter<string>();
|
||||
|
||||
constructor(private alfrescoApi: AlfrescoApiService,
|
||||
private contentService: ContentService,
|
||||
private dialog: MatDialog) {
|
||||
@@ -92,6 +100,10 @@ export class VersionListComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
onViewVersion(versionId) {
|
||||
this.viewVersion.emit(versionId);
|
||||
}
|
||||
|
||||
loadVersionHistory() {
|
||||
this.isLoading = true;
|
||||
this.versionsApi.listVersionHistory(this.node.id).then((versionPaging: VersionPaging) => {
|
||||
|
@@ -38,7 +38,8 @@
|
||||
[allowDownload]="allowDownload"
|
||||
[showComments]="showComments"
|
||||
(deleted)="refresh($event)"
|
||||
(restored)="refresh($event)">
|
||||
(restored)="refresh($event)"
|
||||
(viewVersion)="onViewVersion($event)">
|
||||
</adf-version-list>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -73,6 +73,13 @@ describe('VersionManagerComponent', () => {
|
||||
expect(component.uploadState).toBe('open');
|
||||
});
|
||||
|
||||
it('should be able to view a version', () => {
|
||||
spyOn(component.viewVersion, 'emit');
|
||||
component.onViewVersion('1.0');
|
||||
fixture.detectChanges();
|
||||
expect(component.viewVersion.emit).toHaveBeenCalledWith('1.0');
|
||||
});
|
||||
|
||||
it('should display comments for versions when not configured otherwise', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
|
@@ -75,6 +75,10 @@ export class VersionManagerComponent implements OnInit {
|
||||
@Output()
|
||||
uploadCancel: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
|
||||
/** Emitted when viewing a version. */
|
||||
@Output()
|
||||
viewVersion: EventEmitter<string> = new EventEmitter<string>();
|
||||
|
||||
@ViewChild('versionList', { static: true })
|
||||
versionListComponent: VersionListComponent;
|
||||
|
||||
@@ -117,6 +121,10 @@ export class VersionManagerComponent implements OnInit {
|
||||
this.uploadCancel.emit(true);
|
||||
}
|
||||
|
||||
onViewVersion(versionId: string) {
|
||||
this.viewVersion.emit(versionId);
|
||||
}
|
||||
|
||||
toggleNewVersion() {
|
||||
this.uploadState = this.uploadState === 'open' ? 'close' : 'open';
|
||||
}
|
||||
|
Reference in New Issue
Block a user