Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IgxTreeGrid - Editing #2909

Merged
merged 137 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from 128 commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
ac351bc
feat(tree-grid): adding tree grid component #2530
DiyanDimitrov Oct 26, 2018
1c819d8
feat(tree-grid): fixing some style classes #2530
DiyanDimitrov Oct 26, 2018
1fc943f
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 26, 2018
cf45e3c
feat(tree-grid): fixing test references #2530
DiyanDimitrov Oct 26, 2018
9b5c8a2
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 26, 2018
f27a008
feat(tree-grid): fixing some more test references #2530
DiyanDimitrov Oct 26, 2018
fd53939
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 26, 2018
a16e48b
feat(tree-grid): fixing lint errors #2530
DiyanDimitrov Oct 26, 2018
1a9121c
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 26, 2018
7c94bc9
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 29, 2018
9c65956
feat(tree-grid): fixing tree cell selection and editing #2530
DiyanDimitrov Oct 29, 2018
ae5e928
feat(tree-grid): fixing row selection #2530
DiyanDimitrov Oct 29, 2018
4c37600
feat(tree-grid): fixing tree column auto-sizing #2530
DiyanDimitrov Oct 29, 2018
13f5e0b
feat(tree-grid): applying some changes to the destroyMap #2530
DiyanDimitrov Oct 29, 2018
358ba06
feat(tree-grid): fixing the CRUD operations #2530
DiyanDimitrov Oct 29, 2018
4e52138
feat(tree-grid): adding tree-cell style #2530
DiyanDimitrov Oct 29, 2018
7bab4ce
feat(tree-grid): add pending to a failing test #2530
DiyanDimitrov Oct 29, 2018
13a87d3
fix(igxTreeGrid): update treegrid API to incorp. editing, #2530
ViktorSlavov Oct 29, 2018
5a96282
feat(tree-grid): moving some grouping specific code #2530
DiyanDimitrov Oct 29, 2018
e59f5a8
feat(tree-grid): hiding summaries until implemented #2530
DiyanDimitrov Oct 29, 2018
01636ec
fix(igxGrid): add TreeGridTransaction pipe, update mergeTransactions,…
ViktorSlavov Oct 29, 2018
b65c83b
feat(tree-grid): hide exporters for TreeGrid #2530
DiyanDimitrov Oct 29, 2018
88e1add
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 29, 2018
b9c2552
feat(tree-grid): removing defaultDropArea from TreeGrid #2530
DiyanDimitrov Oct 29, 2018
e51ba43
feat(tree-grid): fixing lint errors #2530
DiyanDimitrov Oct 29, 2018
d14b5d1
feat(tree-grid): adding configureTestSuite to TreeGrid tests #2530
DiyanDimitrov Oct 29, 2018
cb785b3
feat(tree-grid): fixing tree grid sample description #2530
DiyanDimitrov Oct 29, 2018
d160e78
feat(tree-grid): adding some missing cofigureTestSuite calls #2530
DiyanDimitrov Oct 29, 2018
5d31112
test(TreeGridCrud): #2530 Removing done from async tests.
gedinakova Oct 29, 2018
7cffb14
test(ColPinning): #2530 Fixed an issue in afterAll();
gedinakova Oct 29, 2018
c637264
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 29, 2018
dce1905
Merge branch 'ddimitrov/IgxTreeGrid' of https://github.com/IgniteUI/i…
DiyanDimitrov Oct 29, 2018
598cdfa
test(Selection): #2530 Made scrolling test async.
gedinakova Oct 29, 2018
06aa156
test(tree-grid): Adding test scenarios #2852
dafo Oct 29, 2018
3372f79
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 30, 2018
1e1751a
test(tree-grid): fixing tests #2530
Oct 30, 2018
5cf0758
Merge remote-tracking branch 'remotes/origin/ddimitrov/IgxTreeGrid' i…
wnvko Oct 30, 2018
f32376d
chore(tree-grid): refactor in update_cell method
wnvko Oct 30, 2018
c705273
test(tree-grid): fixing tests #2530
Oct 30, 2018
6821fdd
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 30, 2018
702338d
test(row editing): Adding more scenarios #2530
dafo Oct 30, 2018
1c90854
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 30, 2018
cbff4bd
chore(tree-grid): modify dev demos #2530
Oct 30, 2018
320c4c6
Merge branch 'ddimitrov/IgxTreeGrid' of https://github.com/IgniteUI/i…
Oct 30, 2018
fb68511
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
jackofdiamond5 Oct 30, 2018
39cccbe
Merge branch 'ddimitrov/IgxTreeGrid' into VSlavov/treeGrid-editing
ViktorSlavov Oct 30, 2018
15249b3
fix(igxTreeGrid): transactions do not write to data, #2530
ViktorSlavov Oct 30, 2018
d69ce9a
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
jackofdiamond5 Oct 30, 2018
590c7e0
test(row-editing): Added IgxTreeGridFilteringRowEditingComponent #2530
jackofdiamond5 Oct 30, 2018
6303c78
Merge branch 'master' into ddimitrov/IgxTreeGrid
gedinakova Oct 30, 2018
dcfb225
chore(row-editing): Added component to the declarations array #2530
jackofdiamond5 Oct 30, 2018
7e39d0f
test(row-editing): Added a test scenario #2530
jackofdiamond5 Oct 30, 2018
f2808f1
test(row-editing): Added a test scenario #2530
jackofdiamond5 Oct 30, 2018
08aff0b
test(row-editing): Added test scenarios #2530
jackofdiamond5 Oct 30, 2018
6110121
feat(tree-grid): renaming some public API #2530
DiyanDimitrov Oct 30, 2018
ef512e3
feat(tree-grid): hiding some tree cell public API #2530
DiyanDimitrov Oct 30, 2018
f36d850
feat(tree-grid): renaming expandedLevels to expansionDepth #2530
DiyanDimitrov Oct 30, 2018
2468587
feat(tree-grid): fixing the tree grid sample after renaming #2530
DiyanDimitrov Oct 30, 2018
9c70b14
feat(tree-grid): fixing the tree grid template #2530
DiyanDimitrov Oct 30, 2018
5a78b3f
feat(tree-grid): changing addChildRow to addRow with parentID #2530
DiyanDimitrov Oct 30, 2018
22349fc
test(row-editing): Added a test scenario #2530
jackofdiamond5 Oct 30, 2018
4d4cb2c
Merge branch 'ddimitrov/IgxTreeGrid' into VSlavov/treeGrid-editing
ViktorSlavov Oct 30, 2018
b2fd887
feat(treegrid): implement properly showing/hiding overlay #2530
Lipata Oct 30, 2018
d5de7af
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
Lipata Oct 30, 2018
49def6d
test(tree-grid): fixing test because of changes in API #2530
Oct 30, 2018
5fa43e7
refactor(tree-grid): allow transactions to add rows
wnvko Oct 30, 2018
9bd7944
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
wnvko Oct 30, 2018
f7f613c
feat(tree-grid): submit value when clicking expansion indicator #2530
DiyanDimitrov Oct 30, 2018
51c6510
feat(tree-grid): moving code from api service to tree grid #2530
DiyanDimitrov Oct 30, 2018
a1d4302
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 30, 2018
047d924
feat(tree-grid): removing indentation from tree row component #2530
DiyanDimitrov Oct 30, 2018
304ef3c
test(tree-grid): row editing collapsing/expanding #2530
Lipata Oct 30, 2018
7acbe9e
Merge branch 'ddimitrov/IgxTreeGrid' into VSlavov/treeGrid-editing
Lipata Oct 30, 2018
d8db773
test(C): #2530 rowComponent.indentation to rowComponent.treeRow.level.
gedinakova Oct 30, 2018
862e871
test(row-editing): Tree grid row editing integration tests #2530
PlamenaMiteva Oct 30, 2018
7df8d44
test(TreeGrid): #2530 Changed expandedLevels to expansionDepth.
gedinakova Oct 30, 2018
831bf65
feat(tree-grid): call onFocus in onIndicatorFocus #2530
DiyanDimitrov Oct 31, 2018
a78e414
Merge branch 'ddimitrov/IgxTreeGrid' into VSlavov/treeGrid-editing
ViktorSlavov Oct 31, 2018
4cd675e
Merge branch 'master' into ddimitrov/IgxTreeGrid
gedinakova Oct 31, 2018
1bc70ab
feat(tree-grid): fixing row toggle event args #2530
DiyanDimitrov Oct 31, 2018
39f3ebe
fix(igxGrid): close row edit when focusing indicator, #2530
ViktorSlavov Oct 31, 2018
64d43fb
docs(tree-grid): add treeGrid to Changelog #2530
Oct 31, 2018
9c794b7
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 31, 2018
e8b8926
feat(tree-grid): use the default density #2530
DiyanDimitrov Oct 31, 2018
36cae74
test(tree-grid): adding more expand/collapse tests #2530
Oct 31, 2018
65ea409
feat(tree-grid): close overlay on collapse/expand #2530
Lipata Oct 31, 2018
5bc7b6e
chore(tree-grid): remove fdescribe #2530
Lipata Oct 31, 2018
03c2318
Merge branch 'ddimitrov/IgxTreeGrid' into VSlavov/treeGrid-editing
Lipata Oct 31, 2018
e02a8e9
test(row editing): Updating igxTreeGrid template #2530
dafo Oct 31, 2018
ea94ab8
refactor(igxTransaction): make igxTransaction generic
wnvko Oct 31, 2018
ba0a220
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
wnvko Oct 31, 2018
b3edcad
test(tree-grid): adding more expansion tests #2530
Oct 31, 2018
d2b7a59
Merge branch 'master' into ddimitrov/IgxTreeGrid
DiyanDimitrov Oct 31, 2018
a32a5cb
test(tree-grid): removing fdescribe #2530
Oct 31, 2018
af5713b
Merge branch 'ddimitrov/IgxTreeGrid' of https://github.com/IgniteUI/i…
Oct 31, 2018
8d41218
test(tree-grid): current page should update when collapseAll #2530
Oct 31, 2018
dfd2bb2
Merge branch 'master' into ddimitrov/IgxTreeGrid
tachojelev Oct 31, 2018
74b506d
feat(tree-grid): adding cascadeOnDelete input property #2530
DiyanDimitrov Oct 31, 2018
ead5940
test(tree-grid): adding tests regarding the "cascadeOnDelete" propert…
Oct 31, 2018
90b4359
feat(tree-grid): hiding search for TreeGrid #2530
DiyanDimitrov Oct 31, 2018
e29ebdd
feat(Docs): #2530 Adding ///-comments to IgxTreeGridComponent members.
gedinakova Oct 31, 2018
06f203a
Merge branch 'master' into ddimitrov/IgxTreeGrid
gedinakova Oct 31, 2018
20fba6e
Merge branch 'master' into ddimitrov/IgxTreeGrid
tachojelev Nov 1, 2018
b2dbdba
Merge branch 'ddimitrov/IgxTreeGrid' into VSlavov/treeGrid-editing
Lipata Nov 1, 2018
20ce5e8
fix(igx-grid): cell exit will exit row, no other code is needed #2530
Lipata Nov 1, 2018
1a2be8e
test(roe editing): Adding tests for row editing + Sorting #2530
dafo Nov 1, 2018
75b6de5
test(row editing): Row editing integration tests #2530
PlamenaMiteva Nov 1, 2018
98737b8
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
PlamenaMiteva Nov 1, 2018
492473f
refactor(tree-grid): transaction ok for flat data
wnvko Nov 1, 2018
fc9994a
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
wnvko Nov 1, 2018
2417b96
refactor(tree-grid): allow add rows and edit of added rows in hierarc…
wnvko Nov 1, 2018
faa9732
Merge branch 'master' into VSlavov/treeGrid-editing
ViktorSlavov Nov 2, 2018
ed7aecb
chore(*): fixing lint errors
ViktorSlavov Nov 2, 2018
b536720
refactor(tree-grid): refactor delete row logic to include transactions
wnvko Nov 2, 2018
fa5ea8b
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
wnvko Nov 2, 2018
259f8e0
refactor(tree-grid): get_all_data method of tree grid now includes tr…
wnvko Nov 2, 2018
2532d34
Merge remote-tracking branch 'remotes/origin/master' into VSlavov/tre…
wnvko Nov 2, 2018
cf6db67
refactor(tree-grid): adding tree data structure to transaction
wnvko Nov 2, 2018
df4d3ef
refactor(tree-grid): clearStateForDeletedItems checks if node provided
wnvko Nov 2, 2018
2838309
fix(row-editing): fix delete row in transation
simeonoff Nov 2, 2018
c0220a3
refactor(tree-grid): add path to ITreeGridRecord
wnvko Nov 2, 2018
275f8dd
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
wnvko Nov 2, 2018
590f51e
refactor(tree-grid): add /** @experimental @hidden */ where needed
wnvko Nov 2, 2018
c95cf69
Merge remote-tracking branch 'remotes/origin/master' into VSlavov/tre…
wnvko Nov 2, 2018
10f45f8
test(tree-grid): fix row edit tests, #2878
wnvko Nov 2, 2018
75b6f6e
Merge remote-tracking branch 'remotes/origin/master' into VSlavov/tre…
wnvko Nov 3, 2018
7c25eca
refactor(tree-grid): push cascaded flat delete row as pending transac…
wnvko Nov 4, 2018
a66445f
chore(lint): more row's new method after property definitions
damyanpetev Nov 5, 2018
964e8ec
test(row-editing): added selection tests and updated filtering tests …
jackofdiamond5 Nov 5, 2018
61bbf85
refactor(tree-grid): add useInUndo flag
wnvko Nov 5, 2018
df04c08
Merge branch 'VSlavov/treeGrid-editing' of https://github.com/IgniteU…
wnvko Nov 5, 2018
536e195
fix(tree-grid): check row existence #2908
Lipata Nov 5, 2018
161668a
test(tree-grid): fix failing test with missing component in declarati…
wnvko Nov 5, 2018
0ba0f52
fix(igx-grid): pass correct argument #2908
Lipata Nov 5, 2018
6ebcfba
fix(igx-grid): remove unnecessary code #2908
Lipata Nov 5, 2018
423bde9
fix(igx-treegrid): end row edit on expand/collpase #2908
Lipata Nov 5, 2018
31fbbb2
fix(igx-grid): end row edit on expand/collpase #2908
Lipata Nov 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -900,12 +900,18 @@
}

