Skip to content

Commit aefc3e9

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add a chip drop indicator between the chips for rows.
1 parent 98c7619 commit aefc3e9

File tree

4 files changed

+45
-34
lines changed

4 files changed

+45
-34
lines changed

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@
561561
@extend %igx-grid__tr-pivot--filter-container !optional
562562
}
563563

564+
@include e(tr-pivot, $m: 'chip_drop_indicator') {
565+
@extend %igx-grid__tr-pivot--chip_drop_indicator !optional
566+
}
567+
564568
@include e(tr-pivot, $m: 'drop-row-area') {
565569
@extend %igx-grid__tr-pivot--drop-row-area !optional
566570
}

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@
29102910
width: auto;
29112911

29122912
> * {
2913-
margin-#{$right}: rem(8px);
2913+
margin-#{$right}: rem(4px);
29142914
}
29152915

29162916
&:last-child {
@@ -2941,6 +2941,11 @@
29412941
flex-direction: column;
29422942
}
29432943

2944+
%igx-grid__tr-pivot--chip_drop_indicator {
2945+
width: 2px;
2946+
background: var-get($theme, 'resize-line-color');
2947+
}
2948+
29442949
%igx-grid__tr-pivot--drop-row-area {
29452950
flex-grow: 1;
29462951
}

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.html

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</igx-chips-area>
2727
</div>
2828
<div class='igx-grid__tr-pivot--drop-row-area' (igxDragEnter)="onAreaDragEnter($event, rowArea, 0)"
29-
(igxDragLeave)="onAreaDragLeave($event, rowArea)" igxDrop (dropped)="onDimDrop($event, rowArea, 0)">
29+
(igxDragLeave)="onAreaDragLeave($event, rowArea)" igxDrop (dropped)="onDimDrop($event, rowArea, 0)">
3030
</div>
3131
</div>
3232

@@ -97,21 +97,27 @@
9797
<!-- Row area -->
9898
<igx-chips-area #rowArea droppable='true'>
9999
<ng-container *ngIf="grid.showPivotConfigurationUI">
100-
<span igxDrop (dropped)="onDimDrop($event, rowArea, 0)"
100+
<span igxDrop (dropped)="onDimDrop($event, rowArea, 0)"
101101
*ngIf="grid.rowDimensions.length === 0 && grid.showPivotConfigurationUI"
102102
class='igx-pivot__emptyChipArea'>Drop Row Fields here.</span>
103-
<igx-chip *ngFor="let row of grid.rowDimensions" [draggable]="true" [id]="row.memberName"
104-
[displayDensity]="grid.displayDensity" [removable]="true" (remove)="rowRemoved($event)"
105-
(dragLeave)="onDimDragLeave($event)" (dragDrop)="onDimDrop($event, rowArea, 0)"
106-
(dragOver)="onDimDragOver($event, 0)" (moveStart)='onDimDragStart($event, rowArea)'
107-
(moveEnd)='onDimDragEnd()' (click)="onChipSort($event, row, 0)">
108-
<igx-icon igxPrefix>table_rows</igx-icon>
109-
<igx-icon igxPrefix (pointerdown)='onFilteringIconPointerDown($event)'
110-
(click)='onFilteringIconClick($event, row)'>filter_list</igx-icon>
111-
{{ row.memberName}}
112-
<igx-icon *ngIf="row.sortDirection" igxSuffix> {{ row.sortDirection < 2 ? 'arrow_upward'
113-
: 'arrow_downward' }}</igx-icon>
114-
</igx-chip>
103+
<ng-container *ngFor="let row of grid.rowDimensions; let last = last;">
104+
<span [style.visibility]='"hidden"' class="igx-grid__tr-pivot--chip_drop_indicator" [style.height.px]='getAreaHeight(rowArea)'></span>
105+
<igx-chip [draggable]="true" [id]="row.memberName" [displayDensity]="grid.displayDensity"
106+
[removable]="true" (remove)="rowRemoved($event)" (dragLeave)="onDimDragLeave($event)"
107+
(dragDrop)="onDimDrop($event, rowArea, 0)" (dragOver)="onDimDragOver($event, 0)"
108+
(moveStart)='onDimDragStart($event, rowArea)' (moveEnd)='onDimDragEnd()'
109+
(click)="onChipSort($event, row, 0)">
110+
<igx-icon igxPrefix>table_rows</igx-icon>
111+
<igx-icon igxPrefix (pointerdown)='onFilteringIconPointerDown($event)'
112+
(click)='onFilteringIconClick($event, row)'>filter_list</igx-icon>
113+
{{ row.memberName}}
114+
<igx-icon *ngIf="row.sortDirection" igxSuffix> {{ row.sortDirection < 2 ? 'arrow_upward'
115+
: 'arrow_downward' }}</igx-icon>
116+
</igx-chip>
117+
<ng-container *ngIf='last'>
118+
<span [style.visibility]='"hidden"' class="igx-grid__tr-pivot--chip_drop_indicator" [style.height.px]='getAreaHeight(rowArea)'></span>
119+
</ng-container>
120+
</ng-container>
115121
<igx-chip igxDrop (dragDrop)="onDimDrop($event, rowArea, 0)" #notifyChip [hidden]='true'>
116122
Drop here to use as row
117123
</igx-chip>

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from '@angular/core';
1111
import { first } from 'rxjs/operators';
1212
import { IBaseChipEventArgs, IgxChipComponent } from '../../chips/chip.component';
13+
import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
1314
import { GridColumnDataType } from '../../data-operations/data-util';
1415
import { SortingDirection } from '../../data-operations/sorting-strategy';
1516
import { ISelectionEventArgs } from '../../drop-down/drop-down.common';
@@ -39,8 +40,6 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
3940

