mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-08 14:51:14 +00:00
render condition (#80)
This commit is contained in:
committed by
Denys Vuika
parent
4b2c0dfab7
commit
ac6c9e961d
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
|
*ngIf="showEditOption(documentList.selection)"
|
||||||
title="{{ 'APP.ACTIONS.EDIT' | translate }}"
|
title="{{ 'APP.ACTIONS.EDIT' | translate }}"
|
||||||
[adf-edit-folder]="documentList.selection[0]?.entry">
|
[adf-edit-folder]="documentList.selection[0]?.entry">
|
||||||
<mat-icon>create</mat-icon>
|
<mat-icon>create</mat-icon>
|
||||||
|
@@ -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', () => {
|
describe('refresh', () => {
|
||||||
it('should call document list reload', () => {
|
it('should call document list reload', () => {
|
||||||
spyOn(component.documentList, 'reload');
|
spyOn(component.documentList, 'reload');
|
||||||
|
@@ -19,7 +19,7 @@ import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs/Rx';
|
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 { ContentService, NodesApiService } from '@alfresco/adf-core';
|
||||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
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 {
|
refresh(): void {
|
||||||
if (this.documentList) {
|
if (this.documentList) {
|
||||||
this.documentList.reload();
|
this.documentList.reload();
|
||||||
|
Reference in New Issue
Block a user