[ADF-1981] Continous loading of task details if task list is empty

This commit is contained in:
Eugenio Romano
2017-11-22 17:32:37 +00:00
parent 01ff35a786
commit 7870772fbd
3 changed files with 26 additions and 27 deletions

View File

@@ -6,10 +6,10 @@
(executeRowAction)="onExecuteRowAction($event)"> (executeRowAction)="onExecuteRowAction($event)">
<adf-empty-list *ngIf="isEmpty()"> <adf-empty-list *ngIf="isEmpty()">
<div adf-empty-list-header class="adf-empty-list-header" *ngIf="!isCustomTemplateDefined()"> <div *ngIf="!isCustomTemplateDefined()" adf-empty-list-header class="adf-empty-list-header">
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER' | translate}} {{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER' | translate}}
</div> </div>
<div *ngIf="!isDisabled()" #customEmptyListTemplate class="adf-custom-empty-template"> <div *ngIf="isCustomTemplateDefined()" #customEmptyListTemplate class="adf-custom-empty-template">
<ng-content select="[adf-empty-list]"></ng-content> <ng-content select="[adf-empty-list]"></ng-content>
</div> </div>
</adf-empty-list> </adf-empty-list>

View File

@@ -96,9 +96,7 @@ describe('TaskAttachmentList', () => {
deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(Observable.of({successCode: true})); deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(Observable.of({successCode: true}));
let blobObj = new Blob(); let blobObj = new Blob();
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of( getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of(blobObj));
blobObj;
}); });
it('should load attachments when taskId specified', () => { it('should load attachments when taskId specified', () => {
@@ -152,7 +150,7 @@ describe('TaskAttachmentList', () => {
expect(getFileRawContentSpy).toHaveBeenCalled(); expect(getFileRawContentSpy).toHaveBeenCalled();
}); });
it('should show the empty list drag and drop component when the task is not completed', async(() => { it('should show the empty default message when has no custom template', async(() => {
getTaskRelatedContentSpy.and.returnValue(Observable.of({ getTaskRelatedContentSpy.and.returnValue(Observable.of({
'size': 0, 'size': 0,
'total': 0, 'total': 0,
@@ -161,24 +159,7 @@ describe('TaskAttachmentList', () => {
})); }));
let change = new SimpleChange(null, '123', true); let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ 'taskId': change });
component.disabled = false; component.hasCustomTemplate = false;
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('.adf-custom-empty-template')).not.toBeNull();
});
}));
it('should not show the empty list drag and drop component when is disabled', async(() => {
getTaskRelatedContentSpy.and.returnValue(Observable.of({
'size': 0,
'total': 0,
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.disabled = true;
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -187,6 +168,23 @@ describe('TaskAttachmentList', () => {
}); });
})); }));
it('should not show the custom empty message when has custom template', async(() => {
getTaskRelatedContentSpy.and.returnValue(Observable.of({
'size': 0,
'total': 0,
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.hasCustomTemplate = true;
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('.adf-custom-empty-template')).not.toBeNull();
});
}));
it('should display all actions if attachments are not read only', () => { it('should display all actions if attachments are not read only', () => {
let change = new SimpleChange(null, '123', true); let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ 'taskId': change });

View File

@@ -42,9 +42,10 @@ export class TaskAttachmentListComponent implements OnChanges, AfterViewInit {
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error: EventEmitter<any> = new EventEmitter<any>();
hasCustomTemplate: boolean; hasCustomTemplate: boolean = false;
@ViewChild('customEmptyListTemplate') customTemplateRef: ElementRef; @ViewChild('customEmptyListTemplate')
customTemplateRef: ElementRef;
attachments: any[] = []; attachments: any[] = [];
isLoading: boolean = true; isLoading: boolean = true;
@@ -66,7 +67,7 @@ export class TaskAttachmentListComponent implements OnChanges, AfterViewInit {
this.customTemplateRef.nativeElement.children && this.customTemplateRef.nativeElement.children.length > 0) { this.customTemplateRef.nativeElement.children && this.customTemplateRef.nativeElement.children.length > 0) {
this.hasCustomTemplate = true; this.hasCustomTemplate = true;
} }
} }
reset(): void { reset(): void {
this.attachments = []; this.attachments = [];