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

feat(RowPinning): Initial implementation of jump to disabled row grid action. #7255

Merged
merged 24 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
337bccc
feat(RowPinning): Initial implementation of jump to disabled row grid…
skrustev May 4, 2020
0f5c9d4
chore(*): Add test and fix lint.
skrustev May 4, 2020
68126a4
chore(*): Update tree grid to support set properly pinning metadata.
skrustev May 4, 2020
dfffec0
Merge branch 'master' into action-strip-jump-to
MayaKirova May 4, 2020
e0c8392
chore(*): Update grid after merge with new _pinnedRecordMetadata.
skrustev May 4, 2020
9d54353
chore(*): Add missing tree grid override for row pinning .
skrustev May 4, 2020
e783904
chore(*): Revert to pinnedRecordIDs collection and use another method…
skrustev May 5, 2020
ae6de26
Merge branch 'master' into action-strip-jump-to
ChronosSF May 5, 2020
858195a
chore(*): Cleanup unnecessary code and name properly few methods.
skrustev May 5, 2020
6a85636
chore(*): Add different icon for jump to ghost when pinning is set to…
skrustev May 5, 2020
f6f36cb
Merge master insto action-strip-jump-to.
skrustev May 8, 2020
c9d1821
chore(*): Fix lint error due to merge.
skrustev May 8, 2020
a676224
Merge branch 'master' into action-strip-jump-to
ChronosSF May 8, 2020
4de20c6
Merge branch 'master' into action-strip-jump-to
ChronosSF May 8, 2020
bffec47
fix(forOf): Update the scroll position instead of only updating the s…
skrustev May 8, 2020
d6a1979
chore(*): Add missing semicolon.
skrustev May 8, 2020
56f5269
Merge branch 'master' into action-strip-jump-to
ChronosSF May 11, 2020
9810e73
Merge branch 'master' into action-strip-jump-to
ChronosSF May 11, 2020
cd29a9b
fix(forOf): Do not call addScrollTop when there is nothing to adjust.
skrustev May 11, 2020
52648d9
Merge branch 'master' into action-strip-jump-to
ChronosSF May 12, 2020
0a0c816
Merge branch 'master' into action-strip-jump-to
ChronosSF May 12, 2020
9684484
Merge branch 'master' into action-strip-jump-to
ChronosSF May 12, 2020
3bdbe1e
chore(*): Increase times for failing hierarchical grid navigation test.
skrustev May 12, 2020
4f4fc09
Merge branch 'master' into action-strip-jump-to
ChronosSF May 13, 2020
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
@@ -1,4 +1,10 @@
<ng-container *ngIf="isRowContext">
<button *ngIf="inPinnedArea && pinnedTop" igxRipple igxButton="icon" (click)="scrollToRow($event)">
<igx-icon fontSet="filtering-icons" name="jump_down"></igx-icon>
dkamburov marked this conversation as resolved.
Show resolved Hide resolved
</button>
<button *ngIf="inPinnedArea && !pinnedTop" igxRipple igxButton="icon" (click)="scrollToRow($event)">
<igx-icon fontSet="filtering-icons" name="jump_up"></igx-icon>
</button>
<button *ngIf="!pinned" igxRipple igxButton="icon" (click)="pin($event)">
<igx-icon fontSet="filtering-icons" name="pin"></igx-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IgxGridModule, IgxGridComponent } from '../../grids/grid';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { By } from '@angular/platform-browser';
import { IgxActionStripModule } from '../action-strip.module';
import { wait } from '../../test-utils/ui-interactions.spec';


