[ACA-3474] [Info Drawer] Error on save (#5791)

This commit is contained in:
dhrn
2020-06-20 19:26:41 +05:30
committed by GitHub
parent 2baae61cc5
commit 5a0ba6666d
2 changed files with 47 additions and 1 deletions

View File

@@ -115,4 +115,50 @@ describe('DataTableCellComponent', () => {
expect(component.row['node'].entry.name).not.toBe('updated-name');
expect(component.row['cache'].name).not.toBe('updated-name');
});
it('not should throw error if key not found', () => {
const component = new DateCellComponent(
null,
alfrescoApiService,
new AppConfigService(null)
);
component.column = {
key: 'contentSize.sizeInBytes',
type: 'text'
};
component.row = <any> {
cache: {
name: 'some-name'
},
node: {
entry: {
id: 'id',
name: 'some-name',
contentSize: {
sizeInBytes: '12Mb'
}
}
}
};
component.ngOnInit();
alfrescoApiService.nodeUpdated.next({
id: 'id',
contentSize: { sizeInBytes: '11Mb' }
} as any);
expect(component.row['node'].entry.contentSize.sizeInBytes).toBe('11Mb');
expect(component.row['cache']['contentSize.sizeInBytes']).toBe('11Mb');
alfrescoApiService.nodeUpdated.next({
id: 'id',
name: 'updated-name'
} as any);
expect(component.row['node'].entry.name).toBe('updated-name');
expect(component.row['cache']['contentSize.sizeInBytes']).toBe('');
});
});

View File

@@ -93,7 +93,7 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
if (this.row) {
if (this.row['node'].entry.id === node.id) {
this.row['node'].entry = node;
this.row['cache'][this.column.key] = this.column.key.split('.').reduce((source, key) => source[key], node);
this.row['cache'][this.column.key] = this.column.key.split('.').reduce((source, key) => source ? source[key] : '', node);
this.updateValue();
}
}