mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-2200] Upload dialog title should match selected site. (#5648)
* [AAE-2200] content-node-selector-panel pass starting site and emit event onSiteChange * [AAE-2200] content-node-selector handle siteChange event * [AAE-2200] content-node-selector has good default title * [AAE-2200] attach-file-widget-dialog handle siteChange event * [AAE-2200] Minor fixes on attach-file-widget-dialog * [AAE-2200] site-dropdown reload site list unfil it find its default site * [AAE-2200] Fix title translation for attach-file-widget-dialog * fix missing property description * Unit test fix * [AAE-2200] Fix title unit tests * [AAE-2200] Fix sites-dropdown infinite loading * [AAE-2200] Add content-node-selector-panel siteChange event unit tests * [AAE-2200] Refactor sites-dropdown unit tests * [AAE-2200] Refactor the 'allSitesLoaded' check * [AAE-2200] Add sites-dorpdown default value unit tests * [AAE-2200] Move getSiteFromNodePath method to sites service * [create preview] * [create preview] * [AAE-2200] Better hasMoreItems check in sites-dropdown (fix unit test) Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com> Co-authored-by: Cano <david.cano.nieto@gmail.com> Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<header
|
||||
mat-dialog-title
|
||||
data-automation-id="content-node-selector-title">{{title}}
|
||||
data-automation-id="content-node-selector-title">
|
||||
<span *ngIf="isLoggedIn(); else loginTitle">{{title}}</span>
|
||||
<ng-template #loginTitle>{{data.title}}</ng-template>
|
||||
</header>
|
||||
|
||||
<mat-dialog-content class="adf-login-dialog-content">
|
||||
@@ -10,7 +12,8 @@
|
||||
id="attach-file-content-node"
|
||||
[isSelectionValid]="data?.isSelectionValid"
|
||||
[showFilesInResult]="data?.showFilesInResult"
|
||||
(select)="onSelect($event)">
|
||||
(select)="onSelect($event)"
|
||||
(siteChange)="onSiteChange($event)">
|
||||
</adf-content-node-selector-panel>
|
||||
</mat-dialog-content>
|
||||
|
||||
|
@@ -145,22 +145,14 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should update the title when the selected node is a file', () => {
|
||||
const fakeNode: Node = new Node({ id: 'fake', isFile: true});
|
||||
contentNodePanel.componentInstance.select.emit([fakeNode]);
|
||||
it('should update the title when a site is selected', () => {
|
||||
const fakeSiteTitle = 'My fake site';
|
||||
contentNodePanel.componentInstance.siteChange.emit(fakeSiteTitle);
|
||||
fixture.detectChanges();
|
||||
|
||||
const titleElement = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-title"]'));
|
||||
expect(titleElement).not.toBeNull();
|
||||
expect(titleElement.nativeElement.innerText).toBe('ATTACH-FILE.ACTIONS.CHOOSE_ITEM');
|
||||
});
|
||||
|
||||
it('should update the title when the selected node is a folder', () => {
|
||||
const fakeNode: Node = new Node({ id: 'fake', isFolder: true});
|
||||
contentNodePanel.componentInstance.select.emit([fakeNode]);
|
||||
fixture.detectChanges();
|
||||
const titleElement = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-title"]'));
|
||||
expect(titleElement).not.toBeNull();
|
||||
expect(titleElement.nativeElement.innerText).toBe('ATTACH-FILE.ACTIONS.CHOOSE_IN');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -50,7 +50,7 @@ export class AttachFileWidgetDialogComponent {
|
||||
(<any> externalApiService).init(data.ecmHost, data.context);
|
||||
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
|
||||
this.buttonActionName = `ATTACH-FILE.ACTIONS.${this.action}`;
|
||||
this.title = data.title;
|
||||
this.updateTitle('DROPDOWN.MY_FILES_OPTION');
|
||||
}
|
||||
|
||||
isLoggedIn() {
|
||||
@@ -66,12 +66,11 @@ export class AttachFileWidgetDialogComponent {
|
||||
}
|
||||
|
||||
onSelect(nodeList: Node[]) {
|
||||
if (nodeList && nodeList[0].isFile) {
|
||||
this.chosenNode = nodeList;
|
||||
} else {
|
||||
this.chosenNode = null;
|
||||
}
|
||||
this.updateTitle(nodeList);
|
||||
this.chosenNode = nodeList;
|
||||
}
|
||||
|
||||
onSiteChange(siteTitle: string) {
|
||||
this.updateTitle(siteTitle);
|
||||
}
|
||||
|
||||
onClick() {
|
||||
@@ -79,17 +78,13 @@ export class AttachFileWidgetDialogComponent {
|
||||
this.data.selected.complete();
|
||||
}
|
||||
|
||||
updateTitle(nodeList: Node[]): void {
|
||||
if (this.action === 'CHOOSE' && nodeList) {
|
||||
if (nodeList[0].isFile) {
|
||||
this.title = this.getTitleTranslation(this.action + '_ITEM', nodeList[0].name);
|
||||
} else if (nodeList[0].isFolder) {
|
||||
this.title = this.getTitleTranslation(this.action + '_IN', nodeList[0].name);
|
||||
}
|
||||
updateTitle(siteTitle: string) {
|
||||
if (this.action === 'CHOOSE' && siteTitle) {
|
||||
this.title = this.getTitleTranslation(this.action, siteTitle);
|
||||
}
|
||||
}
|
||||
|
||||
getTitleTranslation(action: string, name: string): string {
|
||||
return this.translation.instant(`ATTACH-FILE.ACTIONS.${action}`, { name });
|
||||
getTitleTranslation(action: string, name?: string): string {
|
||||
return this.translation.instant(`ATTACH-FILE.ACTIONS.${action}_ITEM`, { name: this.translation.instant(name) });
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ export class AttachFileWidgetDialogService {
|
||||
selected,
|
||||
ecmHost,
|
||||
context,
|
||||
isSelectionValid: this.isNodeValid.bind(this),
|
||||
isSelectionValid: this.isNodeFile.bind(this),
|
||||
showFilesInResult: true
|
||||
};
|
||||
|
||||
@@ -71,8 +71,8 @@ export class AttachFileWidgetDialogService {
|
||||
this.dialog.closeAll();
|
||||
}
|
||||
|
||||
private isNodeValid(entry: Node): boolean {
|
||||
return entry.isFile || entry.isFolder;
|
||||
private isNodeFile(entry: Node): boolean {
|
||||
return entry.isFile;
|
||||
}
|
||||
|
||||
private getLoginTitleTranslation(ecmHost: string): string {
|
||||
|
Reference in New Issue
Block a user