Skip to content

Commit

Permalink
fix new version uploader parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika committed Aug 2, 2024
1 parent 9ce733a commit 5534648
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface NewVersionUploaderDialogData {
file?: File;
currentVersion?: Version;
showVersionsOnly?: boolean;
showComments?: boolean;
allowDownload?: true;
}

export type NewVersionUploaderData = VersionManagerUploadData | ViewVersion | RefreshData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ <h1 class="adf-new-version-uploader-dialog-title" mat-dialog-title data-automati
<div class="adf-version-list-table">
<adf-version-list
[node]="data.node"
[showComments]="'adf-version-manager.allowComments' | adfAppConfig: true"
[allowDownload]="'adf-version-manager.allowDownload' | adfAppConfig: true"
[showComments]="data.showComments"
[allowDownload]="data.allowDownload"
(deleted)="refresh($event)"
(restored)="refresh($event)"
(viewVersion)="onViewingVersion($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/materia
import { NewVersionUploaderDialogData, NewVersionUploaderData, NewVersionUploaderDataAction } from './models';
import { CommonModule } from '@angular/common';
import { VersionComparisonComponent } from '../version-manager/version-comparison.component';
import { AppConfigPipe } from '@alfresco/adf-core';
import { TranslateModule } from '@ngx-translate/core';
import { MatButtonModule } from '@angular/material/button';
import { VersionUploadComponent } from '../version-manager/version-upload.component';
Expand All @@ -33,7 +32,6 @@ import { VersionListComponent } from '../version-manager/version-list.component'
imports: [
CommonModule,
MatDialogModule,
AppConfigPipe,
TranslateModule,
MatButtonModule,
VersionComparisonComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
import { VersionPaging, VersionsApi } from '@alfresco/js-api';
import { VersionsApi } from '@alfresco/js-api';
import { NewVersionUploaderData, NewVersionUploaderDialogData } from './models';
import { Observable } from 'rxjs';
import { OverlayContainer } from '@angular/cdk/overlay';
Expand All @@ -45,25 +45,30 @@ export class NewVersionUploaderService {
* @param data data to pass to MatDialog
* @param config allow to override default MatDialogConfig
* @param selectorAutoFocusedOnClose element's selector which should be autofocused after closing modal
* @param showComments enable comments
* @param allowDownload enable version download
* @returns an Observable represents the triggered dialog action or an error in case of an error condition
*/
openUploadNewVersionDialog(
data: NewVersionUploaderDialogData,
config?: MatDialogConfig,
selectorAutoFocusedOnClose?: string
selectorAutoFocusedOnClose?: string,
showComments = true,
allowDownload = true
): Observable<NewVersionUploaderData> {
const { file, node, showVersionsOnly } = data;
const showComments = true;
const allowDownload = true;

return new Observable((observer) => {
this.versionsApi.listVersionHistory(node.id).then((versionPaging: VersionPaging) => {
const dialogRef = this.dialog.open(NewVersionUploaderDialogComponent, {
data: { file, node, currentVersion: versionPaging.list.entries[0].entry, showComments, allowDownload, showVersionsOnly },
panelClass: this.composePanelClass(showVersionsOnly),
width: '630px',
...(config && Object.keys(config).length > 0 && config)
});
this.versionsApi.listVersionHistory(node.id).then((versionPaging) => {
const dialogRef = this.dialog.open<NewVersionUploaderDialogComponent, NewVersionUploaderDialogData>(
NewVersionUploaderDialogComponent,
{
data: { file, node, currentVersion: versionPaging.list.entries[0].entry, showComments, allowDownload, showVersionsOnly },
panelClass: this.composePanelClass(showVersionsOnly),
width: '630px',
...(config && Object.keys(config).length > 0 && config)
}
);
dialogRef.componentInstance.dialogAction.asObservable().subscribe((newVersionUploaderData) => {
observer.next(newVersionUploaderData);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
this.processCloudContentService.downloadFile(file.id);
}

onUploadNewFileVersion(node: NewVersionUploaderDialogData): void {
this.newVersionUploaderService.openUploadNewVersionDialog(node).subscribe(
onUploadNewFileVersion(config: NewVersionUploaderDialogData): void {
this.newVersionUploaderService.openUploadNewVersionDialog(config).subscribe(
(newVersionUploaderData) => {
if (newVersionUploaderData.action === NewVersionUploaderDataAction.upload) {
this.replaceOldFileVersionWithNew(newVersionUploaderData as VersionManagerUploadData);
Expand Down

0 comments on commit 5534648

Please sign in to comment.