%igx-grid__td--edited {
font-style: italic;
color: --var($theme, 'cell-edited-value-color');
%grid-cell-text {
font-style: italic;
color: --var($theme, 'cell-edited-value-color');
}
}

%igx-grid__tr--deleted {
text-decoration-line: line-through;
%grid-cell-text {
font-style: italic;
color: igx-color(map-get($theme, 'palette'), 'error');
text-decoration-line: line-through;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simeonoff Can't this be just text-decoration so it'd work in IE/Edge too?
@StefanIvanov Is red part of the design?

Copy link
Collaborator

@simeonoff simeonoff Nov 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damyanpetev text-decoration-line is just a property of the shorthand text-decoration. The line-through text decoration is not supported in IE and Edge. As to the color being red, I've discussed it with @StefanIvanov before implementing the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simeonoff Despite being the shorthand, text-decoration: line-through; is in the CSS1 spec and works just fine even in older IE-s. So unless we need any of the decorations, can we use the shorthand for consistency?

}
}

%igx-grid__td--editing {
Expand Down
22 changes: 22 additions & 0 deletions projects/igniteui-angular/src/lib/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ export function cloneArray(array, deep?: boolean) {
return arr;
}

/**
* Doesn't clone leaf items
* @hidden
*/
export function cloneHierarchicalArray(array: any[], childDataKey: any): any[] {
const result: any[] = [];
if (!array) {
return result;
}

for (const item of array) {
if (Array.isArray(item[childDataKey])) {
const clonedItem = cloneValue(item);
clonedItem[childDataKey] = cloneHierarchicalArray(clonedItem[childDataKey], childDataKey);
result.push(clonedItem);
} else {
result.push(item);
}
}
return result;
}

/**
* Deep clones all first level keys of Obj2 and merges them to Obj1
* @param obj1 Object to merge into
Expand Down
66 changes: 48 additions & 18 deletions projects/igniteui-angular/src/lib/data-operations/data-util.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import {
IgxFilteringOperand,
IgxBooleanFilteringOperand,
IgxDateFilteringOperand,
IgxNumberFilteringOperand,
IgxStringFilteringOperand
} from './filtering-condition';
import { FilteringLogic, IFilteringExpression } from './filtering-expression.interface';
import { filteringStateDefaults, IFilteringState } from './filtering-state.interface';
import { FilteringStrategy, IFilteringStrategy } from './filtering-strategy';

import { ISortingExpression, SortingDirection } from './sorting-expression.interface';
import { ISortingState, SortingStateDefaults } from './sorting-state.interface';
import { ISortingStrategy, SortingStrategy, IGroupByResult, TreeGridSortingStrategy } from './sorting-strategy';

import { IGroupByResult, TreeGridSortingStrategy } from './sorting-strategy';
import { IPagingState, PagingError } from './paging-state.interface';

import { IDataState } from './data-state.interface';
import { IGroupByExpandState, IGroupByKey } from './groupby-expand-state.interface';
import { IGroupByRecord } from './groupby-record.interface';
import { IGroupingState } from './groupby-state.interface';
import { Transaction, TransactionType } from '../services';
import { Transaction, TransactionType, HierarchicalTransaction, IgxHierarchicalTransactionService, HierarchicalState } from '../services';
import { mergeObjects, cloneValue } from '../core/utils';
import { ITreeGridRecord } from '../grids/tree-grid/tree-grid.interfaces';

export enum DataType {
Expand Down Expand Up @@ -79,7 +67,8 @@ export class DataUtil {
children: hierarchicalRecord.children,
isFilteredOutParent: hierarchicalRecord.isFilteredOutParent,
level: hierarchicalRecord.level,
expanded: hierarchicalRecord.expanded
expanded: hierarchicalRecord.expanded,
path: [...hierarchicalRecord.path]
};
return rec;
}
Expand Down Expand Up @@ -224,9 +213,12 @@ export class DataUtil {
* @param primaryKey Primary key of the collection, if any
*/
public static mergeTransactions<T>(data: T[], transactions: Transaction[], primaryKey?: any): T[] {
data.forEach((value, index) => {
const rowId = primaryKey ? value[primaryKey] : value;
data.forEach((item: any, index: number) => {
const rowId = primaryKey ? item[primaryKey] : item;
const transaction = transactions.find(t => t.id === rowId);
if (Array.isArray(item.children)) {
this.mergeTransactions(item.children, transactions, primaryKey);
}
if (transaction && transaction.type === TransactionType.UPDATE) {
data[index] = transaction.newValue;
}
Expand All @@ -237,4 +229,42 @@ export class DataUtil {
.map(t => t.newValue));
return data;
}

// TODO: optimize addition of added rows. Should not filter transaction in each recursion!!!
/** @experimental @hidden */
public static mergeHierarchicalTransactions(
data: any[],
transactions: HierarchicalTransaction[],
childDataKey: any,
primaryKey?: any,
parentKey?: any): any[] {

for (let index = 0; index < data.length; index++) {
const dataItem = data[index];
const rowId = primaryKey ? dataItem[primaryKey] : dataItem;
const updateTransaction = transactions.filter(t => t.type === TransactionType.UPDATE).find(t => t.id === rowId);
const addedTransactions = transactions.filter(t => t.type === TransactionType.ADD).filter(t => t.parentId === rowId);
if (updateTransaction || addedTransactions.length > 0) {
data[index] = mergeObjects(cloneValue(dataItem), updateTransaction && updateTransaction.newValue);
}
if (addedTransactions.length > 0) {
if (!data[index][childDataKey]) {
data[index][childDataKey] = [];
}
for (const addedTransaction of addedTransactions) {
data[index][childDataKey].push(addedTransaction.newValue);
}
}
if (data[index][childDataKey]) {
data[index][childDataKey] = this.mergeHierarchicalTransactions(
data[index][childDataKey],
transactions,
childDataKey,
primaryKey,
rowId
);
}
}
return data;
}
}
8 changes: 6 additions & 2 deletions projects/igniteui-angular/src/lib/grids/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
dataWithTransactions.map((record) => record[grid.primaryKey]).indexOf(rowID) :
dataWithTransactions.indexOf(rowID);
if (rowIndex !== -1) {
// Check if below change will work on added rows with transactions
// oldValue = this.get_all_data(id, true)[rowIndex][column.field];
// rowData = this.get_all_data(id, true)[rowIndex];
oldValue = columnID !== null ? dataWithTransactions[rowIndex][column.field] : null;
rowData = dataWithTransactions[rowIndex];
}
Expand Down Expand Up @@ -596,9 +599,10 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
return column.dataType === DataType.Number;
}

public get_all_data(id: string): any[] {
public get_all_data(id: string, transactions?: boolean): any[] {
const grid = this.get(id);
return grid.data;
const data = transactions ? grid.dataWithAddedInTransactionRows : grid.data;
return data ? data : [];
}

protected getSortStrategyPerColumn(id: string, fieldName: string) {
Expand Down
80 changes: 48 additions & 32 deletions projects/igniteui-angular/src/lib/grids/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import { Subject } from 'rxjs';
import { takeUntil, first } from 'rxjs/operators';
import { IgxSelectionAPIService } from '../core/selection';
import { cloneArray, isNavigationKey, CancelableEventArgs } from '../core/utils';
import { cloneArray, isNavigationKey, mergeObjects, CancelableEventArgs } from '../core/utils';
import { DataType, DataUtil } from '../data-operations/data-util';
import { FilteringLogic, IFilteringExpression } from '../data-operations/filtering-expression.interface';
import { IGroupByExpandState } from '../data-operations/groupby-expand-state.interface';
Expand Down Expand Up @@ -1633,7 +1633,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
/**
* Get transactions service for the grid.
*/
get transactions() {
get transactions(): TransactionService<Transaction, State> {
return this._transactions;
}

Expand Down Expand Up @@ -2062,7 +2062,9 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
this.zone.run(() => {
this.cdr.detectChanges();
this.verticalScrollContainer.onChunkLoad.emit(this.verticalScrollContainer.state);
this.changeRowEditingOverlayStateOnScroll(this.rowInEditMode);
if (this.rowEditable) {
this.changeRowEditingOverlayStateOnScroll(this.rowInEditMode);
}
});
}

Expand Down Expand Up @@ -2097,7 +2099,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
constructor(
private gridAPI: GridBaseAPIService<IgxGridBaseComponent>,
public selection: IgxSelectionAPIService,
@Inject(IgxGridTransaction) private _transactions: TransactionService,
@Inject(IgxGridTransaction) protected _transactions: TransactionService<Transaction, State>,
private elementRef: ElementRef,
private zone: NgZone,
@Inject(DOCUMENT) public document,
Expand Down Expand Up @@ -2859,26 +2861,17 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
return;
}

// TODO: should we emit this when cascadeOnDelete is true for each row?!?!
this.onRowDeleted.emit({ data: data[index] });

// if there is a row (index !== 0) delete it
// if there is a row in ADD or UPDATE state change it's state to DELETE
if (index !== -1) {
if (this.transactions.enabled) {
const transaction: Transaction = { id: rowId, type: TransactionType.DELETE, newValue: null };
this.transactions.add(transaction, data[index]);
} else {
this.deleteRowFromData(rowId, index);
}
} else {
this.transactions.add({ id: rowId, type: TransactionType.DELETE, newValue: null }, state.recordRef);
}

if (this.rowSelectable === true && this.selection.is_item_selected(this.id, rowId)) {
// first deselect row then delete it
if (this.rowSelectable && this.selection.is_item_selected(this.id, rowId)) {
this.deselectRows([rowId]);
} else {
this.checkHeaderCheckboxStatus();
}

this.deleteRowFromData(rowId, index);
this._pipeTrigger++;
this.cdr.markForCheck();

Expand All @@ -2892,7 +2885,19 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
* @hidden
*/
protected deleteRowFromData(rowID: any, index: number) {
this.data.splice(index, 1);
// if there is a row (index !== 0) delete it
// if there is a row in ADD or UPDATE state change it's state to DELETE
if (index !== -1) {
if (this.transactions.enabled) {
const transaction: Transaction = { id: rowID, type: TransactionType.DELETE, newValue: null };
this.transactions.add(transaction, this.data[index]);
} else {
this.data.splice(index, 1);
}
} else {
const state: State = this.transactions.getState(rowID);
this.transactions.add({ id: rowID, type: TransactionType.DELETE, newValue: null }, state && state.recordRef);
}
}

/**
Expand Down Expand Up @@ -3542,7 +3547,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
if (this.rowSelectable) {
this.calcRowCheckboxWidth = this.headerCheckboxContainer.nativeElement.clientWidth;
}
if (this.rowEditable && !this.rowEditingOverlay.collapsed) {
if (this.rowEditable) {
this.repositionRowEditingOverlay(this.rowInEditMode);
}
this.cdr.detectChanges();
Expand Down Expand Up @@ -3842,7 +3847,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
* this.grid.selectRows([1,2,5], true);
* ```
* @param rowIDs
* @param clearCurrentSelection if true clears the curren selection
* @param clearCurrentSelection if true clears the current selection
* @memberof IgxGridBaseComponent
*/
public selectRows(rowIDs: any[], clearCurrentSelection?: boolean) {
Expand Down Expand Up @@ -4319,18 +4324,18 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
this.nativeElement.focus();
} */

private changeRowEditingOverlayStateOnScroll(row: IgxRowComponent<IgxGridBaseComponent>) {
if (!this.rowEditable || this.rowEditingOverlay.collapsed) {
return;
}
if (!row) {
this.toggleRowEditingOverlay(false);
} else {
this.repositionRowEditingOverlay(row);
private changeRowEditingOverlayStateOnScroll(row: IgxRowComponent<IgxGridBaseComponent>) {
if (!this.rowEditable || this.rowEditingOverlay.collapsed) {
return;
}
if (!row) {
this.toggleRowEditingOverlay(false);
} else {
this.repositionRowEditingOverlay(row);
}
}
}

/**
/**
* @hidden
*/
public startRowEdit(cell: {
Expand Down Expand Up @@ -4365,6 +4370,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
this.rowEditingOverlay.element.removeEventListener('wheel', this.rowEditingWheelHandler);
this.rowEditPositioningStrategy.isTopInitialPosition = null;
this.rowEditingOverlay.close();
this.rowEditingOverlay.element.parentElement.style.display = '';
}

/**
Expand All @@ -4385,7 +4391,14 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
public repositionRowEditingOverlay(row: IgxRowComponent<IgxGridBaseComponent>) {
this.configureRowEditingOverlay(row.rowID);
if (!this.rowEditingOverlay.collapsed) {
this.rowEditingOverlay.reposition();
const rowStyle = this.rowEditingOverlay.element.parentElement.style;
if (row) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something not quite right here - if the method accepts a call without a row, the .configureRowEditingOverlay(row.rowID) right above doesn't and will error out (see tests). Also what's with .configureRowEditingOverlay(row) below - is it row or rowID?

rowStyle.display = '';
this.configureRowEditingOverlay(row);
this.rowEditingOverlay.reposition();
} else {
rowStyle.display = 'none';
}
}
}

Expand All @@ -4412,6 +4425,9 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
return rowChanges ? Object.keys(rowChanges).length : 0;
}

protected writeToData(rowIndex: number, value: any) {
mergeObjects(this.data[rowIndex], value);
}
/**
* TODO: Refactor
* @hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,7 @@ export class IgxGridAPIService extends GridBaseAPIService<IgxGridComponent> {
}
this.get(id).groupingExpansionState = expansionState;
if (grid.rowEditable) {
if (toggleRowEditingOverlay !== undefined) {
grid.toggleRowEditingOverlay(toggleRowEditingOverlay);
}

// If row overlay is opened in a group and another group is expanded/collapsed,
// then the row in edit will move down/up and therefore the row edit overlay should move down/up.
if (grid.rowInEditMode && !grid.rowEditingOverlay.collapsed) {
grid.repositionRowEditingOverlay(grid.rowInEditMode);
}
grid.repositionRowEditingOverlay(grid.rowInEditMode);
}
}

Expand Down
Loading