[ADF-2726] fixed save content for external repository (#3341)

* [ADF-2726] start fixing the show of files loaded from CS

* [ADF-2726] start fixing the show of files loaded from CS

* [ADF-2726] fixed save content for external repository|

* [ADF-2726] fixed save content for external repository|

* [ADF-2726] reeanabled and fixed the tests

* [ADF-2726] reeanabled and fixed the tests

* [ADF-2726] added tests for attach file widget and activiti alfresco service

* [ADF-2726] added tests for attach file widget and activiti alfresco service

* [ADF-2726] fixed test
This commit is contained in:
Vito
2018-05-21 12:14:11 +01:00
committed by Eugenio Romano
parent b599e3a41a
commit 1c7f267c63
9 changed files with 344 additions and 29 deletions

View File

@@ -32,6 +32,8 @@ import { ContentNodeDialogService } from '@alfresco/adf-content-services';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/from';
import { zip } from 'rxjs/observable/zip';
import { of } from 'rxjs/observable/of';
@Component({
selector: 'attach-widget',
@@ -121,7 +123,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
}
isTemporaryFile(file): boolean {
return this.tempFilesList.indexOf(file) !== -1 ? true : false;
return this.tempFilesList.findIndex((elem) => elem.name === file.name) >= 0;
}
openSelectDialogFromFileSource() {
@@ -129,6 +131,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
if (this.isDefinedSourceFolder()) {
this.contentDialog.openFileBrowseDialogByFolderId(params.fileSource.selectedFolder.pathId).subscribe(
(selections: MinimalNodeEntryEntity[]) => {
this.tempFilesList.push(...selections);
this.uploadFileFromCS(selections,
this.field.params.fileSource.selectedFolder.accountId,
this.field.params.fileSource.selectedFolder.siteId);
@@ -142,14 +145,14 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
}
onRemoveAttachFile(file: any) {
if (this.isTemporaryFile(file.contentBlob)) {
if (this.isTemporaryFile(file)) {
this.tempFilesList.splice(this.tempFilesList.indexOf(file.contentBlob), 1);
}
this.removeFile(file);
}
onAttachFileClicked(file: any) {
if (this.isTemporaryFile(file.contentBlob)) {
if (this.isTemporaryFile(file)) {
this.formService.formContentClicked.next(file);
} else {
this.fileClicked(file);
@@ -157,8 +160,8 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
}
downloadContent(file: any): void {
if (this.isTemporaryFile(file.contentBlob)) {
this.contentService.downloadBlob(file.contentBlob, file.name);
if (this.isTemporaryFile(file)) {
this.contentService.downloadBlob(file, file.name);
} else {
this.processContentService.getFileRawContent(file.id).subscribe(
(blob: Blob) => {
@@ -172,9 +175,10 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
}
openSelectDialog(repoId: string, repoName: string) {
const accountIdentifier = 'alfresco-' + repoId + repoName;
const accountIdentifier = 'alfresco-' + repoId + '-' + repoName;
this.contentDialog.openFileBrowseDialogBySite().subscribe(
(selections: MinimalNodeEntryEntity[]) => {
this.tempFilesList.push(...selections);
this.uploadFileFromCS(selections, accountIdentifier);
});
}
@@ -183,10 +187,11 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
let filesSaved = [];
Observable.from(fileNodeList)
.mergeMap(node =>
this.activitiContentService.applyAlfrescoNode(node,
zip(of(node.content.mimeType), this.activitiContentService.applyAlfrescoNode(node,
siteId,
accountId)
).subscribe((res) => {
accountId))
).subscribe(([mymeType, res]) => {
res.mimeType = mymeType;
filesSaved.push(res);
},
(error) => {
@@ -195,8 +200,8 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
() => {
this.field.value = filesSaved;
this.field.json.value = filesSaved;
this.hasFile = true;
});
this.hasFile = true;
}
}