diff --git a/src/app/common/common.module.ts b/src/app/common/common.module.ts
index f6ea225ba..ec7a4e960 100644
--- a/src/app/common/common.module.ts
+++ b/src/app/common/common.module.ts
@@ -38,6 +38,7 @@ import { NodeMoveDirective } from './directives/node-move.directive';
import { NodeRestoreDirective } from './directives/node-restore.directive';
import { NodePermanentDeleteDirective } from './directives/node-permanent-delete.directive';
import { NodeUnshareDirective } from './directives/node-unshare.directive';
+import { NodeInfoDirective} from './directives/node-info.directive';
import { ContentManagementService } from './services/content-management.service';
import { BrowsingFilesService } from './services/browsing-files.service';
@@ -61,7 +62,8 @@ export function declarations() {
NodeMoveDirective,
NodeRestoreDirective,
NodePermanentDeleteDirective,
- NodeUnshareDirective
+ NodeUnshareDirective,
+ NodeInfoDirective
];
}
diff --git a/src/app/common/directives/node-info.directive.spec.ts b/src/app/common/directives/node-info.directive.spec.ts
new file mode 100644
index 000000000..4fcff8c88
--- /dev/null
+++ b/src/app/common/directives/node-info.directive.spec.ts
@@ -0,0 +1,103 @@
+/*!
+ * @license
+ * Alfresco Example Content Application
+ *
+ * Copyright (C) 2005 - 2018 Alfresco Software Limited
+ *
+ * This file is part of the Alfresco Example Content Application.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The Alfresco Example Content Application is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+
+import { Component } from '@angular/core';
+import { ComponentFixture, TestBed, async, fakeAsync, tick } from '@angular/core/testing';
+import { AlfrescoApiService } from '@alfresco/adf-core';
+import { CommonModule } from '../common.module';
+
+@Component({
+ template: '
'
+})
+class TestComponent {
+ selection;
+}
+
+describe('NodeInfoDirective', () => {
+ let fixture: ComponentFixture;
+ let component: TestComponent;
+ let apiService: AlfrescoApiService;
+ let nodeService;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CommonModule
+ ],
+ declarations: [
+ TestComponent
+ ]
+ });
+
+ fixture = TestBed.createComponent(TestComponent);
+ component = fixture.componentInstance;
+ apiService = TestBed.get(AlfrescoApiService);
+ nodeService = apiService.getInstance().nodes;
+
+ fixture.detectChanges();
+ }));
+
+ beforeEach(() => {
+ spyOn(nodeService, 'getNodeInfo').and.returnValue(Promise.resolve({
+ entry: { name: 'borg' }
+ }));
+ });
+
+ it('should not get node info when selection is empty', () => {
+ component.selection = [];
+
+ fixture.detectChanges();
+ document.dispatchEvent(new CustomEvent('click'));
+
+ expect(nodeService.getNodeInfo).not.toHaveBeenCalled();
+ });
+
+ it('should get node info from selection', () => {
+ component.selection = [{ entry: { id: 'id' } }];
+
+ fixture.detectChanges();
+ document.dispatchEvent(new CustomEvent('click'));
+
+ expect(nodeService.getNodeInfo).toHaveBeenCalledWith('id');
+ });
+
+
+ it('should get node info of last entry when selecting multiple nodes', fakeAsync(() => {
+ component.selection = [
+ { entry: { id: 'id1', isFile: true } },
+ { entry: { id: 'id2', isFile: true } },
+ { entry: { id: 'id3', isFile: true } }
+ ];
+
+ fixture.detectChanges();
+
+ document.dispatchEvent(new CustomEvent('click'));
+
+ fixture.detectChanges();
+ tick();
+
+ expect(nodeService.getNodeInfo).toHaveBeenCalledWith('id3');
+ }));
+});
diff --git a/src/app/common/directives/node-info.directive.ts b/src/app/common/directives/node-info.directive.ts
new file mode 100644
index 000000000..1e20cca09
--- /dev/null
+++ b/src/app/common/directives/node-info.directive.ts
@@ -0,0 +1,76 @@
+/*!
+ * @license
+ * Alfresco Example Content Application
+ *
+ * Copyright (C) 2005 - 2018 Alfresco Software Limited
+ *
+ * This file is part of the Alfresco Example Content Application.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The Alfresco Example Content Application is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+
+import { Directive, HostListener, Input, Output, EventEmitter } from '@angular/core';
+import { AlfrescoApiService } from '@alfresco/adf-core';
+import { MinimalNodeEntity, MinimalNodeEntryEntity, Node } from 'alfresco-js-api';
+
+@Directive({
+ selector: '[app-node-info]',
+ exportAs: 'nodeInfo'
+})
+
+export class NodeInfoDirective {
+ @Input('app-node-info') selection: MinimalNodeEntity[];
+ @Output() changed: EventEmitter = new EventEmitter();
+ @Output() error: EventEmitter = new EventEmitter();
+
+ node: Node;
+ loading: boolean = null;
+
+ @HostListener('document:click', ['$event'])
+ onClick(event) {
+ this.getNodeInfo();
+ }
+
+ constructor(private apiService: AlfrescoApiService) {}
+
+ getNodeInfo() {
+ if (!this.selection.length) {
+ this.node = null;
+ this.loading = false;
+ this.changed.emit(null);
+ return;
+ }
+
+ const node = this.selection[this.selection.length - 1];
+
+ if (node) {
+ this.loading = true;
+
+ this.apiService.getInstance().nodes
+ .getNodeInfo((node.entry).nodeId || node.entry.id)
+ .then((data: MinimalNodeEntryEntity) => {
+ this.node = data;
+ this.changed.emit(data);
+ this.loading = false;
+ })
+ .catch(() => {
+ this.error.emit();
+ this.loading = false;
+ });
+ }
+ }
+}
diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html
index bd894cfe2..79add4481 100644
--- a/src/app/components/favorites/favorites.component.html
+++ b/src/app/components/favorites/favorites.component.html
@@ -29,6 +29,13 @@
create
+
+
+
+
+
+
+
+