Skip to content

Commit

Permalink
Merge branch 'vNext' into dTsvetkov/replace-node-sass-vnext
Browse files Browse the repository at this point in the history
  • Loading branch information
zdrawku committed Jul 29, 2021
2 parents 0116154 + 046d1f6 commit 6f23a45
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 8 deletions.
12 changes: 12 additions & 0 deletions live-editing/configs/GridConfigGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,18 @@ export class GridConfigGenerator implements IConfigGenerator {
})
}));

configs.push(new Config({
component: 'GridDropIndicatorComponent',
additionalFiles: ['/src/app/directives/prevent-scroll.directive.ts',
'/src/app/data/customers.ts'
],
appModuleConfig: new AppModuleConfig({
imports: ['IgxGridModule', 'GridDropIndicatorComponent', 'IgxDragDropModule', 'IgxPreventDocumentScrollModule'],
ngDeclarations: ['GridDropIndicatorComponent'],
ngImports: ['IgxPreventDocumentScrollModule', 'IgxGridModule', 'IgxDragDropModule']
})
}));

configs.push(new Config({
component: 'GridGroupByPagingSampleComponent',
additionalFiles: ['/src/app/directives/prevent-scroll.directive.ts',
Expand Down
2 changes: 1 addition & 1 deletion live-editing/configs/HierarchicalGridConfigGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export class HierarchicalGridConfigGenerator implements IConfigGenerator {
}));

configs.push(new Config({
additionalFiles: ['/src/app/directives/prevent-scroll.directive.ts', '/src/app/data/customers.ts'],
additionalFiles: ['/src/app/directives/prevent-scroll.directive.ts', '/src/app/data/hierarchical-data.ts'],
appModuleConfig: new AppModuleConfig({
imports: ['IgxHierarchicalGridModule', 'HGridMultiColumnHeadersExportComponent', 'IgxPreventDocumentScrollModule'],
ngDeclarations: ['HGridMultiColumnHeadersExportComponent'],
Expand Down
2 changes: 1 addition & 1 deletion live-editing/configs/TreeGridConfigGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export class TreeGridConfigGenerator implements IConfigGenerator {
// TreeGrid Multi Column Headers Export
configs.push(new Config({
component: 'TreeGridMultiColumnHeadersExportComponent',
additionalFiles: ['/src/app/directives/prevent-scroll.directive.ts', '/src/app/data/customers.ts'],
additionalFiles: ['/src/app/directives/prevent-scroll.directive.ts', '/src/app/tree-grid/data/employees-flat-detailed.ts'],
appModuleConfig: new AppModuleConfig({
imports: ['TreeGridMultiColumnHeadersExportComponent', 'IgxTreeGridModule', 'IgxPreventDocumentScrollModule'],
ngDeclarations: ['TreeGridMultiColumnHeadersExportComponent'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ export class DataAnalysisDockManagerComponent implements OnInit, AfterViewInit,
if ((!this.grid.getRowByIndex(this.rowIndex) || (this.grid.rowList.toArray().indexOf(this.grid.getRowByIndex(this.rowIndex)) >= this.grid.rowList.length - 2) && this.rowIndex + 2 < this.grid.dataLength)) {
const lastFullyVisibleRowIndex = this.grid.rowList.toArray()[this.grid.rowList.length - 3].index;
const field = this.grid.visibleColumns[this.colIndex].field;
cell = this.grid.getCellByColumn(lastFullyVisibleRowIndex, field);
cell = this.grid.gridAPI.get_cell_by_index(lastFullyVisibleRowIndex, field);
} else {
cell = this.grid.getCellByColumn(this.rowIndex, this.grid.visibleColumns[this.colIndex].field);
cell = this.grid.gridAPI.get_cell_by_index(this.rowIndex, this.grid.visibleColumns[this.colIndex].field);
}

if (!cell) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ export class GridDynamicChartDataComponent implements OnInit, AfterViewInit, OnD
if ((!this.grid.getRowByIndex(this.rowIndex) || (this.grid.rowList.toArray().indexOf(this.grid.getRowByIndex(this.rowIndex)) >= this.grid.rowList.length - 2) && this.rowIndex + 2 < this.grid.dataLength)) {
const lastFullyVisibleRowIndex = this.grid.rowList.toArray()[this.grid.rowList.length - 3].index;
const field = this.grid.visibleColumns[this.colIndex].field;
cell = this.grid.getCellByColumn(lastFullyVisibleRowIndex, field);
cell = this.grid.gridAPI.get_cell_by_index(lastFullyVisibleRowIndex, field);
} else {
cell = this.grid.getCellByColumn(this.rowIndex, this.grid.visibleColumns[this.colIndex].field);
cell = this.grid.gridAPI.get_cell_by_index(this.rowIndex, this.grid.visibleColumns[this.colIndex].field);
}

if (!cell) {
Expand Down
1 change: 0 additions & 1 deletion src/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
$__legacy-libsass: true;
@import '~igniteui-angular/lib/core/styles/themes/index';

$legacy-support: true;
Expand Down
16 changes: 16 additions & 0 deletions src/app/grid/grid-drop-indicator/grid-drop-indicator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="grid-container">
<igx-grid igxPreventDocumentScroll #grid [data]="data" height="800px" width="1000px" [autoGenerate]="false" [rowDraggable]="true"
primaryKey="ID" igxDrop (dropped)="onDropAllowed($event)">
<igx-column field="ID" header="ID" width="100px"></igx-column>
<igx-column field="CompanyName" header="Company Name" width="100px"></igx-column>
<igx-column field="ContactName" header="Contact Name" width="100px" minWidth="60px"
maxWidth="230px"></igx-column>
<igx-column field="ContactTitle" header="Contact Title" width="100px"></igx-column>
<igx-column field="Address" header="Address" width="100px"></igx-column>
<igx-column field="City" header="City" width="100px"></igx-column>
<igx-column field="Region" header="Region" width="100px"></igx-column>
<igx-column field="PostalCode" header="Postal Code" width="100px"></igx-column>
<igx-column field="Phone" header="Phone" width="100px"></igx-column>
<igx-column field="Fax" header="Fax" width="100px"></igx-column>
</igx-grid>
</div>
24 changes: 24 additions & 0 deletions src/app/grid/grid-drop-indicator/grid-drop-indicator.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.grid-container {
display: flex;
padding: 20px;
}

.grid-container .drop-area {
height: 500px;
width: 50%;
margin: 10px 20px;
}

.empty-grid {
display: flex;
justify-content: center;
flex-direction: column;
text-align: center;
height: 100%;
}

:host ::ng-deep {
.underlined-class {
border-bottom: 52px solid #d3d3d3;
}
}
201 changes: 201 additions & 0 deletions src/app/grid/grid-drop-indicator/grid-drop-indicator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import { Component, ViewChild, AfterViewInit, OnDestroy, Renderer2 } from '@angular/core';
import { IDragMoveEventArgs, IDropDroppedEventArgs, IgxGridComponent, IRowDragStartEventArgs, Point } from 'igniteui-angular';
import { DATA } from '../../data/customers';
import { Subject, interval, Observable, Subscription } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

@Component({
selector: 'app-grid-drop-indicator',
styleUrls: ['grid-drop-indicator.scss'],
templateUrl: 'grid-drop-indicator.html'
})
export class GridDropIndicatorComponent implements AfterViewInit, OnDestroy {
@ViewChild('grid', { read: IgxGridComponent, static: true })
public grid: IgxGridComponent;
public data: any[];
private destroy$ = new Subject();
private intervalSub: Subscription;
private interval$: Observable<number>;
private _draggedRow: any;
private highlightedRow: HTMLElement;

constructor(private renderer: Renderer2) {
this.data = DATA;
}

public onDropAllowed(args: IDropDroppedEventArgs): void {
const event = args.originalEvent;
const currRowIndex = this.getRowIndexAtPoint(this.grid.rowList.toArray(), {
x: event.clientX,
y: event.clientY
});
if (currRowIndex === -1) {
return;
}
// remove the row that was dragged and place it onto its new location
this.grid.deleteRow(this._draggedRow[this.grid.primaryKey]);
this.data.splice(currRowIndex, 0, this._draggedRow);
this.clearHighlightElement();
}

public ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}

public ngAfterViewInit() {
this.grid.rowDragStart
.pipe(takeUntil(this.destroy$))
.subscribe(this.handleRowStart.bind(this));
this.grid.rowDragEnd
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.unsubInterval();
this.clearHighlightElement();
});
}

private getRowIndexAtPoint(
rowList: any[],
cursorPosition: Point
): number {
for (const row of rowList) {
const rowRect = row.nativeElement.getBoundingClientRect();
if (
cursorPosition.y > rowRect.top + window.scrollY &&
cursorPosition.y < rowRect.bottom + window.scrollY &&
cursorPosition.x > rowRect.left + window.scrollX &&
cursorPosition.x < rowRect.right + window.scrollX
) {
// return the index of the targeted row
return this.data.indexOf(this.data.find(r => r.ID === row.rowID));
}
}

return -1;
}

/**
* Unsubs from the autoscroll interval
*/
private unsubInterval(): void {
if (this.intervalSub) {
this.intervalSub.unsubscribe();
this.intervalSub = null;
}
}

/**
* Handles the grid.onRowDragStart event
*/
private handleRowStart(e: IRowDragStartEventArgs): void {
if (e !== null) {
this._draggedRow = e.dragData.data;
}
const directive = e.dragDirective;
directive.dragMove
.pipe(takeUntil(this.grid.rowDragEnd))
.subscribe(this.handleDragMove.bind(this));
}

/**
* Handles the onDragMove event
*/
private handleDragMove(event: IDragMoveEventArgs): void {
this.handleOver(event);
this.unsubInterval();
const dir = this.isPointOnGridEdge(event.pageY);
if (!dir) {
return;
}
this.scrollGrid(dir);
if (!this.intervalSub) {
this.interval$ = interval(500);
this.intervalSub = this.interval$.subscribe(() => this.scrollGrid(dir));
}
}

/**
* Returns if the point is on the upper (-1) or lower (1) edge of a rectangle
*/
private isPointOnGridEdge(pageY: number): 1 | -1 {
const rect: ClientRect = this.grid.nativeElement
.querySelector('.igx-grid__tbody')
.getBoundingClientRect();
if (pageY >= rect.bottom) {
return 1;
} else if (pageY <= rect.top) {
return -1;
}
}

/**
* Checks if the grid is scrolled to its upper (-1) or lower (1) edge
*/
private isGridScrolledToEdge(dir: 1 | -1): boolean {
if (this.grid.data[0] === this.grid.rowList.first.data && dir === -1) {
return true;
}
if (
this.grid.data[this.grid.data.length - 1] ===
this.grid.rowList.last.data &&
dir === 1
) {
return true;
}
return false;
}

/**
* Attempts to scroll the grid in target direction
*
* Returns whether the grid was scrolled
*/
private scrollGrid(dir: 1 | -1): void {
if (!this.isGridScrolledToEdge(dir)) {
if (dir === 1) {
this.grid.verticalScrollContainer.scrollNext();
} else {
this.grid.verticalScrollContainer.scrollPrev();
}
}
}

private handleOver(event: IDragMoveEventArgs) {
const ghostRect = event.owner.ghostElement.getBoundingClientRect();
const rowIndex = this.getRowIndexAtPoint(this.grid.rowList.toArray(), {
x: ghostRect.x,
y: ghostRect.y
});
if (rowIndex === -1) {
return;
}
const rowElement = this.grid.rowList.find(
e => e.rowData.ID === this.grid.data[rowIndex].ID
);
if (rowElement) {
this.changeHighlightedElement(rowElement.element.nativeElement);
}
}

private clearHighlightElement(): void {
if (this.highlightedRow !== undefined) {
this.renderer.removeClass(this.highlightedRow, 'underlined-class');
}
}
private setHightlightElement(newElement: HTMLElement) {
this.renderer.addClass(newElement, 'underlined-class');
this.highlightedRow = newElement;
}

private changeHighlightedElement(newElement: HTMLElement) {
if (newElement !== undefined) {
if (newElement !== this.highlightedRow) {
this.clearHighlightElement();
this.setHightlightElement(newElement);
} else {
return;
}
}
}
}
1 change: 1 addition & 0 deletions src/app/grid/grid-routes-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const gridsRoutesData = {
'grid-row-drag-base': { displayName: 'Grid Row Drag - Base', parentName: 'Grid' },
'grid-row-drag-to-grid': { displayName: 'Row Drag between Grids', parentName: 'Grid' },
'grid-row-reorder': { displayName: 'Grid Row Reorder', parentName: 'Grid' },
'grid-drop-indicator': { displayName: 'Grid Drop Indicator', parentName: 'Grid' },
'grid-batch-editing': { displayName: 'Grid Batch Editing', parentName: 'Grid' },
'grid-action-strip': { displayName: 'Grid with Action Strip', parentName: 'Grid' },
'grid-displayDensity': { displayName: 'Grid Display Density', parentName: 'Grid' },
Expand Down
6 changes: 6 additions & 0 deletions src/app/grid/grids-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { GridRowPinningExtraColumnSampleComponent } from './grid-row-pinning-ext
import { GridRowPinningStylingSampleComponent } from './grid-row-pinning-styling/grid-row-pinning-styling.component';
import { GridRowPinningSampleComponent } from './grid-row-pinning/grid-row-pinning.component';
import { GridRowReorderComponent } from './grid-row-reorder-sample/grid-row-reorder';
import { GridDropIndicatorComponent } from './grid-drop-indicator/grid-drop-indicator';
import { FinancialSampleComponent } from './grid-sample-2/grid-sample-2.component';
import { GridSample3Component } from './grid-sample-3/grid-sample-3.component';
import { GridRemoteVirtualizationSampleComponent } from './grid-sample-4/grid-sample-4.component';
Expand Down Expand Up @@ -209,6 +210,11 @@ export const gridsRoutes: Routes = [
data: gridsRoutesData['grid-row-reorder'],
path: 'grid-row-reorder'
},
{
component: GridDropIndicatorComponent,
data: gridsRoutesData['grid-drop-indicator'],
path: 'grid-drop-indicator'
},
{
component: GridRowPinningSampleComponent,
data: gridsRoutesData['grid-row-pinning'],
Expand Down
2 changes: 2 additions & 0 deletions src/app/grid/grids.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import { GridRowPinningExtraColumnSampleComponent } from './grid-row-pinning-ext
import { GridRowPinningStylingSampleComponent } from './grid-row-pinning-styling/grid-row-pinning-styling.component';
import { GridRowPinningSampleComponent } from './grid-row-pinning/grid-row-pinning.component';
import { GridRowReorderComponent } from './grid-row-reorder-sample/grid-row-reorder';
import { GridDropIndicatorComponent } from './grid-drop-indicator/grid-drop-indicator';
import { FinancialSampleComponent } from './grid-sample-2/grid-sample-2.component';
import { GridSample3Component } from './grid-sample-3/grid-sample-3.component';
import { GridRemoteVirtualizationSampleComponent } from './grid-sample-4/grid-sample-4.component';
Expand Down Expand Up @@ -204,6 +205,7 @@ import { GridMultiColumnHeadersExportComponent } from './multi-column-headers-ex
ContextmenuComponent,
CustomGridPagingStyleSampleComponent,
GridRowReorderComponent,
GridDropIndicatorComponent,
GridColumnHidingToolbarStyleComponent,
GridMultiColumnHeaderTemplateComponent,
GridClipboardSampleComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<igx-date-range-picker [value]="range" [mode]="'dropdown'"></igx-date-range-picker>
<igx-date-range-picker [value]="range" [mode]="'dialog'"></igx-date-range-picker>

0 comments on commit 6f23a45

Please sign in to comment.