[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:
Baptiste Mahé
2020-05-14 11:38:16 +02:00
committed by GitHub
parent c26b8e046c
commit 78332449a5
21 changed files with 511 additions and 324 deletions

View File

@@ -49,6 +49,7 @@ Opens a [Content Node Selector](content-node-selector.component.md) in its own
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| select | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`Node`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md)`[]>` | Emitted when the user has chosen an item. | | select | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`Node`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md)`[]>` | Emitted when the user has chosen an item. |
| siteChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when the select site changes. |
## Details ## Details

View File

@@ -193,7 +193,7 @@ The Process Instance List also supports pagination:
Emitted before the context menu is displayed for a row. Emitted before the context menu is displayed for a row.
Note that the [ProcessInstanceListComponent](../../../lib/process-services/src/lib/process-list/components/process-list.component.ts) itself does not populate the context menu with items. You can provide all necessary content via the handler. Note that the [`ProcessInstanceListComponent`](../../../lib/process-services/src/lib/process-list/components/process-list.component.ts) itself does not populate the context menu with items. You can provide all necessary content via the handler.
```html ```html
<adf-process-instance-list <adf-process-instance-list

View File

@@ -235,7 +235,7 @@ You can customize the styling of a column and also add features like tooltips an
Emitted before the context menu is displayed for a row. Emitted before the context menu is displayed for a row.
Note that the [TaskListComponent](../../process-services/components/task-list.component.md) itself does not populate the context menu with items. Note that the [`TaskListComponent`](../../process-services/components/task-list.component.md) itself does not populate the context menu with items.
You can provide all necessary content via the handler. You can provide all necessary content via the handler.
```html ```html
@@ -270,7 +270,7 @@ onShowRowContextMenu(event: DataCellEvent) {
This event is cancellable. You can use `event.preventDefault()` to prevent the default behavior. This event is cancellable. You can use `event.preventDefault()` to prevent the default behavior.
The [TaskListComponent](../../process-services/components/task-list.component.md) will automatically render the supplied menu items. The [`TaskListComponent`](../../process-services/components/task-list.component.md) will automatically render the supplied menu items.
See the [ContextMenu](https://www.npmjs.com/package/ng2-alfresco-core) See the [ContextMenu](https://www.npmjs.com/package/ng2-alfresco-core)
documentation for more details on the format and behavior of context actions. documentation for more details on the format and behavior of context actions.

View File

@@ -179,7 +179,7 @@ export class ContentNodeDialogService {
}); });
const data: ContentNodeSelectorComponentData = { const data: ContentNodeSelectorComponentData = {
title: this.getTitleTranslation(action, contentEntry.name), title: this.getTitleTranslation(action, this.translation.instant('DROPDOWN.MY_FILES_OPTION')),
actionName: action, actionName: action,
currentFolderId: contentEntry.id, currentFolderId: contentEntry.id,
imageResolver: this.imageResolver.bind(this), imageResolver: this.imageResolver.bind(this),
@@ -206,7 +206,7 @@ export class ContentNodeDialogService {
}); });
const data: ContentNodeSelectorComponentData = { const data: ContentNodeSelectorComponentData = {
title: this.getTitleTranslation(action, contentEntry.name), title: this.getTitleTranslation(action, this.translation.instant('DROPDOWN.MY_FILES_OPTION')),
actionName: action, actionName: action,
currentFolderId: contentEntry.id, currentFolderId: contentEntry.id,
imageResolver: this.imageResolver.bind(this), imageResolver: this.imageResolver.bind(this),

View File

@@ -29,6 +29,7 @@
[placeholder]="'NODE_SELECTOR.SELECT_LOCATION'" [placeholder]="'NODE_SELECTOR.SELECT_LOCATION'"
[hideMyFiles]="dropdownHideMyFiles" [hideMyFiles]="dropdownHideMyFiles"
[siteList]="dropdownSiteList" [siteList]="dropdownSiteList"
[value]="startSiteGuid"
data-automation-id="content-node-selector-sites-combo"> data-automation-id="content-node-selector-sites-combo">
</adf-sites-dropdown> </adf-sites-dropdown>

View File

@@ -19,7 +19,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { NodeEntry, Node, SiteEntry, SitePaging, NodePaging } from '@alfresco/js-api'; import { NodeEntry, Node, SiteEntry, SitePaging, NodePaging } from '@alfresco/js-api';
import { SearchService, SitesService, setupTestBed } from '@alfresco/adf-core'; import { SearchService, SitesService, setupTestBed, NodesApiService } from '@alfresco/adf-core';
import { Observable, Observer, of, throwError } from 'rxjs'; import { Observable, Observer, of, throwError } from 'rxjs';
import { DropdownBreadcrumbComponent } from '../breadcrumb'; import { DropdownBreadcrumbComponent } from '../breadcrumb';
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component'; import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
@@ -27,6 +27,7 @@ import { ContentNodeSelectorService } from './content-node-selector.service';
import { ContentTestingModule } from '../testing/content.testing.module'; import { ContentTestingModule } from '../testing/content.testing.module';
import { DocumentListService } from '../document-list/services/document-list.service'; import { DocumentListService } from '../document-list/services/document-list.service';
import { DocumentListComponent } from '../document-list/components/document-list.component'; import { DocumentListComponent } from '../document-list/components/document-list.component';
import { DropdownSitesComponent } from '../site-dropdown/sites-dropdown.component';
import { CustomResourcesService } from '../document-list/services/custom-resources.service'; import { CustomResourcesService } from '../document-list/services/custom-resources.service';
import { ShareDataRow } from '../document-list'; import { ShareDataRow } from '../document-list';
@@ -53,6 +54,8 @@ describe('ContentNodeSelectorComponent', () => {
let fixture: ComponentFixture<ContentNodeSelectorPanelComponent>; let fixture: ComponentFixture<ContentNodeSelectorPanelComponent>;
let contentNodeSelectorService: ContentNodeSelectorService; let contentNodeSelectorService: ContentNodeSelectorService;
let searchService: SearchService; let searchService: SearchService;
let nodeService: NodesApiService;
let sitesService: SitesService;
let searchSpy: jasmine.Spy; let searchSpy: jasmine.Spy;
let cnSearchSpy: jasmine.Spy; let cnSearchSpy: jasmine.Spy;
@@ -82,13 +85,19 @@ describe('ContentNodeSelectorComponent', () => {
component.debounceSearch = 0; component.debounceSearch = 0;
searchService = TestBed.get(SearchService); searchService = TestBed.get(SearchService);
nodeService = TestBed.get(NodesApiService);
contentNodeSelectorService = TestBed.get(ContentNodeSelectorService); contentNodeSelectorService = TestBed.get(ContentNodeSelectorService);
sitesService = TestBed.get(SitesService);
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }));
cnSearchSpy = spyOn(contentNodeSelectorService, 'search').and.callThrough(); cnSearchSpy = spyOn(contentNodeSelectorService, 'search').and.callThrough();
searchSpy = spyOn(searchService, 'searchByQueryBody').and.callFake(() => { searchSpy = spyOn(searchService, 'searchByQueryBody').and.callFake(() => {
return new Observable((observer: Observer<NodePaging>) => { return new Observable((observer: Observer<NodePaging>) => {
_observer = observer; _observer = observer;
}); });
}); });
const fakeSite = new SiteEntry({ entry: { id: 'fake-site', guid: 'fake-site', title: 'fake-site', visibility: 'visible' } });
spyOn(sitesService, 'getSite').and.returnValue(of(fakeSite));
}); });
afterEach(() => { afterEach(() => {
@@ -98,11 +107,9 @@ describe('ContentNodeSelectorComponent', () => {
describe('Parameters', () => { describe('Parameters', () => {
let documentListService: DocumentListService; let documentListService: DocumentListService;
let sitesService: SitesService;
beforeEach(() => { beforeEach(() => {
documentListService = TestBed.get(DocumentListService); documentListService = TestBed.get(DocumentListService);
sitesService = TestBed.get(SitesService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } })); spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test')); spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
@@ -205,11 +212,9 @@ describe('ContentNodeSelectorComponent', () => {
describe('Breadcrumbs', () => { describe('Breadcrumbs', () => {
let documentListService: DocumentListService; let documentListService: DocumentListService;
let sitesService: SitesService;
beforeEach(() => { beforeEach(() => {
documentListService = TestBed.get(DocumentListService); documentListService = TestBed.get(DocumentListService);
sitesService = TestBed.get(SitesService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } })); spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test')); spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
@@ -350,6 +355,40 @@ describe('ContentNodeSelectorComponent', () => {
}); });
}); });
describe('Site selection', () => {
beforeEach(() => {
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
component.currentFolderId = 'fake-starting-folder';
});
it('should trigger siteChange event on init with parent site Title of start folder', (done) => {
component.siteChange.subscribe((siteTitle: string) => {
expect(siteTitle).toBe('fake-site');
done();
});
component.ngOnInit();
fixture.detectChanges();
expect(component.startSiteGuid).toBe('fake-site');
});
it('should trigger siteChange event when a site is selected in sites-dropdown', (done) => {
const fakeSiteEntry = new SiteEntry({ entry: { title: 'fake-new-site', guid: 'fake-new-site' } });
fixture.detectChanges();
fixture.whenStable().then(() => {
component.siteChange.subscribe((siteTitle: string) => {
expect(siteTitle).toBe('fake-new-site');
done();
});
const sitesDropdown = fixture.debugElement.query(By.directive(DropdownSitesComponent));
sitesDropdown.componentInstance.selectedSite({value: fakeSiteEntry});
});
});
});
describe('Search functionality', () => { describe('Search functionality', () => {
let getCorrespondingNodeIdsSpy; let getCorrespondingNodeIdsSpy;
@@ -392,7 +431,6 @@ describe('ContentNodeSelectorComponent', () => {
} }
})); }));
const sitesService = TestBed.get(SitesService);
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } })); spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
const customResourcesService = TestBed.get(CustomResourcesService); const customResourcesService = TestBed.get(CustomResourcesService);
@@ -883,7 +921,6 @@ describe('ContentNodeSelectorComponent', () => {
} }
beforeEach(() => { beforeEach(() => {
const sitesService = TestBed.get(SitesService);
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } })); spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
}); });

View File

@@ -21,7 +21,9 @@ import {
UserPreferencesService, UserPreferencesService,
PaginationModel, PaginationModel,
UserPreferenceValues, UserPreferenceValues,
InfinitePaginationComponent, PaginatedComponent InfinitePaginationComponent, PaginatedComponent,
NodesApiService,
SitesService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { Node, NodePaging, Pagination, SiteEntry, SitePaging } from '@alfresco/js-api'; import { Node, NodePaging, Pagination, SiteEntry, SitePaging } from '@alfresco/js-api';
@@ -176,6 +178,10 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
@Output() @Output()
select: EventEmitter<Node[]> = new EventEmitter<Node[]>(); select: EventEmitter<Node[]> = new EventEmitter<Node[]>();
/** Emitted when the select site changes. */
@Output()
siteChange: EventEmitter<string> = new EventEmitter<string>();
@ViewChild('documentList') @ViewChild('documentList')
documentList: DocumentListComponent; documentList: DocumentListComponent;
@@ -191,6 +197,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
_chosenNode: Node = null; _chosenNode: Node = null;
folderIdToShow: string | null = null; folderIdToShow: string | null = null;
breadcrumbFolderTitle: string | null = null; breadcrumbFolderTitle: string | null = null;
startSiteGuid: string | null = null;
pagination: PaginationModel = this.DEFAULT_PAGINATION; pagination: PaginationModel = this.DEFAULT_PAGINATION;
@@ -207,7 +214,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
constructor(private contentNodeSelectorService: ContentNodeSelectorService, constructor(private contentNodeSelectorService: ContentNodeSelectorService,
private customResourcesService: CustomResourcesService, private customResourcesService: CustomResourcesService,
private userPreferencesService: UserPreferencesService) { private userPreferencesService: UserPreferencesService,
private nodesApiService: NodesApiService,
private sitesService: SitesService) {
} }
set chosenNode(value: Node) { set chosenNode(value: Node) {
@@ -238,6 +247,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.target = this.documentList; this.target = this.documentList;
this.folderIdToShow = this.currentFolderId; this.folderIdToShow = this.currentFolderId;
if (this.currentFolderId) {
this.getStartSite();
}
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null; this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
this.isSelectionValid = this.isSelectionValid ? this.isSelectionValid : defaultValidation; this.isSelectionValid = this.isSelectionValid ? this.isSelectionValid : defaultValidation;
@@ -248,6 +260,19 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.onDestroy$.complete(); this.onDestroy$.complete();
} }
private getStartSite() {
this.nodesApiService.getNode(this.currentFolderId).subscribe((startNodeEntry) => {
this.startSiteGuid = this.sitesService.getSiteNameFromNodePath(startNodeEntry);
if (this.startSiteGuid) {
this.sitesService.getSite(this.startSiteGuid).subscribe((startSiteEntry) => {
if (startSiteEntry instanceof SiteEntry) {
this.siteChange.emit(startSiteEntry.entry.title);
}
});
}
});
}
private createRowFilter(filter?: RowFilter) { private createRowFilter(filter?: RowFilter) {
if (!filter) { if (!filter) {
filter = () => true; filter = () => true;
@@ -280,8 +305,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
siteChanged(chosenSite: SiteEntry): void { siteChanged(chosenSite: SiteEntry): void {
this.siteId = chosenSite.entry.guid; this.siteId = chosenSite.entry.guid;
this.setTitleIfCustomSite(chosenSite); this.setTitleIfCustomSite(chosenSite);
this.siteChange.emit(chosenSite.entry.title);
this.updateResults(); this.updateResults();
} }
/** /**

View File

@@ -18,7 +18,8 @@
[showSearch]="data?.showSearch" [showSearch]="data?.showSearch"
[showDropdownSiteList]="data?.showDropdownSiteList" [showDropdownSiteList]="data?.showDropdownSiteList"
[showFilesInResult]="data?.showFilesInResult" [showFilesInResult]="data?.showFilesInResult"
(select)="onSelect($event)"> (select)="onSelect($event)"
(siteChange)="onSiteChange($event)">
</adf-content-node-selector-panel> </adf-content-node-selector-panel>
</mat-dialog-content> </mat-dialog-content>

View File

@@ -20,6 +20,7 @@ import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ContentNodeSelectorComponent } from './content-node-selector.component'; import { ContentNodeSelectorComponent } from './content-node-selector.component';
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
import { ContentNodeSelectorPanelComponent } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { setupTestBed, SitesService } from '@alfresco/adf-core'; import { setupTestBed, SitesService } from '@alfresco/adf-core';
import { of } from 'rxjs'; import { of } from 'rxjs';
@@ -159,8 +160,10 @@ describe('ContentNodeSelectorDialogComponent', () => {
describe('Title', () => { describe('Title', () => {
it('should be updated when a node is chosen', () => { it('should be updated when a site is chosen', () => {
component.onSelect([new Node({ id: 'fake', name: 'fake-node' })]); const fakeSiteTitle = 'My fake site';
const contentNodePanel = fixture.debugElement.query(By.directive(ContentNodeSelectorPanelComponent));
contentNodePanel.componentInstance.siteChange.emit(fakeSiteTitle);
fixture.detectChanges(); fixture.detectChanges();
const titleElement = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-title"]')); const titleElement = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-title"]'));

View File

@@ -34,7 +34,7 @@ export class ContentNodeSelectorComponent {
buttonActionName: string; buttonActionName: string;
chosenNode: Node[]; chosenNode: Node[];
constructor(public translation: TranslationService, constructor(private translation: TranslationService,
@Inject(MAT_DIALOG_DATA) public data: ContentNodeSelectorComponentData) { @Inject(MAT_DIALOG_DATA) public data: ContentNodeSelectorComponentData) {
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE'; this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
this.buttonActionName = `NODE_SELECTOR.${this.action}`; this.buttonActionName = `NODE_SELECTOR.${this.action}`;
@@ -47,7 +47,10 @@ export class ContentNodeSelectorComponent {
onSelect(nodeList: Node[]) { onSelect(nodeList: Node[]) {
this.chosenNode = nodeList; this.chosenNode = nodeList;
this.updateTitle(nodeList); }
onSiteChange(siteTitle: string) {
this.updateTitle(siteTitle);
} }
onClick(): void { onClick(): void {
@@ -55,13 +58,13 @@ export class ContentNodeSelectorComponent {
this.data.select.complete(); this.data.select.complete();
} }
updateTitle(nodeList: Node[]): void { updateTitle(siteTitle: string) {
if (this.action === 'CHOOSE' && nodeList) { if (this.action === 'CHOOSE' && siteTitle) {
this.title = this.getTitleTranslation(this.action, nodeList[0].name); this.title = this.getTitleTranslation(this.action, siteTitle);
} }
} }
getTitleTranslation(action: string, name: string): string { getTitleTranslation(action: string, name: string): string {
return this.translation.instant(`NODE_SELECTOR.${action}_ITEM`, { name }); return this.translation.instant(`NODE_SELECTOR.${action}_ITEM`, { name: this.translation.instant(name) });
} }
} }

View File

@@ -20,3 +20,4 @@ export * from './document-list.component.mock';
export * from './search.component.mock'; export * from './search.component.mock';
export * from './search.service.mock'; export * from './search.service.mock';
export * from './search-filter-mock'; export * from './search-filter-mock';
export * from './sites-dropdown.component.mock';

View File

@@ -0,0 +1,293 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { SitePaging } from '@alfresco/js-api';
/* We are using functions instead of constants here to pass a new instance of the object each time */
export function getFakeSitePaging(): SitePaging {
return {
'list': {
'pagination': {
'count': 2,
'hasMoreItems': true,
'totalItems': 2,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-1',
'description': 'fake-test-site',
'id': 'fake-test-site',
'preset': 'site-dashboard',
'title': 'fake-test-site'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-2',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'fake-test-2'
}
}
]
}
};
}
export function getFakeSitePagingNoMoreItems(): SitePaging {
return {
'list': {
'pagination': {
'count': 2,
'hasMoreItems': false,
'totalItems': 2,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-1',
'description': 'fake-test-site',
'id': 'fake-test-site',
'preset': 'site-dashboard',
'title': 'fake-test-site'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-2',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'fake-test-2'
}
}
]
}
};
}
export function getFakeSitePagingFirstPage(): SitePaging {
return {
'list': {
'pagination': {
'count': 2,
'hasMoreItems': true,
'totalItems': 2,
'skipCount': 0,
'maxItems': 4
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-1',
'description': 'fake-test-site',
'id': 'fake-test-site',
'preset': 'site-dashboard',
'title': 'fake-test-site'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-2',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'fake-test-2'
}
}
]
}
};
}
export function getFakeSitePagingLastPage(): SitePaging {
return {
'list': {
'pagination': {
'count': 4,
'hasMoreItems': false,
'totalItems': 2,
'skipCount': 2,
'maxItems': 4
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-3',
'description': 'fake-test-3',
'id': 'fake-test-3',
'preset': 'site-dashboard',
'title': 'fake-test-3'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-test-4',
'description': 'This is a Sample Alfresco Team site.',
'id': 'fake-test-4',
'preset': 'site-dashboard',
'title': 'fake-test-4'
}
}
]
}
};
}
export function getFakeSitePagingWithMembers() {
return {
'list': {
'entries': [{
'entry': {
'visibility': 'MODERATED',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'MODERATED-SITE',
'preset': 'site-dashboard',
'title': 'FAKE-MODERATED-SITE'
},
'relations': {
'members': {
'list': {
'pagination': {
'count': 3,
'hasMoreItems': false,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'person': {
'firstName': 'Administrator',
'emailNotificationsEnabled': true,
'company': {},
'id': 'admin',
'enabled': true,
'email': 'admin@alfresco.com'
},
'id': 'admin'
}
},
{
'entry': {
'role': 'SiteCollaborator',
'person': {
'lastName': 'Beecher',
'userStatus': 'Helping to design the look and feel of the new web site',
'jobTitle': 'Graphic Designer',
'statusUpdatedAt': '2011-02-15T20:20:13.432+0000',
'mobile': '0112211001100',
'emailNotificationsEnabled': true,
'description': 'Alice is a demo user for the sample Alfresco Team site.',
'telephone': '0112211001100',
'enabled': false,
'firstName': 'Alice',
'skypeId': 'abeecher',
'avatarId': '198500fc-1e99-4f5f-8926-248cea433366',
'location': 'Tilbury, UK',
'company': {
'organization': 'Moresby, Garland and Wedge',
'address1': '200 Butterwick Street',
'address2': 'Tilbury',
'address3': 'UK',
'postcode': 'ALF1 SAM1'
},
'id': 'abeecher',
'email': 'abeecher@example.com'
},
'id': 'abeecher'
}
}
]
}
}
}
}, {
'entry': {
'visibility': 'PUBLIC',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'PUBLIC-SITE',
'preset': 'site-dashboard',
'title': 'FAKE-SITE-PUBLIC'
}
}, {
'entry': {
'visibility': 'PRIVATE',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'MEMBER-SITE',
'preset': 'site-dashboard',
'title': 'FAKE-PRIVATE-SITE-MEMBER'
},
'relations': {
'members': {
'list': {
'pagination': {
'count': 3,
'hasMoreItems': false,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'person': {
'firstName': 'Administrator',
'emailNotificationsEnabled': true,
'company': {},
'id': 'admin',
'enabled': true,
'email': 'admin@alfresco.com'
},
'id': 'test'
}
}
]
}
}
}
}
]
}
};
}

