Skip to content

Commit

Permalink
Merge branch 'master' into dmdimitrov/query-builder-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gedinakova authored Feb 6, 2025
2 parents 4b3b48c + 5161e7b commit eed54ea
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ import {
} from '@angular/core';
import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
import { CheckboxBaseDirective } from './checkbox-base.directive';
import { IBaseEventArgs } from '../core/utils';
import { ControlValueAccessor } from '@angular/forms';
import { EditorProvider, EDITOR_PROVIDER } from '../core/edit-provider';

export interface IChangeCheckboxEventArgs extends IBaseEventArgs {
checked: boolean;
value?: any;
}
/**
* Allows users to make a binary choice for a certain condition.
*
Expand Down
2 changes: 2 additions & 0 deletions projects/igniteui-angular/src/lib/checkbox/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { type LabelPosition, IChangeCheckboxEventArgs } from "./checkbox-base.directive";
export * from "./checkbox.component";
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { startWith, takeUntil } from 'rxjs/operators';
import { mkenum } from '../../core/utils';
import { IgxRadioComponent } from '../../radio/radio.component';
import { IgxDirectionality } from '../../services/direction/directionality';
import { IChangeCheckboxEventArgs } from '../../checkbox/checkbox.component';
import { IChangeCheckboxEventArgs } from '../../checkbox/public_api';

/**
* Determines the Radio Group alignment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,13 @@ export class IgxGridCRUDService extends IgxRowAddCrudState {
return;
}
this.endEdit(true, event);

if (parentRow != null && this.grid.expansionStates.get(parentRow.key)) {
this.grid.collapseRow(parentRow.key);
// work with copy of original row, since context may change on collapse.
const parentRowCopy = parentRow ? Object.assign(copyDescriptors(parentRow), parentRow) : null;
if (parentRowCopy != null && this.grid.expansionStates.get(parentRowCopy.key)) {
this.grid.collapseRow(parentRowCopy.key);
}

this.createAddRow(parentRow, asChild);
this.createAddRow(parentRowCopy, asChild);

this.grid.transactions.startPending();
if (this.addRowParent.isPinned) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
IgxStringFilteringOperand, IgxDateTimeFilteringOperand, IgxTimeFilteringOperand
} from '../../../data-operations/filtering-condition';
import { Subject } from 'rxjs';
import { IChangeCheckboxEventArgs, IgxCheckboxComponent } from '../../../checkbox/checkbox.component';
import { IChangeCheckboxEventArgs, IgxCheckboxComponent } from '../../../checkbox/public_api';
import { takeUntil } from 'rxjs/operators';
import { cloneHierarchicalArray, PlatformUtil } from '../../../core/utils';
import { BaseFilteringComponent } from './base-filtering.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IgxActionStripComponent } from '../../action-strip/public_api';
import { IgxTreeGridRowComponent } from './tree-grid-row.component';
import { first } from 'rxjs/operators';
import { IRowDataCancelableEventArgs } from '../public_api';
import { wait } from '../../test-utils/ui-interactions.spec';

describe('IgxTreeGrid - Add Row UI #tGrid', () => {
configureTestSuite();
Expand Down Expand Up @@ -216,5 +217,47 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
const addedRow = treeGrid.getRowByKey(newRowId);
expect(addedRow.data[treeGrid.foreignKey]).toBe(2);
});

it('should collapse row when child row adding begins and it added row should go under correct parent.', async() => {
treeGrid.data = [
{ ID: 1, ParentID: -1, Name: 'Casey Houston', JobTitle: 'Vice President', Age: 32 },
{ ID: 2, ParentID: 10, Name: 'Gilberto Todd', JobTitle: 'Director', Age: 41 },
{ ID: 3, ParentID: 10, Name: 'Tanya Bennett', JobTitle: 'Director', Age: 29 },
{ ID: 4, ParentID: 6, Name: 'Jack Simon', JobTitle: 'Software Developer', Age: 33 },
{ ID: 6, ParentID: -1, Name: 'Erma Walsh', JobTitle: 'CEO', Age: 52 },
{ ID: 7, ParentID: 10, Name: 'Debra Morton', JobTitle: 'Associate Software Developer', Age: 35 },
{ ID: 9, ParentID: 10, Name: 'Leslie Hansen', JobTitle: 'Associate Software Developer', Age: 44 },
{ ID: 10, ParentID: -1, Name: 'Eduardo Ramirez', JobTitle: 'Manager', Age: 53 }
];
fix.detectChanges();
treeGrid.collapseAll();
treeGrid.height = "350px";
fix.detectChanges();
const parentRow1 = treeGrid.rowList.toArray()[1] as IgxTreeGridRowComponent;
treeGrid.expandRow(parentRow1.key);
const parentRow2 = treeGrid.rowList.toArray()[3] as IgxTreeGridRowComponent;
treeGrid.expandRow(parentRow2.key);
treeGrid.triggerPipes();
fix.detectChanges();

// scroll bottom
treeGrid.verticalScrollContainer.scrollTo(treeGrid.dataView.length - 1);
await wait(50);
fix.detectChanges();
// start add row
parentRow2.beginAddChild();
fix.detectChanges();
// last row should be add row
const addRow = treeGrid.gridAPI.get_row_by_index(4);
expect(addRow.addRowUI).toBeTrue();
endTransition();

// end edit
treeGrid.gridAPI.crudService.endEdit(true);
fix.detectChanges();

// row should be added under correct parent
expect(treeGrid.data[treeGrid.data.length - 1].ParentID).toBe(10);
});
});
});
2 changes: 1 addition & 1 deletion projects/igniteui-angular/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export * from './lib/buttonGroup/public_api';
export * from './lib/calendar/public_api';
export * from './lib/card/public_api';
export * from './lib/carousel/public_api';
export * from './lib/checkbox/checkbox.component';
export * from './lib/checkbox/public_api';
export * from './lib/chips/public_api';
export * from './lib/combo/public_api';
export * from './lib/simple-combo/public_api';
Expand Down

0 comments on commit eed54ea

Please sign in to comment.