[ADF-3930] Can't load more results in Copy/Move dialog (#4247)

* fix unrelated failing test
improve type definition
add set get filtering node selector
fix directive highlight
fix minor problem style breadcrumb
small refactoring problem documentlist

* fix lint style

* fix html node

* fix test
This commit is contained in:
Eugenio Romano
2019-02-03 20:10:54 +00:00
committed by GitHub
parent 50572e9db5
commit fec2b89b2d
25 changed files with 288 additions and 362 deletions
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange } from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PathElementEntity } from '@alfresco/js-api';
import { setupTestBed } from '@alfresco/adf-core';
@@ -52,10 +52,9 @@ describe('Breadcrumb', () => {
});
it('should root be present as default node if the path is null', () => {
let change = new SimpleChange(null, fakeNodeWithCreatePermission, true);
component.root = 'default';
component.ngOnChanges({ 'folderNode': change });
component.folderNode = fakeNodeWithCreatePermission;
component.ngOnChanges(null);
expect(component.route[0].name).toBe('default');
});
@@ -211,8 +210,8 @@ describe('Breadcrumb', () => {
transformNode.name = 'test-name';
return transformNode;
});
let change = new SimpleChange(null, node, true);
component.ngOnChanges({ 'folderNode': change });
component.folderNode = node;
component.ngOnChanges(null);
expect(component.route.length).toBe(4);
expect(component.route[3].id).toBe('test-id');
expect(component.route[3].name).toBe('test-name');
@@ -15,7 +15,17 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core';
import {
Component,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
SimpleChanges,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import { MatSelect } from '@angular/material';
import { Node, PathElementEntity } from '@alfresco/js-api';
import { DocumentListComponent } from '../document-list';
@@ -84,23 +94,24 @@ export class BreadcrumbComponent implements OnInit, OnChanges {
ngOnInit() {
this.transform = this.transform ? this.transform : null;
if (this.target) {
this.target.$folderNode.subscribe((folderNode: Node) => {
this.folderNode = folderNode;
this.recalculateNodes();
});
}
}
ngOnChanges(changes: SimpleChanges): void {
if (changes.folderNode) {
let node: Node = null;
node = this.transform ? this.transform(changes.folderNode.currentValue) : changes.folderNode.currentValue;
this.route = this.parseRoute(node);
}
if (changes.transform) {
let node = this.transform ? this.transform(this.folderNode) : this.folderNode;
this.route = this.parseRoute(node);
}
this.recalculateNodes();
}
protected recalculateNodes(): void {
let node: Node = this.transform ? this.transform(this.folderNode) : this.folderNode;
this.route = this.parseRoute(node);
if (this.maxItems && this.route.length > this.maxItems) {
this.lastNodes = this.route.slice(this.route.length - this.maxItems);
this.previousNodes = this.route.slice(0, this.route.length - this.maxItems);
@@ -127,7 +138,8 @@ export class BreadcrumbComponent implements OnInit, OnChanges {
route.push(<PathElementEntity> {
id: node.id,
name: node.name
name: node.name,
node: node
});
const rootPos = this.getElementPosition(route, this.rootId);
@@ -10,6 +10,7 @@
}
&-dropdown-breadcrumb-trigger {
height: 0;
cursor: pointer;
padding: 0;
border: none;
@@ -21,10 +22,6 @@
}
}
&-dropdown-breadcrumb-item-chevron {
margin-top: 5px;
}
&-dropdown-breadcrumb-trigger.adf-isRoot {
cursor: not-allowed;
}
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange } from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { setupTestBed } from '@alfresco/adf-core';
@@ -52,8 +52,8 @@ describe('DropdownBreadcrumb', () => {
}
function triggerComponentChange(fakeNodeData) {
const change = new SimpleChange(null, fakeNodeData, true);
component.ngOnChanges({ 'folderNode': change });
component.folderNode = fakeNodeData;
component.ngOnChanges(null);
fixture.detectChanges();
}
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, OnChanges, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core';
import { Component, OnChanges, ViewChild, ViewEncapsulation } from '@angular/core';
import { MatSelect } from '@angular/material';
import { PathElementEntity, Node } from '@alfresco/js-api';
import { BreadcrumbComponent } from './breadcrumb.component';
@@ -37,24 +37,13 @@ export class DropdownBreadcrumbComponent extends BreadcrumbComponent implements
currentNode: PathElementEntity;
previousNodes: PathElementEntity[];
ngOnChanges(changes: SimpleChanges): void {
if (changes.folderNode) {
let node: Node = null;
node = this.transform ? this.transform(changes.folderNode.currentValue) : changes.folderNode.currentValue;
this.route = this.parseRoute(node);
}
if (changes.transform) {
let node = this.transform ? this.transform(this.folderNode) : this.folderNode;
this.route = this.parseRoute(node);
}
this.recalculateNodes();
}
/**
* Calculate the current and previous nodes from the route array
*/
protected recalculateNodes(): void {
let node: Node = this.transform ? this.transform(this.folderNode) : this.folderNode;
this.route = this.parseRoute(node);
this.currentNode = this.route[this.route.length - 1];
this.previousNodes = this.route.slice(0, this.route.length - 1).reverse();
}
@@ -15,6 +15,8 @@
* limitations under the License.
*/
import { Node } from '@alfresco/js-api';
export interface NavigableComponentInterface {
navigateTo(nodeId: string);
navigateTo(node: Node | string);
}