mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Ability to use the appname as placeholder in the destinationFolder relative path (#6076)
This commit is contained in:
@@ -27,7 +27,8 @@ import {
|
|||||||
FormFieldTypes,
|
FormFieldTypes,
|
||||||
FormFieldMetadata,
|
FormFieldMetadata,
|
||||||
FormService,
|
FormService,
|
||||||
DownloadService
|
DownloadService,
|
||||||
|
AppConfigService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
@@ -43,6 +44,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
let fixture: ComponentFixture<AttachFileCloudWidgetComponent>;
|
let fixture: ComponentFixture<AttachFileCloudWidgetComponent>;
|
||||||
let element: HTMLInputElement;
|
let element: HTMLInputElement;
|
||||||
let contentCloudNodeSelectorService: ContentCloudNodeSelectorService;
|
let contentCloudNodeSelectorService: ContentCloudNodeSelectorService;
|
||||||
|
let appConfigService: AppConfigService;
|
||||||
let processCloudContentService: ProcessCloudContentService;
|
let processCloudContentService: ProcessCloudContentService;
|
||||||
let formService: FormService;
|
let formService: FormService;
|
||||||
let downloadService: DownloadService;
|
let downloadService: DownloadService;
|
||||||
@@ -173,6 +175,9 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
contentCloudNodeSelectorService = TestBed.inject(
|
contentCloudNodeSelectorService = TestBed.inject(
|
||||||
ContentCloudNodeSelectorService
|
ContentCloudNodeSelectorService
|
||||||
);
|
);
|
||||||
|
appConfigService = TestBed.inject(
|
||||||
|
AppConfigService
|
||||||
|
);
|
||||||
formService = TestBed.inject(FormService);
|
formService = TestBed.inject(FormService);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -389,6 +394,21 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-root-', 'multiple', true);
|
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-root-', 'multiple', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the application name in case -appname- placeholder is present', async() => {
|
||||||
|
appConfigService.config = Object.assign(appConfigService.config, {
|
||||||
|
'alfresco-deployed-apps': [
|
||||||
|
{
|
||||||
|
'name': 'fakeapp'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
expect(widget.replaceAppNameAliasWithValue('/myfiles/-appname-/folder')).toBe('/myfiles/fakeapp/folder');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the same value in case -appname- placeholder is NOT present', async() => {
|
||||||
|
expect(widget.replaceAppNameAliasWithValue('/myfiles/fakepath/folder')).toBe('/myfiles/fakepath/folder');
|
||||||
|
});
|
||||||
|
|
||||||
describe('FilesSource', () => {
|
describe('FilesSource', () => {
|
||||||
|
|
||||||
it('should be able to set myFiles folderId as rootNodeId if fileSource set only to content', async () => {
|
it('should be able to set myFiles folderId as rootNodeId if fileSource set only to content', async () => {
|
||||||
|
@@ -24,7 +24,8 @@ import {
|
|||||||
ThumbnailService,
|
ThumbnailService,
|
||||||
NotificationService,
|
NotificationService,
|
||||||
FormValues,
|
FormValues,
|
||||||
ContentLinkModel
|
ContentLinkModel,
|
||||||
|
AppConfigService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { Node, RelatedContentRepresentation } from '@alfresco/js-api';
|
import { Node, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||||
import { ContentCloudNodeSelectorService } from '../../../services/content-cloud-node-selector.service';
|
import { ContentCloudNodeSelectorService } from '../../../services/content-cloud-node-selector.service';
|
||||||
@@ -53,6 +54,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
|||||||
|
|
||||||
static MY_FILES_FOLDER_ID = '-my-';
|
static MY_FILES_FOLDER_ID = '-my-';
|
||||||
static ROOT_FOLDER_ID = '-root-';
|
static ROOT_FOLDER_ID = '-root-';
|
||||||
|
static APP_NAME = '-appname-';
|
||||||
static VALID_ALIAS = [AttachFileCloudWidgetComponent.ROOT_FOLDER_ID, AttachFileCloudWidgetComponent.MY_FILES_FOLDER_ID, '-shared-'];
|
static VALID_ALIAS = [AttachFileCloudWidgetComponent.ROOT_FOLDER_ID, AttachFileCloudWidgetComponent.MY_FILES_FOLDER_ID, '-shared-'];
|
||||||
|
|
||||||
typeId = 'AttachFileCloudWidgetComponent';
|
typeId = 'AttachFileCloudWidgetComponent';
|
||||||
@@ -64,7 +66,8 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
|||||||
thumbnails: ThumbnailService,
|
thumbnails: ThumbnailService,
|
||||||
processCloudContentService: ProcessCloudContentService,
|
processCloudContentService: ProcessCloudContentService,
|
||||||
notificationService: NotificationService,
|
notificationService: NotificationService,
|
||||||
private contentNodeSelectorService: ContentCloudNodeSelectorService
|
private contentNodeSelectorService: ContentCloudNodeSelectorService,
|
||||||
|
private appConfigService: AppConfigService
|
||||||
) {
|
) {
|
||||||
super(formService, thumbnails, processCloudContentService, notificationService, logger);
|
super(formService, thumbnails, processCloudContentService, notificationService, logger);
|
||||||
}
|
}
|
||||||
@@ -85,6 +88,18 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
|||||||
this.removeFile(file);
|
this.removeFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchAppNameFromAppConfig(): string {
|
||||||
|
return this.appConfigService.get('alfresco-deployed-apps')[0]?.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceAppNameAliasWithValue(path: string): string {
|
||||||
|
if (path?.match(AttachFileCloudWidgetComponent.APP_NAME)) {
|
||||||
|
const appName = this.fetchAppNameFromAppConfig();
|
||||||
|
return path.replace(AttachFileCloudWidgetComponent.APP_NAME, appName);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
async openSelectDialog() {
|
async openSelectDialog() {
|
||||||
const selectedMode = this.field.params.multiple ? 'multiple' : 'single';
|
const selectedMode = this.field.params.multiple ? 'multiple' : 'single';
|
||||||
|
|
||||||
@@ -92,6 +107,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
|||||||
const destinationFolderPath = this.getAliasAndRelativePathFromDestinationFolderPath(this.field.params.fileSource.destinationFolderPath);
|
const destinationFolderPath = this.getAliasAndRelativePathFromDestinationFolderPath(this.field.params.fileSource.destinationFolderPath);
|
||||||
const opts = { relativePath: destinationFolderPath.path };
|
const opts = { relativePath: destinationFolderPath.path };
|
||||||
|
|
||||||
|
destinationFolderPath.path = this.replaceAppNameAliasWithValue(destinationFolderPath.path);
|
||||||
const nodeId = await this.contentNodeSelectorService.fetchNodeIdFromRelativePath(destinationFolderPath.alias, opts);
|
const nodeId = await this.contentNodeSelectorService.fetchNodeIdFromRelativePath(destinationFolderPath.alias, opts);
|
||||||
this.rootNodeId = nodeId ? nodeId : destinationFolderPath.alias;
|
this.rootNodeId = nodeId ? nodeId : destinationFolderPath.alias;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user