4041
public value: IPivotValue;
4142
private _dropPos = DropPosition.AfterDropTarget;
42-
private _dropLeftIndicatorClass = 'igx-pivot-grid__drop-indicator--left';
43-
private _dropRightIndicatorClass = 'igx-pivot-grid__drop-indicator--right';
4443
private valueData: Map<string, IPivotAggregator[]>;
4544
private _subMenuPositionSettings: PositionSettings = {
4645
verticalStartPoint: VerticalAlignment.Bottom,
@@ -86,6 +85,11 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
8685
}
8786
}
8887

88+
public getAreaHeight(area: IgxChipsAreaComponent) {
89+
const chips = area.chipsList;
90+
return chips && chips.length > 0 ? chips.first.nativeElement.clientHeight : 0;
91+
}
92+
8993
public getAggregateList(val: IPivotValue): IPivotAggregator[] {
9094
if (!val.aggregateList) {
9195
let defaultAggr = this.getAggregatorsForValue(val);
@@ -216,23 +220,17 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
216220

217221
this._dropPos = event.originalEvent.offsetX > pos ? DropPosition.AfterDropTarget : DropPosition.BeforeDropTarget;
218222
if (this._dropPos === DropPosition.AfterDropTarget) {
219-
event.owner.nativeElement.style.borderRight = '1px solid red';
220-
event.owner.nativeElement.style.borderLeft = '';
221-
this.renderer.removeClass(event.owner.nativeElement, this._dropLeftIndicatorClass);
222-
this.renderer.addClass(event.owner.nativeElement, this._dropRightIndicatorClass);
223+
event.owner.nativeElement.previousElementSibling.style.visibility = 'hidden';
224+
event.owner.nativeElement.nextElementSibling.style.visibility = '';
223225
} else {
224-
event.owner.nativeElement.style.borderRight = '';
225-
event.owner.nativeElement.style.borderLeft = '1px solid red';
226-
this.renderer.addClass(event.owner.nativeElement, this._dropLeftIndicatorClass);
227-
this.renderer.removeClass(event.owner.nativeElement, this._dropRightIndicatorClass);
226+
event.owner.nativeElement.nextElementSibling.style.visibility = 'hidden';
227+
event.owner.nativeElement.previousElementSibling.style.visibility = '';
228228
}
229229
}
230230

231231
public onDimDragLeave(event) {
232-
this.renderer.removeClass(event.owner.nativeElement, this._dropLeftIndicatorClass);
233-
this.renderer.removeClass(event.owner.nativeElement, this._dropRightIndicatorClass);
234-
event.owner.nativeElement.style.borderLeft = '';
235-
event.owner.nativeElement.style.borderRight = '';
232+
event.owner.nativeElement.previousElementSibling.style.visibility = 'hidden';
233+
event.owner.nativeElement.nextElementSibling.style.visibility = 'hidden';
236234
this._dropPos = DropPosition.AfterDropTarget;
237235
}
238236

@@ -250,16 +248,14 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
250248
const targetElem = event.detail.originalEvent.target;
251249
const targetOwner = event.detail.owner.element.nativeElement.parentElement;
252250
if (targetOwner !== lastElem && targetElem.getBoundingClientRect().x >= lastElem.getBoundingClientRect().x) {
253-
this.renderer.addClass(area.chipsList.last.nativeElement, this._dropRightIndicatorClass);
254-
// TODO- remove once classes are added.
255-
area.chipsList.last.nativeElement.style.borderRight = '1px solid red';
251+
area.chipsList.last.nativeElement.nextElementSibling.style.visibility = '';
256252
}
257253
}
258254
}
259255
public onAreaDragLeave(event, area) {
260256
area.chipsList.toArray().forEach(element => {
261-
this.renderer.removeClass(element.nativeElement, this._dropRightIndicatorClass);
262-
element.nativeElement.style.borderRight = '';
257+
event.owner.nativeElement.previousElementSibling.style.visibility = 'hidden';
258+
event.owner.nativeElement.nextElementSibling.style.visibility = 'hidden';
263259
});
264260
}
265261

0 commit comments

Comments
 (0)