describe('igxGridPinningActions #grid ', () => {
Expand Down Expand Up @@ -57,8 +58,22 @@ describe('igxGridPinningActions #grid ', () => {
expect(grid.pinnedRows.length).toBe(0);
});

it('should allow navigating to disabled row in unpinned area', () => {
pending('implementation');
it('should allow navigating to disabled row in unpinned area', async() => {
grid.pinRow('FAMIA');
fixture.detectChanges();

actionStrip.show(grid.pinnedRows[0]);
fixture.detectChanges();

const jumpIcon = fixture.debugElement.query(By.css(`igx-icon[name=jump_down]`));
jumpIcon.parent.triggerEventHandler('click', new Event('click'));
await wait();
fixture.detectChanges();
await wait();
fixture.detectChanges();

const secondToLastVisible = grid.rowList.toArray()[grid.rowList.length - 2];
expect(secondToLastVisible.rowID).toEqual('FAMIA');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ export class IgxGridPinningActionsComponent extends IgxGridActionsBaseDirective
return context && context.pinned;
}

/**
* Getter to know if the row is in pinned and ghost
* @hidden
* @internal
*/
get inPinnedArea(): boolean {
if (!this.isRow(this.strip.context)) {
return;
}
const context = this.strip.context;
return this.pinned && !context.disabled;
}

/**
* Getter to know if the row pinning is set to top or bottom
* @hidden
* @internal
*/
get pinnedTop(): boolean {
if (!this.isRow(this.strip.context)) {
return;
}
return this.strip.context.grid.isRowPinningToTop;
}

/**
* Pin the row according to the context.
* @example
Expand Down Expand Up @@ -75,6 +100,16 @@ export class IgxGridPinningActionsComponent extends IgxGridActionsBaseDirective
this.strip.hide();
}

public scrollToRow(event) {
if (event) {
event.stopPropagation();
}
const context = this.strip.context;
const grid = context.grid;
grid.scrollTo(context.rowData, 0);
this.strip.hide();
}

private renderIcons(): void {
if (!this.isRow(this.strip.context)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,9 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
// need to adjust the offsets so that item is last in view.
const updatesToIndex = this._adjustToIndex - this.state.startIndex + 1;
const sumDiffs = diffs.slice(0, updatesToIndex).reduce(reducer);
const currOffset = parseInt(this.dc.instance._viewContainer.element.nativeElement.style.top, 10);
this.dc.instance._viewContainer.element.nativeElement.style.top = (currOffset - sumDiffs) + 'px';
if (sumDiffs !== 0) {
this.addScrollTop(sumDiffs);
}
this._adjustToIndex = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/src/lib/grids/common/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class IgxGridRowPinningPipe implements PipeTransform {

if (grid.hasPinnedRecords && isPinned) {
const result = collection.filter(rec => grid.isRecordPinned(rec));
result.sort((rec1, rec2) => grid.pinRecordIndex(rec1) - grid.pinRecordIndex(rec2));
result.sort((rec1, rec2) => grid.getInitialPinnedIndex(rec1) - grid.getInitialPinnedIndex(rec2));
return result;
}

Expand Down
12 changes: 12 additions & 0 deletions projects/igniteui-angular/src/lib/grids/filtering/svgIcons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,17 @@ export default [
<rect x="7.5" y="7.5" width="3.75" height="3.75"/>
<rect x="12.75" y="7.5" width="3.75" height="3.75"/>
</svg>`
},
{
name: 'jump_up',
value: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M6 8l4 4H7c0 3.31 2.69 6 6 6 1.01 0 1.97-.25 2.8-.7l1.46 1.46A7.93 7.93 0 0113 20c-4.42 0-8-3.58-8-8H2l4-4zm15-5v2H5V3h16z"/>
</svg>`
},
{
name: 'jump_down',
value: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M21 19v2H5v-2h16zM13 4c1.57 0 3.03.46 4.26 1.24L15.8 6.7A5.87 5.87 0 0013 6c-3.31 0-6 2.69-6 6h3l-4 4-4-4h3c0-4.42 3.58-8 8-8z"/>
</svg>`
}
];
37 changes: 17 additions & 20 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2449,9 +2449,9 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
*/
protected destroy$ = new Subject<any>();

protected _filteredSortedPinnedData;
protected _filteredSortedUnpinnedData;
protected _filteredPinnedData;
protected _filteredSortedPinnedData: any[];
protected _filteredSortedUnpinnedData: any[];
protected _filteredPinnedData: any[];

/**
* @hidden
Expand Down Expand Up @@ -2711,15 +2711,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
});
}

/**
* @hidden
* @internal
*/
public isRecordPinned(rec) {
const id = this.primaryKey ? rec[this.primaryKey] : rec;
return this._pinnedRecordIDs.indexOf(id) !== -1;
}

/**
* Returns whether the record is pinned or not.
*
Expand All @@ -2737,9 +2728,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
* Returns whether the record is pinned or not.
*
* @param rowIndex Index of the record in the `filteredSortedData` collection.
*
* @hidden
* @internal
*/
public isRecordPinnedByIndex(rowIndex: number) {
return this.hasPinnedRecords && (this.isRowPinningToTop && rowIndex < this._filteredSortedPinnedData.length) ||
Expand All @@ -2750,8 +2738,17 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
* @hidden
* @internal
*/
public pinRecordIndex(rec) {
const id = this.primaryKey ? rec[this.primaryKey] : rec;
public isRecordPinned(rec) {
return this.getInitialPinnedIndex(rec) !== -1;
}

/**
* @hidden
* @internal
* Returns the record index in order of pinning by the user. Does not consider sorting/filtering.
*/
public getInitialPinnedIndex(rec) {
const id = this.gridAPI.get_row_id(rec);
return this._pinnedRecordIDs.indexOf(id);
}

Expand Down Expand Up @@ -3015,12 +3012,12 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
*/
public setFilteredSortedData(data, pinned: boolean) {
data = data || [];
if (this._pinnedRecordIDs.length > 0 && pinned) {
if (this.pinnedRecordsCount > 0 && pinned) {
this._filteredSortedPinnedData = data;
this.pinnedRecords = data;
this.filteredSortedData = this.isRowPinningToTop ? [... this._filteredSortedPinnedData, ... this._filteredSortedUnpinnedData] :
[... this._filteredSortedUnpinnedData, ... this._filteredSortedPinnedData];
} else if (this._pinnedRecordIDs.length > 0 && !pinned) {
} else if (this.pinnedRecordsCount > 0 && !pinned) {
this._filteredSortedUnpinnedData = data;
} else {
this.filteredSortedData = data;
Expand Down Expand Up @@ -5959,7 +5956,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
/**
* @hidden
*/
protected scrollTo(row: any | number, column: any | number, inCollection = this.filteredSortedData): void {
protected scrollTo(row: any | number, column: any | number, inCollection = this._filteredSortedUnpinnedData): void {
let delayScrolling = false;

if (this.paging && typeof (row) !== 'number') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,20 +271,23 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
}));

it('should scroll top of child grid into view when pressing Ctrl + Arrow Up when cell is selected in it.', (async () => {
hierarchicalGrid.verticalScrollContainer.scrollTo(7);
fixture.detectChanges();
await wait(DEBOUNCE_TIME);
fixture.detectChanges();

hierarchicalGrid.verticalScrollContainer.scrollTo(7);
await wait(DEBOUNCE_TIME);
fixture.detectChanges();
hierarchicalGrid.verticalScrollContainer.scrollTo(7);
await wait(DEBOUNCE_TIME);
fixture.detectChanges();

const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[3];

const childLastRowCell = childGrid.dataRowList.toArray()[9].cells.toArray()[0];
const childGridContent = fixture.debugElement.queryAll(By.css(GRID_CONTENT_CLASS))[1];
GridFunctions.focusCell(fixture, childLastRowCell);
fixture.detectChanges();
UIInteractions.triggerEventHandlerKeyDown('arrowup', childGridContent, false, false, true);
await wait(200);
fixture.detectChanges();
await wait(200);
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,22 +616,12 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
};
}

/**
* @hidden @internal
* This is overwritten because tree grid records have special record format - ITreeGridRecord,
* which already has the rowID in the record object.
*/
public isRecordPinned(rec) {
const id = rec.rowID;
return this._pinnedRecordIDs.indexOf(id) !== -1;
}

/**
* @hidden
* @internal
*/
public pinRecordIndex(rec) {
return super.pinRecordIndex(rec.data);
public getInitialPinnedIndex(rec) {
return this._pinnedRecordIDs.indexOf(rec.rowID);
}

/**
Expand Down