View File

@@ -22,6 +22,31 @@ import { DropdownSitesComponent, Relations } from './sites-dropdown.component';
import { SitesService, setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core'; import { SitesService, setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { getFakeSitePaging,
getFakeSitePagingNoMoreItems,
getFakeSitePagingFirstPage,
getFakeSitePagingLastPage,
getFakeSitePagingWithMembers
} from '../mock';
const customSiteList = {
'list': {
'entries': [
{
'entry': {
'guid': '-my-',
'title': 'PERSONAL_FILES'
}
},
{
'entry': {
'guid': '-mysites-',
'title': 'FILE_LIBRARIES'
}
}
]
}
};
describe('DropdownSitesComponent', () => { describe('DropdownSitesComponent', () => {
@@ -54,45 +79,10 @@ describe('DropdownSitesComponent', () => {
debug = fixture.debugElement; debug = fixture.debugElement;
element = fixture.nativeElement; element = fixture.nativeElement;
component = fixture.componentInstance; component = fixture.componentInstance;
spyOn(siteService, 'getSites').and.returnValue(of(getFakeSitePaging()));
})); }));
it('Should show loading item if there are more itemes', async(() => { it('Should show loading item if there are more itemes', async(() => {
spyOn(siteService, 'getSites').and.returnValue(of({
'list': {
'pagination': {
'count': 2,
'hasMoreItems': true,
'totalItems': 2,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-1',
'description': 'fake-test-site',
'id': 'fake-test-site',
'preset': 'site-dashboard',
'title': 'fake-test-site'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-2',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'fake-test-2'
}
}
]
}
}));
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -101,42 +91,6 @@ describe('DropdownSitesComponent', () => {
})); }));
it('Should not show loading item if there are more itemes', async(() => { it('Should not show loading item if there are more itemes', async(() => {
spyOn(siteService, 'getSites').and.returnValue(of({
'list': {
'pagination': {
'count': 2,
'hasMoreItems': false,
'totalItems': 2,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-1',
'description': 'fake-test-site',
'id': 'fake-test-site',
'preset': 'site-dashboard',
'title': 'fake-test-site'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-2',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'fake-test-2'
}
}
]
}
}));
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -150,41 +104,7 @@ describe('DropdownSitesComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
siteService = TestBed.get(SitesService); siteService = TestBed.get(SitesService);
spyOn(siteService, 'getSites').and.returnValue(of({ spyOn(siteService, 'getSites').and.returnValue(of(getFakeSitePagingNoMoreItems()));
'list': {
'pagination': {
'count': 2,
'hasMoreItems': false,
'totalItems': 2,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-1',
'description': 'fake-test-site',
'id': 'fake-test-site',
'preset': 'site-dashboard',
'title': 'fake-test-site'
}
},
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'fake-2',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'fake-test-2'
}
}
]
}
}));
fixture = TestBed.createComponent(DropdownSitesComponent); fixture = TestBed.createComponent(DropdownSitesComponent);
debug = fixture.debugElement; debug = fixture.debugElement;
@@ -260,24 +180,7 @@ describe('DropdownSitesComponent', () => {
})); }));
it('should load custom sites when the \'siteList\' input property is given a value', async(() => { it('should load custom sites when the \'siteList\' input property is given a value', async(() => {
component.siteList = { component.siteList = customSiteList;
'list': {
'entries': [
{
'entry': {
'guid': '-my-',
'title': 'PERSONAL_FILES'
}
},
{
'entry': {
'guid': '-mysites-',
'title': 'FILE_LIBRARIES'
}
}
]
}
};
fixture.detectChanges(); fixture.detectChanges();
@@ -339,129 +242,43 @@ describe('DropdownSitesComponent', () => {
}); });
}); });
describe('Default value', () => {
beforeEach(async(() => {
siteService = TestBed.get(SitesService);
spyOn(siteService, 'getSites').and.returnValues(of(getFakeSitePagingFirstPage()), of(getFakeSitePagingLastPage()));
fixture = TestBed.createComponent(DropdownSitesComponent);
component = fixture.componentInstance;
}));
it('should load new sites if default value is not in the first page', (done) => {
component.value = 'fake-test-4';
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(component.selected.entry.title).toBe('fake-test-4');
done();
});
});
it('should NOT reload infinitely if default value is NOT found after all sites are loaded', (done) => {
component.value = 'nonexistent-site';
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(component.selected).toBeUndefined();
expect(component.loading).toBeFalsy();
done();
});
});
});
describe('Sites with members', () => { describe('Sites with members', () => {
beforeEach(async(() => { beforeEach(async(() => {
siteService = TestBed.get(SitesService); siteService = TestBed.get(SitesService);
spyOn(siteService, 'getSites').and.returnValue(of({ spyOn(siteService, 'getSites').and.returnValue(of(getFakeSitePagingWithMembers()));
'list': {
'entries': [{
'entry': {
'visibility': 'MODERATED',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'MODERATED-SITE',
'preset': 'site-dashboard',
'title': 'FAKE-MODERATED-SITE'
},
'relations': {
'members': {
'list': {
'pagination': {
'count': 3,
'hasMoreItems': false,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'person': {
'firstName': 'Administrator',
'emailNotificationsEnabled': true,
'company': {},
'id': 'admin',
'enabled': true,
'email': 'admin@alfresco.com'
},
'id': 'admin'
}
},
{
'entry': {
'role': 'SiteCollaborator',
'person': {
'lastName': 'Beecher',
'userStatus': 'Helping to design the look and feel of the new web site',
'jobTitle': 'Graphic Designer',
'statusUpdatedAt': '2011-02-15T20:20:13.432+0000',
'mobile': '0112211001100',
'emailNotificationsEnabled': true,
'description': 'Alice is a demo user for the sample Alfresco Team site.',
'telephone': '0112211001100',
'enabled': false,
'firstName': 'Alice',
'skypeId': 'abeecher',
'avatarId': '198500fc-1e99-4f5f-8926-248cea433366',
'location': 'Tilbury, UK',
'company': {
'organization': 'Moresby, Garland and Wedge',
'address1': '200 Butterwick Street',
'address2': 'Tilbury',
'address3': 'UK',
'postcode': 'ALF1 SAM1'
},
'id': 'abeecher',
'email': 'abeecher@example.com'
},
'id': 'abeecher'
}
}
]
}
}
}
}, {
'entry': {
'visibility': 'PUBLIC',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'PUBLIC-SITE',
'preset': 'site-dashboard',
'title': 'FAKE-SITE-PUBLIC'
}
}, {
'entry': {
'visibility': 'PRIVATE',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'MEMBER-SITE',
'preset': 'site-dashboard',
'title': 'FAKE-PRIVATE-SITE-MEMBER'
},
'relations': {
'members': {
'list': {
'pagination': {
'count': 3,
'hasMoreItems': false,
'skipCount': 0,
'maxItems': 100
},
'entries': [
{
'entry': {
'role': 'SiteManager',
'person': {
'firstName': 'Administrator',
'emailNotificationsEnabled': true,
'company': {},
'id': 'admin',
'enabled': true,
'email': 'admin@alfresco.com'
},
'id': 'test'
}
}
]
}
}
}
}
]
}
}));
fixture = TestBed.createComponent(DropdownSitesComponent); fixture = TestBed.createComponent(DropdownSitesComponent);
debug = fixture.debugElement; debug = fixture.debugElement;

View File

@@ -142,8 +142,8 @@ export class DropdownSitesComponent implements OnInit, OnDestroy {
if (!this.hideMyFiles) { if (!this.hideMyFiles) {
const siteEntry = new SiteEntry({ const siteEntry = new SiteEntry({
entry: { entry: {
id: '-my-', id: this.MY_FILES_VALUE,
guid: '-my-', guid: this.MY_FILES_VALUE,
title: 'DROPDOWN.MY_FILES_OPTION' title: 'DROPDOWN.MY_FILES_OPTION'
} }
}); });
@@ -151,7 +151,7 @@ export class DropdownSitesComponent implements OnInit, OnDestroy {
this.siteList.list.entries.unshift(siteEntry); this.siteList.list.entries.unshift(siteEntry);
if (!this.value) { if (!this.value) {
this.value = '-my-'; this.value = this.MY_FILES_VALUE;
} }
} }
@@ -164,6 +164,10 @@ export class DropdownSitesComponent implements OnInit, OnDestroy {
this.selected = this.siteList.list.entries.find((site: SiteEntry) => site.entry.id === this.value); this.selected = this.siteList.list.entries.find((site: SiteEntry) => site.entry.id === this.value);
if (this.value && !this.selected && this.siteListHasMoreItems()) {
this.loadSiteList();
}
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
@@ -172,11 +176,15 @@ export class DropdownSitesComponent implements OnInit, OnDestroy {
} }
showLoading(): boolean { showLoading(): boolean {
return this.loading && (this.siteList && this.siteList.list.pagination && this.siteList.list.pagination.hasMoreItems); return this.loading && this.siteListHasMoreItems();
} }
isInfiniteScrollingEnabled(): boolean { isInfiniteScrollingEnabled(): boolean {
return !this.loading && (this.siteList && this.siteList.list.pagination && this.siteList.list.pagination.hasMoreItems); return !this.loading && this.siteListHasMoreItems();
}
private siteListHasMoreItems(): boolean {
return this.siteList && this.siteList.list.pagination && this.siteList.list.pagination.hasMoreItems;
} }
private filteredResultsByMember(sites: SitePaging): SitePaging { private filteredResultsByMember(sites: SitePaging): SitePaging {
@@ -191,5 +199,4 @@ export class DropdownSitesComponent implements OnInit, OnDestroy {
return member.entry.id.toLowerCase() === loggedUserName.toLowerCase(); return member.entry.id.toLowerCase() === loggedUserName.toLowerCase();
}); });
} }
} }

View File

@@ -17,6 +17,7 @@
import { AlfrescoApiService } from '../../services/alfresco-api.service'; import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LogService } from '../../services/log.service'; import { LogService } from '../../services/log.service';
import { SitesService } from '../../services/sites.service';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoApiCompatibility, MinimalNode, RelatedContentRepresentation } from '@alfresco/js-api'; import { AlfrescoApiCompatibility, MinimalNode, RelatedContentRepresentation } from '@alfresco/js-api';
import { Observable, from, throwError } from 'rxjs'; import { Observable, from, throwError } from 'rxjs';
@@ -33,7 +34,8 @@ export class ActivitiContentService {
static GENERIC_ERROR_MESSAGE: string = 'Server error'; static GENERIC_ERROR_MESSAGE: string = 'Server error';
constructor(private apiService: AlfrescoApiService, constructor(private apiService: AlfrescoApiService,
private logService: LogService) { private logService: LogService,
private sitesService: SitesService) {
} }
/** /**
@@ -94,7 +96,7 @@ export class ActivitiContentService {
applyAlfrescoNode(node: MinimalNode, siteId: string, accountId: string) { applyAlfrescoNode(node: MinimalNode, siteId: string, accountId: string) {
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance(); const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
const currentSideId = siteId ? siteId : this.getSiteNameFromNodePath(node); const currentSideId = siteId ? siteId : this.sitesService.getSiteNameFromNodePath(node);
const params: RelatedContentRepresentation = { const params: RelatedContentRepresentation = {
source: accountId, source: accountId,
mimeType: node.content.mimeType, mimeType: node.content.mimeType,
@@ -109,18 +111,6 @@ export class ActivitiContentService {
); );
} }
private getSiteNameFromNodePath(node: MinimalNode): string {
let siteName = '';
if (node.path) {
const foundNode = node.path
.elements.find((pathNode: MinimalNode) =>
pathNode.nodeType === 'st:site' &&
pathNode.name !== 'Sites');
siteName = foundNode ? foundNode.name : '';
}
return siteName.toLocaleLowerCase();
}
toJson(res: any) { toJson(res: any) {
if (res) { if (res) {
return res || {}; return res || {};

View File

@@ -18,7 +18,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable, from, throwError } from 'rxjs'; import { Observable, from, throwError } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service'; import { AlfrescoApiService } from './alfresco-api.service';
import { SitePaging, SiteEntry, SitesApi, SiteMembershipRequestWithPersonPaging } from '@alfresco/js-api'; import { SitePaging, SiteEntry, MinimalNode, SitesApi, SiteMembershipRequestWithPersonPaging } from '@alfresco/js-api';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
@Injectable({ @Injectable({
@@ -103,6 +103,24 @@ export class SitesService {
return this.apiService.getInstance().getEcmUsername(); return this.apiService.getInstance().getEcmUsername();
} }
/**
* Looks for a site inside the path of a Node and returns its guid if it finds one.
* (return an empty string if no site is found)
* @param node Node to look for parent site
* @returns Site guid
*/
getSiteNameFromNodePath(node: MinimalNode): string {
let siteName = '';
if (node.path && node.path.elements) {
const foundNode = node.path
.elements.find((pathNode: MinimalNode) =>
pathNode.nodeType === 'st:site' &&
pathNode.name !== 'Sites');
siteName = foundNode ? foundNode.name : '';
}
return siteName.toLocaleLowerCase();
}
/** /**
* Gets a list of site membership requests. * Gets a list of site membership requests.
* @param opts Options supported by JS-API * @param opts Options supported by JS-API

View File

@@ -1,6 +1,8 @@
<header <header
mat-dialog-title 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> </header>
<mat-dialog-content class="adf-login-dialog-content"> <mat-dialog-content class="adf-login-dialog-content">
@@ -10,7 +12,8 @@
id="attach-file-content-node" id="attach-file-content-node"
[isSelectionValid]="data?.isSelectionValid" [isSelectionValid]="data?.isSelectionValid"
[showFilesInResult]="data?.showFilesInResult" [showFilesInResult]="data?.showFilesInResult"
(select)="onSelect($event)"> (select)="onSelect($event)"
(siteChange)="onSiteChange($event)">
</adf-content-node-selector-panel> </adf-content-node-selector-panel>
</mat-dialog-content> </mat-dialog-content>

View File

@@ -145,22 +145,14 @@ describe('AttachFileWidgetDialogComponent', () => {
}); });
}); });
it('should update the title when the selected node is a file', () => { it('should update the title when a site is selected', () => {
const fakeNode: Node = new Node({ id: 'fake', isFile: true}); const fakeSiteTitle = 'My fake site';
contentNodePanel.componentInstance.select.emit([fakeNode]); contentNodePanel.componentInstance.siteChange.emit(fakeSiteTitle);
fixture.detectChanges(); fixture.detectChanges();
const titleElement = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-title"]')); const titleElement = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-title"]'));
expect(titleElement).not.toBeNull(); expect(titleElement).not.toBeNull();
expect(titleElement.nativeElement.innerText).toBe('ATTACH-FILE.ACTIONS.CHOOSE_ITEM'); 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');
});
}); });
}); });

View File

@@ -50,7 +50,7 @@ export class AttachFileWidgetDialogComponent {
(<any> externalApiService).init(data.ecmHost, data.context); (<any> externalApiService).init(data.ecmHost, data.context);
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE'; this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
this.buttonActionName = `ATTACH-FILE.ACTIONS.${this.action}`; this.buttonActionName = `ATTACH-FILE.ACTIONS.${this.action}`;
this.title = data.title; this.updateTitle('DROPDOWN.MY_FILES_OPTION');
} }
isLoggedIn() { isLoggedIn() {
@@ -66,12 +66,11 @@ export class AttachFileWidgetDialogComponent {
} }
onSelect(nodeList: Node[]) { onSelect(nodeList: Node[]) {
if (nodeList && nodeList[0].isFile) {
this.chosenNode = nodeList; this.chosenNode = nodeList;
} else {
this.chosenNode = null;
} }
this.updateTitle(nodeList);
onSiteChange(siteTitle: string) {
this.updateTitle(siteTitle);
} }
onClick() { onClick() {
@@ -79,17 +78,13 @@ export class AttachFileWidgetDialogComponent {
this.data.selected.complete(); this.data.selected.complete();
} }
updateTitle(nodeList: Node[]): void { updateTitle(siteTitle: string) {
if (this.action === 'CHOOSE' && nodeList) { if (this.action === 'CHOOSE' && siteTitle) {
if (nodeList[0].isFile) { this.title = this.getTitleTranslation(this.action, siteTitle);
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);
}
} }
} }
getTitleTranslation(action: string, name: string): string { getTitleTranslation(action: string, name?: string): string {
return this.translation.instant(`ATTACH-FILE.ACTIONS.${action}`, { name }); return this.translation.instant(`ATTACH-FILE.ACTIONS.${action}_ITEM`, { name: this.translation.instant(name) });
} }
} }

View File

@@ -54,7 +54,7 @@ export class AttachFileWidgetDialogService {
selected, selected,
ecmHost, ecmHost,
context, context,
isSelectionValid: this.isNodeValid.bind(this), isSelectionValid: this.isNodeFile.bind(this),
showFilesInResult: true showFilesInResult: true
}; };
@@ -71,8 +71,8 @@ export class AttachFileWidgetDialogService {
this.dialog.closeAll(); this.dialog.closeAll();
} }
private isNodeValid(entry: Node): boolean { private isNodeFile(entry: Node): boolean {
return entry.isFile || entry.isFolder; return entry.isFile;
} }
private getLoginTitleTranslation(ecmHost: string): string { private getLoginTitleTranslation(ecmHost: string): string {