mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2300] added menu option to attach file widget (#2992)
* [ADF-2300] added new selection menu to file uploaded * [ADF-2300] added menu option to attach file widget * [ADF-2300] removed fdescribe * [ADF-2300] fixed due peer review
This commit is contained in:
@@ -25,7 +25,9 @@ import {
|
||||
LogService,
|
||||
ThumbnailService,
|
||||
ProcessContentService,
|
||||
ActivitiContentService
|
||||
ActivitiContentService,
|
||||
ContentService,
|
||||
FormEvent
|
||||
} from '@alfresco/adf-core';
|
||||
import { ContentNodeDialogService } from '@alfresco/adf-content-services';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
@@ -41,12 +43,14 @@ import { Observable } from 'rxjs/Observable';
|
||||
export class AttachFileWidgetComponent extends UploadWidgetComponent implements OnInit {
|
||||
|
||||
repositoryList = [];
|
||||
private tempFilesList = [];
|
||||
|
||||
constructor(public formService: FormService,
|
||||
private logger: LogService,
|
||||
public thumbnails: ThumbnailService,
|
||||
public processContentService: ProcessContentService,
|
||||
private activitiContentService: ActivitiContentService,
|
||||
private contentService: ContentService,
|
||||
private contentDialog: ContentNodeDialogService) {
|
||||
super(formService, logger, thumbnails, processContentService);
|
||||
}
|
||||
@@ -58,9 +62,16 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
this.hasFile = true;
|
||||
}
|
||||
this.getMultipleFileParam();
|
||||
|
||||
this.activitiContentService.getAlfrescoRepositories(null, true).subscribe((repoList) => {
|
||||
this.repositoryList = repoList;
|
||||
});
|
||||
|
||||
this.formService.taskSaved.subscribe((formSaved: FormEvent) => {
|
||||
if (formSaved.form.id === this.field.form.id) {
|
||||
this.tempFilesList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isFileSourceConfigured(): boolean {
|
||||
@@ -99,6 +110,10 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
!!this.field.params.fileSource.selectedFolder;
|
||||
}
|
||||
|
||||
isTemporaryFile(file): boolean {
|
||||
return this.tempFilesList.indexOf(file) !== -1 ? true : false;
|
||||
}
|
||||
|
||||
openSelectDialogFromFileSource() {
|
||||
let params = this.field.params;
|
||||
if (this.isDefinedSourceFolder()) {
|
||||
@@ -111,6 +126,41 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
}
|
||||
}
|
||||
|
||||
onAttachFileChanged(event: any) {
|
||||
this.tempFilesList.push(...Array.from(event.target.files));
|
||||
this.onFileChanged(event);
|
||||
}
|
||||
|
||||
onRemoveAttachFile(file: any) {
|
||||
if (this.isTemporaryFile(file.contentBlob)) {
|
||||
this.tempFilesList.splice(this.tempFilesList.indexOf(file.contentBlob), 1);
|
||||
}
|
||||
this.removeFile(file);
|
||||
}
|
||||
|
||||
onAttachFileClicked(file: any) {
|
||||
if (this.isTemporaryFile(file.contentBlob)) {
|
||||
this.formService.formContentClicked.next(file);
|
||||
} else {
|
||||
this.fileClicked(file);
|
||||
}
|
||||
}
|
||||
|
||||
downloadContent(file: any): void {
|
||||
if (this.isTemporaryFile(file.contentBlob)) {
|
||||
this.contentService.downloadBlob(file.contentBlob, file.name);
|
||||
} else {
|
||||
this.processContentService.getFileRawContent(file.id).subscribe(
|
||||
(blob: Blob) => {
|
||||
this.contentService.downloadBlob(blob, file.name);
|
||||
},
|
||||
(err) => {
|
||||
this.logger.error('Impossible retrieve content for download');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
openSelectDialog(repoId: string, repoName: string) {
|
||||
const accountIdentifier = 'alfresco-' + repoId + repoName;
|
||||
this.contentDialog.openFileBrowseDialogBySite().subscribe(
|
||||
|
Reference in New Issue
Block a user