mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4400] Versioning - restore does not update the document list (#4605)
* emit NodeInfo data on restore * update row data and cache on node update event * tests * fix metadatat e2e
This commit is contained in:
committed by
Eugenio Romano
parent
74e918d916
commit
36ce9bce0d
@@ -17,8 +17,16 @@
|
||||
|
||||
import { DateCellComponent } from './date-cell.component';
|
||||
import { Subject } from 'rxjs';
|
||||
import { AlfrescoApiServiceMock, AppConfigService } from '@alfresco/adf-core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
|
||||
describe('DataTableCellComponent', () => {
|
||||
let alfrescoApiService: AlfrescoApiServiceMock;
|
||||
|
||||
beforeEach(() => {
|
||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null));
|
||||
});
|
||||
|
||||
it('should use medium format by default', () => {
|
||||
const component = new DateCellComponent(null, null);
|
||||
expect(component.format).toBe('medium');
|
||||
@@ -37,4 +45,72 @@ describe('DataTableCellComponent', () => {
|
||||
component.ngOnInit();
|
||||
expect(component.format).toBe('longTime');
|
||||
});
|
||||
|
||||
it('should update cell data on alfrescoApiService.nodeUpdated event', () => {
|
||||
const component = new DateCellComponent(
|
||||
null,
|
||||
alfrescoApiService
|
||||
);
|
||||
|
||||
component.column = {
|
||||
key: 'name',
|
||||
type: 'text'
|
||||
};
|
||||
|
||||
component.row = <any> {
|
||||
cache: {
|
||||
name: 'some-name'
|
||||
},
|
||||
node: {
|
||||
entry: {
|
||||
id: 'id',
|
||||
name: 'test-name'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
alfrescoApiService.nodeUpdated.next(<Node> {
|
||||
id: 'id',
|
||||
name: 'updated-name'
|
||||
});
|
||||
|
||||
expect(component.row['node'].entry.name).toBe('updated-name');
|
||||
expect(component.row['cache'].name).toBe('updated-name');
|
||||
});
|
||||
|
||||
it('not should update cell data if ids don`t match', () => {
|
||||
const component = new DateCellComponent(
|
||||
null,
|
||||
alfrescoApiService
|
||||
);
|
||||
|
||||
component.column = {
|
||||
key: 'name',
|
||||
type: 'text'
|
||||
};
|
||||
|
||||
component.row = <any> {
|
||||
cache: {
|
||||
name: 'some-name'
|
||||
},
|
||||
node: {
|
||||
entry: {
|
||||
id: 'some-id',
|
||||
name: 'test-name'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
alfrescoApiService.nodeUpdated.next(<Node> {
|
||||
id: 'id',
|
||||
name: 'updated-name'
|
||||
});
|
||||
|
||||
expect(component.row['node'].entry.name).not.toBe('updated-name');
|
||||
expect(component.row['cache'].name).not.toBe('updated-name');
|
||||
});
|
||||
});
|
||||
|
@@ -85,10 +85,9 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
|
||||
this.updateValue();
|
||||
this.sub = this.alfrescoApiService.nodeUpdated.subscribe((node: Node) => {
|
||||
if (this.row) {
|
||||
const { entry } = this.row['node'];
|
||||
|
||||
if (entry === node) {
|
||||
this.row['node'] = { entry };
|
||||
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.updateValue();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user