render condition (#80)

This commit is contained in:
Cilibiu Bogdan
2017-11-24 11:49:58 +02:00
committed by Denys Vuika
parent 4b2c0dfab7
commit ac6c9e961d
3 changed files with 56 additions and 1 deletions

View File

@@ -23,6 +23,7 @@
<button
mat-icon-button
*ngIf="showEditOption(documentList.selection)"
title="{{ 'APP.ACTIONS.EDIT' | translate }}"
[adf-edit-folder]="documentList.selection[0]?.entry">
<mat-icon>create</mat-icon>

View File

@@ -179,6 +179,56 @@ describe('Favorites Routed Component', () => {
});
});
describe('edit option', () => {
it('should return false if a file node is selected', () => {
const selection = [
{
entry: {
isFolder: false,
isFile: true
}
}
];
const result = component.showEditOption(selection);
expect(result).toBe(false);
});
it('should return false if multiple nodes are selected', () => {
const selection = [
{
entry: {
isFolder: true,
isFile: false
}
},
{
entry: {
isFolder: true,
isFile: false
}
}
];
const result = component.showEditOption(selection);
expect(result).toBe(false);
});
it('should return true if selected node is a folder', () => {
const selection = [
{
entry: {
isFolder: true,
isFile: false
}
}
];
const result = component.showEditOption(selection);
expect(result).toBe(true);
});
});
describe('refresh', () => {
it('should call document list reload', () => {
spyOn(component.documentList, 'reload');

View File

@@ -19,7 +19,7 @@ import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs/Rx';
import { MinimalNodeEntryEntity, PathElementEntity, PathInfo } from 'alfresco-js-api';
import { MinimalNodeEntryEntity, MinimalNodeEntity, PathElementEntity, PathInfo } from 'alfresco-js-api';
import { ContentService, NodesApiService } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
@@ -92,6 +92,10 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr
}
}
showEditOption(selection: MinimalNodeEntity[]) {
return selection && selection.length === 1 && selection[0].entry.isFolder;
}
refresh(): void {
if (this.documentList) {
this.documentList.reload();