mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2672] version manager fixes (#3169)
* fix app config, add extra flags for version manager * add docs and tests * update i18n strings * rename "id" to "nodeId" * automatically detect permissions * restore 'id' and mark as deprecated
This commit is contained in:
committed by
Eugenio Romano
parent
8b4af90b46
commit
aba9f41af1
@@ -487,7 +487,6 @@
|
|||||||
},
|
},
|
||||||
"adf-version-manager": {
|
"adf-version-manager": {
|
||||||
"allowComments": true,
|
"allowComments": true,
|
||||||
"allowDownload": true,
|
"allowDownload": true
|
||||||
"allowDelete": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -361,8 +361,7 @@
|
|||||||
<adf-version-manager
|
<adf-version-manager
|
||||||
[node]="documentList.selection[0].entry"
|
[node]="documentList.selection[0].entry"
|
||||||
[showComments]="showVersionComments"
|
[showComments]="showVersionComments"
|
||||||
[allowDownload]="allowVersionDownload"
|
[allowDownload]="allowVersionDownload">
|
||||||
[allowDelete]="allowVersionDelete">
|
|
||||||
</adf-version-manager>
|
</adf-version-manager>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -460,12 +459,6 @@
|
|||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
|
||||||
<mat-slide-toggle color="primary" [(ngModel)]="allowVersionDelete">
|
|
||||||
{{'APP.ADF_VERSION_MANAGER.ALLOW_DELETE' | translate}}
|
|
||||||
</mat-slide-toggle>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<h5>Upload</h5>
|
<h5>Upload</h5>
|
||||||
<section *ngIf="acceptedFilesTypeShow">
|
<section *ngIf="acceptedFilesTypeShow">
|
||||||
<mat-form-field floatPlaceholder="float">
|
<mat-form-field floatPlaceholder="float">
|
||||||
|
@@ -105,9 +105,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
allowVersionDownload = true;
|
allowVersionDownload = true;
|
||||||
|
|
||||||
@Input()
|
|
||||||
allowVersionDelete = true;
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
acceptedFilesType = '.jpg,.pdf,.js';
|
acceptedFilesType = '.jpg,.pdf,.js';
|
||||||
|
|
||||||
|
@@ -27,11 +27,11 @@ export class DebugAppConfigService extends AppConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
get<T>(key: string): T {
|
get<T>(key: string, defaultValue?: T): T {
|
||||||
if (key === 'ecmHost' || key === 'bpmHost') {
|
if (key === 'ecmHost' || key === 'bpmHost') {
|
||||||
return <T> (<any> this.storage.getItem(key) || super.get<T>(key));
|
return <T> (<any> this.storage.getItem(key) || super.get<T>(key));
|
||||||
}
|
}
|
||||||
return super.get<T>(key);
|
return super.get<T>(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,18 @@ Displays the version history of a node in a Version Manager component
|
|||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| ---- | ---- | ------------- | ----------- |
|
| ---- | ---- | ------------- | ----------- |
|
||||||
| id | `string` | | ID of the node whose version history you want to display. |
|
| node | `MinimalNodeEntryEntity` | | Node whose version history you want to display. |
|
||||||
| showComments | `boolean` | true | Set this to false if version comments should not be displayed. |
|
| showComments | `boolean` | true | Set this to false if version comments should not be displayed. |
|
||||||
| allowDownload | `boolean` | true | Toggles downloads of previous versions. Set this to false to not show the menu item for version download. |
|
| allowDownload | `boolean` | true | Toggles downloads of previous versions. Set this to false to not show the menu item for version download. |
|
||||||
| allowDelete | `boolean` | true | Toggles the version delete feature. |
|
|
||||||
|
### DOM events
|
||||||
|
|
||||||
|
All DOM events are bubbling and can be handled in the parent components up to the root application component.
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| version-deleted | Raised after a version is deleted. |
|
||||||
|
| version-restored | Raised after a version is restored. |
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ Displays the version history of a node with the ability to upload a new version.
|
|||||||
| ---- | ---- | --- | ----------- |
|
| ---- | ---- | --- | ----------- |
|
||||||
| node | [MinimalNodeEntryEntity](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) | |The node you want to manage the version history of. |
|
| node | [MinimalNodeEntryEntity](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) | |The node you want to manage the version history of. |
|
||||||
| showComments | `boolean` | true | Set this to false if version comments should not be displayed. |
|
| showComments | `boolean` | true | Set this to false if version comments should not be displayed. |
|
||||||
| enableDownload | `boolean` | true | Configuration to enable/disable downloads of previous versions. Set this to false to not show the menu item for version download. |
|
| allowDownload | `boolean` | true | Toggles downloads of previous versions. Set this to false to not show the menu item for version download. |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
},
|
},
|
||||||
"CONFIRM_DELETE": {
|
"CONFIRM_DELETE": {
|
||||||
"TITLE": "Delete version",
|
"TITLE": "Delete version",
|
||||||
"MESSAGE": "Deleted file versions can not be restored. Delete?",
|
"MESSAGE": "Deleted file versions can not be restored.",
|
||||||
"YES_LABEL": "Yes",
|
"YES_LABEL": "DELETE",
|
||||||
"NO_LABEL": "No"
|
"NO_LABEL": "KEEP"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ADF_CONFIRM_DIALOG": {
|
"ADF_CONFIRM_DIALOG": {
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<p mat-line class="adf-version-list-item-comment" *ngIf="showComments">{{version.entry.versionComment}}</p>
|
<p mat-line class="adf-version-list-item-comment" *ngIf="showComments">{{version.entry.versionComment}}</p>
|
||||||
|
|
||||||
<mat-menu #versionMenu="matMenu" yPosition="below" xPosition="before">
|
<mat-menu #versionMenu="matMenu" yPosition="below" xPosition="before">
|
||||||
<button
|
<button *ngIf="canUpdate()"
|
||||||
mat-menu-item
|
mat-menu-item
|
||||||
(click)="restore(version.entry.id)">
|
(click)="restore(version.entry.id)">
|
||||||
{{ 'ADF_VERSION_LIST.ACTIONS.RESTORE' | translate }}
|
{{ 'ADF_VERSION_LIST.ACTIONS.RESTORE' | translate }}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
(click)="downloadVersion(version.entry.id)">
|
(click)="downloadVersion(version.entry.id)">
|
||||||
{{ 'ADF_VERSION_LIST.ACTIONS.DOWNLOAD' | translate }}
|
{{ 'ADF_VERSION_LIST.ACTIONS.DOWNLOAD' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button *ngIf="allowDelete"
|
<button *ngIf="canUpdate()"
|
||||||
(click)="deleteVersion(version.entry.id)"
|
(click)="deleteVersion(version.entry.id)"
|
||||||
mat-menu-item>
|
mat-menu-item>
|
||||||
{{ 'ADF_VERSION_LIST.ACTIONS.DELETE' | translate }}
|
{{ 'ADF_VERSION_LIST.ACTIONS.DELETE' | translate }}
|
||||||
|
@@ -52,7 +52,7 @@ describe('VersionListComponent', () => {
|
|||||||
dialog = TestBed.get(MatDialog);
|
dialog = TestBed.get(MatDialog);
|
||||||
|
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.id = nodeId;
|
component.node = { id: nodeId, allowableOperations: [ 'update' ] };
|
||||||
|
|
||||||
spyOn(component, 'downloadContent').and.stub();
|
spyOn(component, 'downloadContent').and.stub();
|
||||||
});
|
});
|
||||||
@@ -64,7 +64,6 @@ describe('VersionListComponent', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
component.allowDelete = true;
|
|
||||||
component.deleteVersion('1');
|
component.deleteVersion('1');
|
||||||
|
|
||||||
expect(dialog.open).toHaveBeenCalled();
|
expect(dialog.open).toHaveBeenCalled();
|
||||||
@@ -79,12 +78,10 @@ describe('VersionListComponent', () => {
|
|||||||
|
|
||||||
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
component.id = '0';
|
component.deleteVersion(versionId);
|
||||||
component.allowDelete = true;
|
|
||||||
component.deleteVersion('1');
|
|
||||||
|
|
||||||
expect(dialog.open).toHaveBeenCalled();
|
expect(dialog.open).toHaveBeenCalled();
|
||||||
expect(alfrescoApiService.versionsApi.deleteVersion).toHaveBeenCalledWith('0', '1');
|
expect(alfrescoApiService.versionsApi.deleteVersion).toHaveBeenCalledWith(nodeId, versionId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not delete version if user rejects', () => {
|
it('should not delete version if user rejects', () => {
|
||||||
@@ -96,9 +93,7 @@ describe('VersionListComponent', () => {
|
|||||||
|
|
||||||
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
component.id = '0';
|
component.deleteVersion(versionId);
|
||||||
component.allowDelete = true;
|
|
||||||
component.deleteVersion('1');
|
|
||||||
|
|
||||||
expect(dialog.open).toHaveBeenCalled();
|
expect(dialog.open).toHaveBeenCalled();
|
||||||
expect(alfrescoApiService.versionsApi.deleteVersion).not.toHaveBeenCalled();
|
expect(alfrescoApiService.versionsApi.deleteVersion).not.toHaveBeenCalled();
|
||||||
@@ -115,15 +110,23 @@ describe('VersionListComponent', () => {
|
|||||||
|
|
||||||
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
component.id = '0';
|
component.deleteVersion(versionId);
|
||||||
component.allowDelete = true;
|
|
||||||
component.deleteVersion('1');
|
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(component.loadVersionHistory).toHaveBeenCalled();
|
expect(component.loadVersionHistory).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should reload and raise version-deleted DOM event', (done) => {
|
||||||
|
spyOn(component, 'loadVersionHistory').and.stub();
|
||||||
|
fixture.nativeElement.addEventListener('version-deleted', () => {
|
||||||
|
expect(component.loadVersionHistory).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.onVersionDeleted();
|
||||||
|
});
|
||||||
|
|
||||||
describe('Version history fetching', () => {
|
describe('Version history fetching', () => {
|
||||||
|
|
||||||
it('should use loading bar', () => {
|
it('should use loading bar', () => {
|
||||||
@@ -231,6 +234,23 @@ describe('VersionListComponent', () => {
|
|||||||
|
|
||||||
describe('Version restoring', () => {
|
describe('Version restoring', () => {
|
||||||
|
|
||||||
|
it('should reload and raise version-restored DOM event', (done) => {
|
||||||
|
spyOn(component, 'loadVersionHistory').and.stub();
|
||||||
|
fixture.nativeElement.addEventListener('version-restored', () => {
|
||||||
|
expect(component.loadVersionHistory).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.onVersionRestored();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should restore version only when restore allowed', () => {
|
||||||
|
component.node.allowableOperations = [];
|
||||||
|
spyOn(alfrescoApiService.versionsApi, 'revertVersion').and.stub();
|
||||||
|
component.restore('1');
|
||||||
|
expect(alfrescoApiService.versionsApi.revertVersion).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('should load the versions for a given id', () => {
|
it('should load the versions for a given id', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(alfrescoApiService.versionsApi, 'listVersionHistory').and
|
spyOn(alfrescoApiService.versionsApi, 'listVersionHistory').and
|
||||||
|
@@ -15,9 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, ContentService } from '@alfresco/adf-core';
|
||||||
import { Component, Input, OnChanges, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnChanges, ViewEncapsulation, ElementRef } from '@angular/core';
|
||||||
import { VersionsApi } from 'alfresco-js-api';
|
import { VersionsApi, MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
|
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
|
||||||
|
|
||||||
@@ -36,10 +36,13 @@ export class VersionListComponent implements OnChanges {
|
|||||||
versions: any = [];
|
versions: any = [];
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
|
||||||
/** ID of the node whose version history you want to display. */
|
/** @deprecated in 2.3.0 */
|
||||||
@Input()
|
@Input()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
node: MinimalNodeEntryEntity;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showComments = true;
|
showComments = true;
|
||||||
|
|
||||||
@@ -47,11 +50,11 @@ export class VersionListComponent implements OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
allowDownload = true;
|
allowDownload = true;
|
||||||
|
|
||||||
/** Toggle version deletion feature. */
|
constructor(
|
||||||
@Input()
|
private alfrescoApi: AlfrescoApiService,
|
||||||
allowDelete = true;
|
private contentService: ContentService,
|
||||||
|
private dialog: MatDialog,
|
||||||
constructor(private alfrescoApi: AlfrescoApiService, private dialog: MatDialog) {
|
private el: ElementRef) {
|
||||||
this.versionsApi = this.alfrescoApi.versionsApi;
|
this.versionsApi = this.alfrescoApi.versionsApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,15 +62,21 @@ export class VersionListComponent implements OnChanges {
|
|||||||
this.loadVersionHistory();
|
this.loadVersionHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canUpdate(): boolean {
|
||||||
|
return this.contentService.hasPermission(this.node, 'update');
|
||||||
|
}
|
||||||
|
|
||||||
restore(versionId) {
|
restore(versionId) {
|
||||||
this.versionsApi
|
if (this.canUpdate()) {
|
||||||
.revertVersion(this.id, versionId, { majorVersion: true, comment: ''})
|
this.versionsApi
|
||||||
.then(this.loadVersionHistory.bind(this));
|
.revertVersion(this.node.id, versionId, { majorVersion: true, comment: ''})
|
||||||
|
.then(() => this.onVersionRestored());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadVersionHistory() {
|
loadVersionHistory() {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.versionsApi.listVersionHistory(this.id).then((data) => {
|
this.versionsApi.listVersionHistory(this.node.id).then((data) => {
|
||||||
this.versions = data.list.entries;
|
this.versions = data.list.entries;
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
});
|
});
|
||||||
@@ -75,13 +84,13 @@ export class VersionListComponent implements OnChanges {
|
|||||||
|
|
||||||
downloadVersion(versionId: string) {
|
downloadVersion(versionId: string) {
|
||||||
if (this.allowDownload) {
|
if (this.allowDownload) {
|
||||||
const versionDownloadUrl = this.getVersionContentUrl(this.id, versionId, true);
|
const versionDownloadUrl = this.getVersionContentUrl(this.node.id, versionId, true);
|
||||||
this.downloadContent(versionDownloadUrl);
|
this.downloadContent(versionDownloadUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteVersion(versionId: string) {
|
deleteVersion(versionId: string) {
|
||||||
if (this.allowDelete) {
|
if (this.canUpdate()) {
|
||||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
title: 'ADF_VERSION_LIST.CONFIRM_DELETE.TITLE',
|
title: 'ADF_VERSION_LIST.CONFIRM_DELETE.TITLE',
|
||||||
@@ -95,15 +104,27 @@ export class VersionListComponent implements OnChanges {
|
|||||||
dialogRef.afterClosed().subscribe(result => {
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
this.alfrescoApi.versionsApi
|
this.alfrescoApi.versionsApi
|
||||||
.deleteVersion(this.id, versionId)
|
.deleteVersion(this.node.id, versionId)
|
||||||
.then(() => {
|
.then(() => this.onVersionDeleted());
|
||||||
this.loadVersionHistory();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onVersionDeleted() {
|
||||||
|
this.loadVersionHistory();
|
||||||
|
|
||||||
|
const event = new CustomEvent('version-deleted', { bubbles: true });
|
||||||
|
this.el.nativeElement.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
onVersionRestored() {
|
||||||
|
this.loadVersionHistory();
|
||||||
|
|
||||||
|
const event = new CustomEvent('version-restored', { bubbles: true });
|
||||||
|
this.el.nativeElement.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
private getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean) {
|
private getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean) {
|
||||||
const nodeDownloadUrl = this.alfrescoApi.contentApi.getContentUrl(nodeId, attachment);
|
const nodeDownloadUrl = this.alfrescoApi.contentApi.getContentUrl(nodeId, attachment);
|
||||||
return nodeDownloadUrl.replace('/content', '/versions/' + versionId + '/content');
|
return nodeDownloadUrl.replace('/content', '/versions/' + versionId + '/content');
|
||||||
|
@@ -1,11 +1,15 @@
|
|||||||
<div class="adf-new-version-uploader-container" fxLayout="row" fxLayoutAlign="end center">
|
<div class="adf-new-version-uploader-container" fxLayout="row" fxLayoutAlign="end center">
|
||||||
<adf-version-upload [node]="node" (success)="onUploadSuccess($event)" (error)="onUploadError($event)"></adf-version-upload>
|
<adf-version-upload
|
||||||
|
[node]="node"
|
||||||
|
(success)="onUploadSuccess($event)"
|
||||||
|
(error)="uploadError.emit($event)">
|
||||||
|
</adf-version-upload>
|
||||||
</div>
|
</div>
|
||||||
<div class="adf-version-list-container">
|
<div class="adf-version-list-container">
|
||||||
<adf-version-list
|
<adf-version-list
|
||||||
#versionList [id]="node.id"
|
#versionList
|
||||||
|
[node]="node"
|
||||||
[allowDownload]="allowDownload"
|
[allowDownload]="allowDownload"
|
||||||
[showComments]="showComments"
|
[showComments]="showComments">
|
||||||
[allowDelete]="allowDelete">
|
|
||||||
</adf-version-list>
|
</adf-version-list>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -98,14 +98,4 @@ describe('VersionManagerComponent', () => {
|
|||||||
});
|
});
|
||||||
component.onUploadSuccess(emittedData);
|
component.onUploadSuccess(emittedData);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit error event upon failure to upload a new version', () => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
const errorEvent = new CustomEvent('error');
|
|
||||||
component.uploadError.subscribe(event => {
|
|
||||||
expect(event).toBe(errorEvent);
|
|
||||||
});
|
|
||||||
component.onUploadError(errorEvent);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { Component, Input, ViewEncapsulation, ViewChild, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, ViewEncapsulation, ViewChild, Output, EventEmitter } from '@angular/core';
|
||||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||||
import { VersionListComponent } from './version-list.component';
|
import { VersionListComponent } from './version-list.component';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
import { AppConfigService, ContentService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-version-manager',
|
selector: 'adf-version-manager',
|
||||||
@@ -31,9 +31,6 @@ export class VersionManagerComponent {
|
|||||||
@Input()
|
@Input()
|
||||||
node: MinimalNodeEntryEntity;
|
node: MinimalNodeEntryEntity;
|
||||||
|
|
||||||
@Input()
|
|
||||||
allowDelete = true;
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showComments = true;
|
showComments = true;
|
||||||
|
|
||||||
@@ -49,8 +46,9 @@ export class VersionManagerComponent {
|
|||||||
@ViewChild('versionList')
|
@ViewChild('versionList')
|
||||||
versionListComponent: VersionListComponent;
|
versionListComponent: VersionListComponent;
|
||||||
|
|
||||||
constructor(config: AppConfigService) {
|
constructor(
|
||||||
this.allowDelete = config.get('adf-version-manager.allowDelete', true);
|
config: AppConfigService,
|
||||||
|
private contentService: ContentService) {
|
||||||
this.showComments = config.get('adf-version-manager.allowComments', true);
|
this.showComments = config.get('adf-version-manager.allowComments', true);
|
||||||
this.allowDownload = config.get('adf-version-manager.allowDownload', true);
|
this.allowDownload = config.get('adf-version-manager.allowDownload', true);
|
||||||
}
|
}
|
||||||
@@ -60,7 +58,7 @@ export class VersionManagerComponent {
|
|||||||
this.uploadSuccess.emit(event);
|
this.uploadSuccess.emit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUploadError(event): any {
|
canUpdate(): boolean {
|
||||||
this.uploadError.emit(event);
|
return this.contentService.hasPermission(this.node, 'update');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,10 @@
|
|||||||
class="adf-new-version-file-upload"
|
class="adf-new-version-file-upload"
|
||||||
staticTitle="{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.TITLE' | translate }}"
|
staticTitle="{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.TITLE' | translate }}"
|
||||||
[node]="node"
|
[node]="node"
|
||||||
|
[disabled]="!canUpload()"
|
||||||
[rootFolderId]="node.parentId"
|
[rootFolderId]="node.parentId"
|
||||||
tooltip="{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.TOOLTIP' | translate }}"
|
tooltip="{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.TOOLTIP' | translate }}"
|
||||||
[versioning]="true"
|
[versioning]="true"
|
||||||
(success)="onUploadSuccess($event)"
|
(success)="success.emit($event)"
|
||||||
(error)="onUploadError($event)">
|
(error)="error.emit($event)">
|
||||||
</adf-upload-version-button>
|
</adf-upload-version-button>
|
||||||
|
@@ -17,14 +17,13 @@
|
|||||||
|
|
||||||
import { Component, Input, ViewEncapsulation, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, ViewEncapsulation, Output, EventEmitter } from '@angular/core';
|
||||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||||
|
import { ContentService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-version-upload',
|
selector: 'adf-version-upload',
|
||||||
templateUrl: './version-upload.component.html',
|
templateUrl: './version-upload.component.html',
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: {
|
host: { 'class': 'adf-version-upload' }
|
||||||
'class': 'adf-version-upload'
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
export class VersionUploadComponent {
|
export class VersionUploadComponent {
|
||||||
|
|
||||||
@@ -32,17 +31,16 @@ export class VersionUploadComponent {
|
|||||||
node: MinimalNodeEntryEntity;
|
node: MinimalNodeEntryEntity;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
success: EventEmitter<any> = new EventEmitter();
|
success = new EventEmitter();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
error: EventEmitter<any> = new EventEmitter();
|
error = new EventEmitter();
|
||||||
|
|
||||||
onUploadSuccess(event): void {
|
constructor(private contentService: ContentService) {
|
||||||
this.success.emit(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUploadError(event): void {
|
canUpload(): boolean {
|
||||||
this.error.emit(event);
|
return this.contentService.hasPermission(this.node, 'update');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -474,8 +474,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"allowComments": { "type": "boolean" },
|
"allowComments": { "type": "boolean" },
|
||||||
"allowDownload": { "type": "boolean" },
|
"allowDownload": { "type": "boolean" }
|
||||||
"allowDelete": { "type": "boolean" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user