1 |
|
2 | import {Column} from "../entities/column";
|
3 | import {RowNode} from "../entities/rowNode";
|
4 | import {Autowired, Bean, PostConstruct} from "../context/context";
|
5 | import {GridOptionsWrapper} from "../gridOptionsWrapper";
|
6 | import {ChangedPath} from "../rowModels/clientSide/changedPath";
|
7 | import {IRowModel} from "../interfaces/iRowModel";
|
8 | import {ClientSideRowModel} from "../rowModels/clientSide/clientSideRowModel";
|
9 | import {RowRenderer} from "../rendering/rowRenderer";
|
10 | import {EventService} from "../eventService";
|
11 | import {Constants} from "../constants";
|
12 | import {BeanStub} from "../context/beanStub";
|
13 | import {Events} from "../events";
|
14 |
|
15 | @Bean('changeDetectionService')
|
16 | export class ChangeDetectionService extends BeanStub {
|
17 |
|
18 | @Autowired('gridOptionsWrapper') private gridOptionsWrapper: GridOptionsWrapper;
|
19 | @Autowired('rowModel') private rowModel: IRowModel;
|
20 | @Autowired('rowRenderer') private rowRenderer: RowRenderer;
|
21 | @Autowired('eventService') private eventService: EventService;
|
22 |
|
23 | private clientSideRowModel: ClientSideRowModel;
|
24 |
|
25 | @PostConstruct
|
26 | private init(): void {
|
27 | if (this.rowModel.getType()===Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
|
28 | this.clientSideRowModel = <ClientSideRowModel> this.rowModel;
|
29 | }
|
30 |
|
31 | this.addDestroyableEventListener(this.eventService, Events.EVENT_CELL_VALUE_CHANGED, this.onCellValueChanged.bind(this));
|
32 | }
|
33 |
|
34 | private onCellValueChanged(event: any): void {
|
35 | this.doChangeDetection(event.node, event.column);
|
36 | }
|
37 |
|
38 | private doChangeDetection(rowNode: RowNode, column: Column): void {
|
39 | if (this.gridOptionsWrapper.isSuppressChangeDetection()) { return; }
|
40 |
|
41 |
|
42 | if (this.clientSideRowModel && !rowNode.isRowPinned()) {
|
43 | let onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns();
|
44 | let changedPath = new ChangedPath(onlyChangedColumns);
|
45 | changedPath.addParentNode(rowNode.parent, [column]);
|
46 | this.clientSideRowModel.doAggregate(changedPath);
|
47 | }
|
48 |
|
49 |
|
50 | this.rowRenderer.refreshCells();
|
51 | }
|
52 |
|
53 | } |
\ | No newline at end of file |