Skip to content

Commit 2f3d1fe

Browse files
committed
chore(*): Addressing pr comments
1 parent 67ef591 commit 2f3d1fe

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ All notable changes for each version of this project will be documented in this
55
## 10.0.0
66

77
### General
8-
- `IgxTransaction` - The `onStateUpdate` now emits with information of its origin. The emitted value is of type `IStateUpdateEvent`, which has two properies:
9-
- `origin` - a mandatory property. It can vary within the values of the `TransactionEventOrigin` interface;
10-
- `actions` - an optional property that contains information about the transactions, that caused the emission of the event. It is used by `undo` and `redo`.
8+
- `IgxTransaction` - The `onStateUpdate` now emits with information of its origin. The emitted value is of type `StateUpdateEvent`, which has two properies:
9+
- `origin` - it can vary within the values of the `TransactionEventOrigin` interface;
10+
- `actions` - contains information about the transactions, that caused the emission of the event.
1111

1212

1313
## 9.1.1

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
PositionSettings,
4848
ConnectedPositioningStrategy,
4949
ContainerPositionStrategy,
50-
IStateUpdateEvent,
50+
StateUpdateEvent,
5151
TransactionEventOrigin
5252
} from '../services/public_api';
5353
import { GridBaseAPIService } from './api.service';
@@ -2858,7 +2858,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
28582858
this.summaryService.clearSummaryCache(args);
28592859
});
28602860

2861-
this.transactions.onStateUpdate.pipe(destructor).subscribe((event?: IStateUpdateEvent) => {
2861+
this.transactions.onStateUpdate.pipe(destructor).subscribe((event?: StateUpdateEvent) => {
28622862
let actions = [];
28632863
if (event.origin === TransactionEventOrigin.REDO) {
28642864
actions = event.actions ? event.actions.filter(x => x.transaction.type === TransactionType.DELETE) : [];

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
HierarchicalState,
2323
TransactionType,
2424
TransactionEventOrigin,
25-
IStateUpdateEvent
25+
StateUpdateEvent
2626
} from '../../services/transaction/transaction';
2727
import { IgxHierarchicalTransactionService } from '../../services/public_api';
2828
import { IgxFilteringService } from '../filtering/grid-filtering.service';
@@ -353,7 +353,7 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
353353
this.loadChildrenOnRowExpansion(args);
354354
});
355355

356-
this.transactions.onStateUpdate.pipe(takeUntil<any>(this.destroy$)).subscribe((event?: IStateUpdateEvent) => {
356+
this.transactions.onStateUpdate.pipe(takeUntil<any>(this.destroy$)).subscribe((event?: StateUpdateEvent) => {
357357
let actions = [];
358358
if (event.origin === TransactionEventOrigin.REDO) {
359359
actions = event.actions ? event.actions.filter(x => x.transaction.type === TransactionType.DELETE) : [];

projects/igniteui-angular/src/lib/services/transaction/base-transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TransactionService, Transaction, State, IStateUpdateEvent } from './transaction';
1+
import { TransactionService, Transaction, State, StateUpdateEvent } from './transaction';
22
import { EventEmitter, Injectable } from '@angular/core';
33
import { isObject, mergeObjects, cloneValue } from '../../core/utils';
44

@@ -32,7 +32,7 @@ export class IgxBaseTransactionService<T extends Transaction, S extends State> i
3232
/**
3333
* @inheritdoc
3434
*/
35-
public onStateUpdate = new EventEmitter<IStateUpdateEvent>();
35+
public onStateUpdate = new EventEmitter<StateUpdateEvent>();
3636

3737
/**
3838
* @inheritdoc

projects/igniteui-angular/src/lib/services/transaction/igx-transaction.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Transaction, State, TransactionType, IStateUpdateEvent, TransactionEventOrigin } from './transaction';
1+
import { Transaction, State, TransactionType, StateUpdateEvent, TransactionEventOrigin } from './transaction';
22
import { IgxBaseTransactionService } from './base-transaction';
33
import { EventEmitter, Injectable } from '@angular/core';
44
import { isObject, mergeObjects, cloneValue } from '../../core/utils';
@@ -27,7 +27,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
2727
/**
2828
* @inheritdoc
2929
*/
30-
public onStateUpdate = new EventEmitter<IStateUpdateEvent>();
30+
public onStateUpdate = new EventEmitter<StateUpdateEvent>();
3131

3232
/**
3333
* @inheritdoc
@@ -45,9 +45,10 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
4545
transactions.push(transaction);
4646

4747
if (!this._isPending) {
48-
this._undoStack.push([{ transaction, recordRef }]);
48+
const actions = [{ transaction, recordRef }];
49+
this._undoStack.push(actions);
4950
this._redoStack = [];
50-
this.onStateUpdate.emit({ origin: TransactionEventOrigin.ADD });
51+
this.onStateUpdate.emit({ origin: TransactionEventOrigin.ADD, actions: actions });
5152
}
5253
}
5354

@@ -127,7 +128,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
127128
this._undoStack.push(actions);
128129
this._redoStack = [];
129130

130-
this.onStateUpdate.emit({ origin: TransactionEventOrigin.END});
131+
this.onStateUpdate.emit({ origin: TransactionEventOrigin.END, actions});
131132
}
132133
super.endPending(commit);
133134
}
@@ -167,7 +168,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
167168
this._undoStack = [];
168169
}
169170
this._redoStack = [];
170-
this.onStateUpdate.emit({ origin: TransactionEventOrigin.CLEAR });
171+
this.onStateUpdate.emit({ origin: TransactionEventOrigin.CLEAR, actions: []});
171172
}
172173

173174
/**
@@ -205,7 +206,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
205206
}
206207

207208
this._undoStack.push(actions);
208-
this.onStateUpdate.emit({ origin: TransactionEventOrigin.REDO, actions: actions });
209+
this.onStateUpdate.emit({ origin: TransactionEventOrigin.REDO, actions });
209210
}
210211
}
211212

projects/igniteui-angular/src/lib/services/transaction/transaction.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ export interface State {
3535
type: TransactionType;
3636
}
3737

38-
export interface IStateUpdateEvent {
38+
export interface Action {
39+
transaction: Transaction;
40+
recordRef: any;
41+
}
42+
43+
export interface StateUpdateEvent {
3944
origin: TransactionEventOrigin;
40-
actions?: any;
45+
actions: Array<Action>;
4146
}
4247

4348
/**
@@ -57,7 +62,7 @@ export interface TransactionService<T extends Transaction, S extends State> {
5762
/**
5863
* Event fired when transaction state has changed - add transaction, commit all transactions, undo and redo
5964
*/
60-
onStateUpdate?: EventEmitter<IStateUpdateEvent>;
65+
onStateUpdate?: EventEmitter<StateUpdateEvent>;
6166

6267
/**
6368
* @returns if there are any transactions in the Undo stack

0 commit comments

Comments
 (0)