• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.59
/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    ChangeDetectorRef,
4
    Component,
5
    ElementRef,
6
    Inject,
7
    OnChanges,
8
    QueryList,
9
    Renderer2,
10
    ViewChild,
11
    SimpleChanges,
12
    ViewChildren
13
} from '@angular/core';
14
import { IBaseChipEventArgs, IgxChipComponent } from '../../chips/chip.component';
15
import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
16
import { SortingDirection } from '../../data-operations/sorting-strategy';
17
import { IgxGridForOfDirective } from '../../directives/for-of/for_of.directive';
18
import { ISelectionEventArgs } from '../../drop-down/drop-down.common';
19
import { IgxDropDownComponent } from '../../drop-down/drop-down.component';
20
import { AbsoluteScrollStrategy, AutoPositionStrategy, OverlaySettings, PositionSettings, VerticalAlignment } from '../../services/public_api';
21
import { ColumnType, IGX_GRID_BASE, PivotGridType } from '../common/grid.interface';
22
import { IgxGridHeaderGroupComponent } from '../headers/grid-header-group.component';
23
import { IgxGridHeaderRowComponent } from '../headers/grid-header-row.component';
24
import { DropPosition } from '../moving/moving.service';
25
import { IPivotAggregator, IPivotDimension, IPivotValue, PivotDimensionType } from './pivot-grid.interface';
26
import { PivotUtil } from './pivot-util';
27
import { IgxGridTopLevelColumns } from '../common/pipes';
28
import { IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe } from '../headers/pipes';
29
import { IgxExcelStyleSearchComponent } from '../filtering/excel-style/excel-style-search.component';
30
import { IgxGridExcelStyleFilteringComponent, IgxExcelStyleColumnOperationsTemplateDirective, IgxExcelStyleFilterOperationsTemplateDirective } from '../filtering/excel-style/excel-style-filtering.component';
31
import { IgxDropDownItemComponent } from '../../drop-down/drop-down-item.component';
32
import { IgxDropDownItemNavigationDirective } from '../../drop-down/drop-down-navigation.directive';
33
import { IgxSuffixDirective } from '../../directives/suffix/suffix.directive';
34
import { IgxBadgeComponent } from '../../badge/badge.component';
35
import { IgxPrefixDirective } from '../../directives/prefix/prefix.directive';
36
import { IgxIconComponent } from '../../icon/icon.component';
37
import { IgxDropDirective } from '../../directives/drag-drop/drag-drop.directive';
38
import { NgIf, NgFor, NgTemplateOutlet, NgClass, NgStyle } from '@angular/common';
39
import { IgxPivotRowHeaderGroupComponent } from './pivot-row-header-group.component';
40
import { IgxPivotRowDimensionHeaderGroupComponent } from './pivot-row-dimension-header-group.component';
41

42
/**
43
 *
44
 * For all intents & purposes treat this component as what a <thead> usually is in the default <table> element.
45
 *
46
 * This container holds the pivot grid header elements and their behavior/interactions.
47
 *
48
 * @hidden @internal
49
 */
50
@Component({
51
    changeDetection: ChangeDetectionStrategy.OnPush,
52
    selector: 'igx-pivot-header-row',
53
    templateUrl: './pivot-header-row.component.html',
54
    imports: [NgIf, IgxDropDirective, IgxChipsAreaComponent, NgFor, IgxChipComponent, IgxIconComponent,
55
        IgxPrefixDirective, IgxBadgeComponent, IgxSuffixDirective, IgxDropDownItemNavigationDirective,
56
        NgTemplateOutlet, IgxGridHeaderGroupComponent, NgClass, NgStyle, IgxGridForOfDirective,
57
        IgxDropDownComponent, IgxDropDownItemComponent, IgxGridExcelStyleFilteringComponent,
58
        IgxExcelStyleColumnOperationsTemplateDirective, IgxExcelStyleFilterOperationsTemplateDirective,
59
        IgxExcelStyleSearchComponent, IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe, IgxGridTopLevelColumns,
60
        IgxPivotRowHeaderGroupComponent]
61
})
62
export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implements OnChanges {
2✔
UNCOV
63
    public aggregateList: IPivotAggregator[] = [];
×
64

65
    public value: IPivotValue;
UNCOV
66
    public filterDropdownDimensions: Set<any> = new Set<any>();
×
UNCOV
67
    public filterAreaDimensions: Set<any> = new Set<any>();
×
UNCOV
68
    private _dropPos = DropPosition.AfterDropTarget;
×
69
    private valueData: Map<string, IPivotAggregator[]>;
UNCOV
70
    private _subMenuPositionSettings: PositionSettings = {
×
71
        verticalStartPoint: VerticalAlignment.Bottom,
72
        closeAnimation: undefined
73
    };
UNCOV
74
    private _subMenuOverlaySettings: OverlaySettings = {
×
75
        closeOnOutsideClick: true,
76
        modal: false,
77
        positionStrategy: new AutoPositionStrategy(this._subMenuPositionSettings),
78
        scrollStrategy: new AbsoluteScrollStrategy()
79
    };
80

81
    /**
82
     * @hidden @internal
83
     */
84
    @ViewChild('esf') public esf: any;
85

86
    /**
87
     * @hidden @internal
88
     */
89
    @ViewChild('filterAreaHidden', { static: false }) public filterArea;
90

91
    /**
92
     * @hidden @internal
93
     */
94
    @ViewChild('filterIcon') public filtersButton;
95

96
    /**
97
     * @hidden @internal
98
     */
99
    @ViewChild('dropdownChips') public dropdownChips;
100

101
    /**
102
     * @hidden @internal
103
     */
104
    @ViewChild('pivotFilterContainer') public pivotFilterContainer;
105

106
    /**
107
     * @hidden @internal
108
     */
109
    @ViewChild('pivotRowContainer') public pivotRowContainer;
110

111
    /**
112
    * @hidden
113
    * @internal
114
    */
115
    @ViewChildren('notifyChip')
116
    public notificationChips: QueryList<IgxChipComponent>;
117

118
    /**
119
    * @hidden
120
    * @internal
121
    * The virtualized part of the header row containing the unpinned header groups.
122
    */
123
    @ViewChildren('headerVirtualContainer', { read: IgxGridForOfDirective })
124
    public headerContainers: QueryList<IgxGridForOfDirective<ColumnType, ColumnType[]>>;
125

126
    /**
127
    * @hidden
128
    * @internal
129
    */
130
    @ViewChildren('rowDimensionHeaders')
131
    public rowDimensionHeaders: QueryList<IgxPivotRowDimensionHeaderGroupComponent>;
132

133
    public override get headerForOf() {
UNCOV
134
        return this.headerContainers?.last;
×
135
    }
136

137
    constructor(
UNCOV
138
        @Inject(IGX_GRID_BASE) public override grid: PivotGridType,
×
139
        ref: ElementRef<HTMLElement>,
140
        cdr: ChangeDetectorRef,
UNCOV
141
        protected renderer: Renderer2,
×
142
    ) {
UNCOV
143
        super(ref, cdr);
×
144
    }
145

146
    /**
147
    * @hidden
148
    * @internal
149
    * Default is a single empty level since default depth is 1
150
    */
UNCOV
151
    public columnDimensionsByLevel: any[] = [[]];
×
152

153
    /**
154
    * @hidden @internal
155
    */
156
    public get isFiltersButton(): boolean {
UNCOV
157
        let chipsWidth = 0;
×
UNCOV
158
        this.filterDropdownDimensions.clear();
×
UNCOV
159
        this.filterAreaDimensions.clear();
×
UNCOV
160
        if (this.filterArea?.chipsList && this.filterArea.chipsList.length !== 0) {
×
UNCOV
161
            const styles = getComputedStyle(this.pivotFilterContainer.nativeElement);
×
UNCOV
162
            const containerPaddings = parseFloat(styles.paddingLeft) + parseFloat(styles.paddingRight);
×
UNCOV
163
            chipsWidth += containerPaddings + (this.filtersButton && this.filterArea?.chipsList.length > 1 ? this.filtersButton.el.nativeElement.getBoundingClientRect().width : 0);
×
UNCOV
164
            this.filterArea.chipsList.forEach(chip => {
×
UNCOV
165
                const dim = this.grid.filterDimensions.find(x => x.memberName === chip.id);
×
UNCOV
166
                if (dim) {
×
167
                    // 8 px margin between chips
UNCOV
168
                    const currentChipWidth = chip.nativeElement.getBoundingClientRect().width + 8;
×
UNCOV
169
                    if (chipsWidth + currentChipWidth < this.grid.pivotRowWidths) {
×
UNCOV
170
                        this.filterAreaDimensions.add(dim);
×
171
                    } else {
UNCOV
172
                        this.filterDropdownDimensions.add(dim);
×
173
                    }
UNCOV
174
                    chipsWidth += currentChipWidth;
×
175
                }
176
            });
UNCOV
177
            return this.filterDropdownDimensions.size > 0;
×
178
        }
UNCOV
179
        return false;
×
180
    }
181

182
    /**
183
    * @hidden
184
    * @internal
185
    */
186
    public get totalDepth() {
UNCOV
187
        const columnDimensions = this.grid.columnDimensions;
×
UNCOV
188
        if (columnDimensions.length === 0) {
×
UNCOV
189
            return 1;
×
190
        }
UNCOV
191
        let totalDepth = columnDimensions.map(x => PivotUtil.getDimensionDepth(x) + 1).reduce((acc, val) => acc + val);
×
UNCOV
192
        if (this.grid.hasMultipleValues) {
×
UNCOV
193
            totalDepth += 1;
×
194
        }
UNCOV
195
        return totalDepth;
×
196
    }
197

198
    /**
199
    * @hidden
200
    * @internal
201
    */
202
    public get maxContainerHeight() {
UNCOV
203
        return this.totalDepth * this.grid.renderedRowHeight;
×
204
    }
205

206
    /**
207
    * @hidden
208
    * @internal
209
    */
210
    public calcHeight(col: ColumnType, index: number) {
UNCOV
211
        return !col.columnGroup && col.level < this.totalDepth && col.level === index ? (this.totalDepth - col.level) * this.grid.rowHeight : this.grid.rowHeight;
×
212
    }
213

214
    /**
215
    * @hidden
216
    * @internal
217
    */
218
    public isDuplicateOfExistingParent(col: ColumnType, lvl: number) {
UNCOV
219
        const parentCollection = lvl > 0 ? this.columnDimensionsByLevel[lvl - 1] : [];
×
UNCOV
220
        const duplicate = parentCollection.indexOf(col) !== -1;
×
221

UNCOV
222
        return duplicate;
×
223
    }
224

225
    /**
226
    * @hidden
227
    * @internal
228
    */
229
    public isMultiRow(col: ColumnType, lvl: number) {
UNCOV
230
        const isLeaf = !col.columnGroup;
×
UNCOV
231
        return isLeaf && lvl !== this.totalDepth - 1;
×
232
    }
233

234
    /**
235
    * @hidden
236
    * @internal
237
    */
238
    public populateColumnDimensionsByLevel() {
UNCOV
239
        const res = [];
×
UNCOV
240
        for (let i = 0; i < this.totalDepth; i++) {
×
UNCOV
241
            res[i] = [];
×
242
        }
UNCOV
243
        const cols = this.unpinnedColumnCollection;
×
244
        // populate column dimension matrix recursively
UNCOV
245
        this.populateDimensionRecursively(cols.filter(x => x.level === 0), 0, res);
×
UNCOV
246
        this.columnDimensionsByLevel = res;
×
247
    }
248

249
    protected populateDimensionRecursively(currentLevelColumns: ColumnType[], level = 0, res: any[]) {
×
UNCOV
250
        currentLevelColumns.forEach(col => {
×
UNCOV
251
            if (res[level]) {
×
UNCOV
252
                res[level].push(col);
×
UNCOV
253
                if (col.columnGroup && col.children.length > 0) {
×
UNCOV
254
                    const visibleColumns = col.children.toArray().filter(x => !x.hidden);
×
UNCOV
255
                    this.populateDimensionRecursively(visibleColumns, level + 1, res);
×
UNCOV
256
                } else if (level < this.totalDepth - 1) {
×
UNCOV
257
                    for (let i = level + 1; i <= this.totalDepth - 1; i++) {
×
UNCOV
258
                        res[i].push(col);
×
259
                    }
260
                }
261
            }
262
        });
263
    }
264

265
    /**
266
    * @hidden
267
    * @internal
268
    */
269
    public ngOnChanges(changes: SimpleChanges) {
UNCOV
270
        if (changes.unpinnedColumnCollection) {
×
UNCOV
271
            this.populateColumnDimensionsByLevel();
×
272
        }
273
    }
274

275
    /**
276
    * @hidden
277
    * @internal
278
    */
279
    public onDimDragStart(event, area) {
UNCOV
280
        this.cdr.detectChanges();
×
UNCOV
281
        for (const chip of this.notificationChips) {
×
UNCOV
282
            const parent = chip.nativeElement.parentElement;
×
UNCOV
283
            if (area.chipsList.toArray().indexOf(chip) === -1 &&
×
284
                parent.children.length > 0 &&
285
                parent.children.item(0).id !== 'empty') {
UNCOV
286
                chip.nativeElement.hidden = false;
×
UNCOV
287
                parent.parentElement.scrollTo({ left: chip.nativeElement.offsetLeft });
×
288
            }
289
        }
290
    }
291

292
    /**
293
    * @hidden
294
    * @internal
295
    */
296
    public onDimDragEnd() {
UNCOV
297
        for (const chip of this.notificationChips) {
×
UNCOV
298
            chip.nativeElement.hidden = true;
×
299
        }
300
    }
301

302
    /**
303
    * @hidden
304
    * @internal
305
    */
306
    public getAreaHeight(area: IgxChipsAreaComponent) {
UNCOV
307
        const chips = area.chipsList;
×
UNCOV
308
        return chips && chips.length > 0 ? chips.first.nativeElement.offsetHeight : 0;
×
309
    }
310

311
    /**
312
    * @hidden
313
    * @internal
314
    */
315
    public rowRemoved(event: IBaseChipEventArgs) {
UNCOV
316
        const row = this.grid.pivotConfiguration.rows.find(x => x.memberName === event.owner.id);
×
UNCOV
317
        this.grid.toggleDimension(row);
×
318
    }
319

320
    /**
321
    * @hidden
322
    * @internal
323
    */
324
    public columnRemoved(event: IBaseChipEventArgs) {
UNCOV
325
        const col = this.grid.pivotConfiguration.columns.find(x => x.memberName === event.owner.id);
×
UNCOV
326
        this.grid.toggleDimension(col);
×
327
    }
328

329
    /**
330
    * @hidden
331
    * @internal
332
    */
333
    public valueRemoved(event: IBaseChipEventArgs) {
UNCOV
334
        const value = this.grid.pivotConfiguration.values.find(x => x.member === event.owner.id || x.displayName === event.owner.id);
×
UNCOV
335
        this.grid.toggleValue(value);
×
336
    }
337

338
    /**
339
    * @hidden
340
    * @internal
341
    */
342
    public filterRemoved(event: IBaseChipEventArgs) {
UNCOV
343
        const filter = this.grid.pivotConfiguration.filters.find(x => x.memberName === event.owner.id);
×
UNCOV
344
        this.grid.toggleDimension(filter);
×
UNCOV
345
        if (this.filterDropdownDimensions.size > 0) {
×
UNCOV
346
            this.onFiltersAreaDropdownClick({ target: this.filtersButton.el.nativeElement }, undefined, false);
×
347
        } else {
UNCOV
348
            this.grid.filteringService.hideESF();
×
349
        }
350
    }
351

352
    public onFiltersSelectionChanged(event?: IBaseChipEventArgs) {
UNCOV
353
        this.dropdownChips.chipsList.forEach(chip => {
×
UNCOV
354
            if (chip.id !== event.owner.id) {
×
UNCOV
355
                chip.selected = false
×
356
            }
357
        });
UNCOV
358
        this.onFiltersAreaDropdownClick({ target: this.filtersButton.el.nativeElement }, this.grid.filterDimensions.find(dim => dim.memberName === event.owner.id), false);
×
359
    }
360

361
    /**
362
    * @hidden
363
    * @internal
364
    */
365
    public onFilteringIconPointerDown(event) {
UNCOV
366
        event.stopPropagation();
×
UNCOV
367
        event.preventDefault();
×
368
    }
369

370
    /**
371
    * @hidden
372
    * @internal
373
    */
374
    public onFilteringIconClick(event, dimension) {
UNCOV
375
        event.stopPropagation();
×
UNCOV
376
        event.preventDefault();
×
UNCOV
377
        const dim = dimension;
×
UNCOV
378
        const col = this.grid.dimensionDataColumns.find(x => x.field === dim.memberName || x.field === dim.member);
×
UNCOV
379
        this.grid.filteringService.toggleFilterDropdown(event.target, col);
×
380
    }
381

382
    /**
383
    * @hidden
384
    * @internal
385
    */
386
    public onSummaryClick(eventArgs, value: IPivotValue, dropdown: IgxDropDownComponent, chip: IgxChipComponent) {
UNCOV
387
        this._subMenuOverlaySettings.target = eventArgs.currentTarget;
×
UNCOV
388
        this.updateDropDown(value, dropdown, chip);
×
389
    }
390

391
    /**
392
     * @hidden @internal
393
     */
394
    public onFiltersAreaDropdownClick(event, dimension?, shouldReattach = true) {
×
UNCOV
395
        const dim = dimension || this.filterDropdownDimensions.values().next().value;
×
UNCOV
396
        const col = this.grid.dimensionDataColumns.find(x => x.field === dim.memberName || x.field === dim.member);
×
UNCOV
397
        if (shouldReattach) {
×
UNCOV
398
            this.dropdownChips.chipsList.forEach(chip => {
×
UNCOV
399
                chip.selected = false
×
400
            });
UNCOV
401
            this.dropdownChips.chipsList.first.selected = true;
×
402
        }
UNCOV
403
        this.grid.filteringService.toggleFiltersESF(this.esf, event.target, col, shouldReattach);
×
404
    }
405

406
    /**
407
    * @hidden
408
    * @internal
409
    */
410
    public onAggregationChange(event: ISelectionEventArgs) {
UNCOV
411
        if (!this.isSelected(event.newSelection.value)) {
×
UNCOV
412
            this.value.aggregate = event.newSelection.value;
×
UNCOV
413
            this.grid.pipeTrigger++;
×
414
        }
415
    }
416

417
    /**
418
    * @hidden
419
    * @internal
420
    */
421
    public isSelected(val: IPivotAggregator) {
UNCOV
422
        return this.value.aggregate.key === val.key;
×
423
    }
424

425
    /**
426
    * @hidden
427
    * @internal
428
    */
429
    public onChipSort(_event, dimension: IPivotDimension) {
UNCOV
430
        if (dimension.sortable === undefined || dimension.sortable) {
×
UNCOV
431
            const startDirection = dimension.sortDirection || SortingDirection.None;
×
UNCOV
432
            const direction = startDirection + 1 > SortingDirection.Desc ?
×
433
                SortingDirection.None : startDirection + 1;
UNCOV
434
            this.grid.sortDimension(dimension, direction);
×
435
        }
436
    }
437

438
    /**
439
    * @hidden
440
    * @internal
441
    */
442
    public onDimDragOver(event, dimension?: PivotDimensionType) {
UNCOV
443
        if (!event.dragChip || !event.dragChip.data?.pivotArea) return;
×
UNCOV
444
        const typeMismatch = dimension !== undefined ? this.grid.pivotConfiguration.values.find(x => x.member === event.dragChip.id
×
445
            || x.displayName === event.dragChip.id) :
UNCOV
446
            !this.grid.pivotConfiguration.values.find(x => x.member === event.dragChip.id || x.displayName === event.dragChip.id);
×
UNCOV
447
        if (typeMismatch) {
×
448
            // cannot drag between dimensions and value
UNCOV
449
            return;
×
450
        }
451
        // if we are in the left half of the chip, drop on the left
452
        // else drop on the right of the chip
UNCOV
453
        const clientRect = event.owner.nativeElement.getBoundingClientRect();
×
UNCOV
454
        const pos = clientRect.width / 2;
×
455

UNCOV
456
        this._dropPos = event.originalEvent.offsetX > pos ? DropPosition.AfterDropTarget : DropPosition.BeforeDropTarget;
×
UNCOV
457
        if (this._dropPos === DropPosition.AfterDropTarget) {
×
UNCOV
458
            event.owner.nativeElement.previousElementSibling.style.visibility = 'hidden';
×
UNCOV
459
            event.owner.nativeElement.nextElementSibling.style.visibility = '';
×
460
        } else {
UNCOV
461
            event.owner.nativeElement.nextElementSibling.style.visibility = 'hidden';
×
UNCOV
462
            event.owner.nativeElement.previousElementSibling.style.visibility = '';
×
463
        }
464
    }
465

466
    /**
467
    * @hidden
468
    * @internal
469
    */
470
    public onDimDragLeave(event) {
UNCOV
471
        event.owner.nativeElement.previousElementSibling.style.visibility = 'hidden';
×
UNCOV
472
        event.owner.nativeElement.nextElementSibling.style.visibility = 'hidden';
×
UNCOV
473
        this._dropPos = DropPosition.AfterDropTarget;
×
474
    }
475

476
    /**
477
    * @hidden
478
    * @internal
479
    */
480
    public onAreaDragLeave(event, area) {
UNCOV
481
        const dataChips = area.chipsList.toArray().filter(x => this.notificationChips.toArray().indexOf(x) === -1);
×
UNCOV
482
        dataChips.forEach(element => {
×
UNCOV
483
            if (element.nativeElement.previousElementSibling) {
×
UNCOV
484
                element.nativeElement.previousElementSibling.style.visibility = 'hidden';
×
485
            }
UNCOV
486
            if (element.nativeElement.nextElementSibling) {
×
UNCOV
487
                element.nativeElement.nextElementSibling.style.visibility = 'hidden';
×
488
            }
489
        });
490
    }
491

492
    /**
493
    * @hidden
494
    * @internal
495
    */
496
    public onValueDrop(event, area) {
UNCOV
497
        if (!(event.dragChip && event.dragChip.data?.pivotArea) && !(event.dragData?.chip && !!event.dragData.chip.data.pivotArea)) return;
×
498
        //values can only be reordered
UNCOV
499
        const values = this.grid.pivotConfiguration.values;
×
UNCOV
500
        const dragId = event.dragChip?.id || event.dragData?.chip.id;
×
UNCOV
501
        const chipsArray = area.chipsList.toArray();
×
UNCOV
502
        let chipIndex = chipsArray.indexOf(event.owner) !== -1 ? chipsArray.indexOf(event.owner) : chipsArray.length;
×
UNCOV
503
        chipIndex = this._dropPos === DropPosition.AfterDropTarget ? chipIndex + 1 : chipIndex;
×
UNCOV
504
        const value = values.find(x => x.member === dragId || x.displayName === dragId);
×
UNCOV
505
        if (value) {
×
UNCOV
506
            const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
×
UNCOV
507
            this.grid.moveValue(value, dragChipIndex >= chipIndex ? chipIndex : chipIndex - 1);
×
508
        }
509
    }
510

511
    /**
512
    * @hidden
513
    * @internal
514
    */
515
    public onDimDrop(event, area, dimensionType: PivotDimensionType) {
UNCOV
516
        if (!(event.dragChip && event.dragChip.data?.pivotArea) && !(event.dragData?.chip && !!event.dragData.chip.data.pivotArea)) return;
×
UNCOV
517
        const dragId = event.dragChip?.id || event.dragData?.chip.id;
×
UNCOV
518
        const currentDim = this.grid.getDimensionsByType(dimensionType);
×
UNCOV
519
        const chipsArray = area.chipsList.toArray();
×
UNCOV
520
        const chip = chipsArray.find(x => x.id === dragId);
×
UNCOV
521
        const isNewChip = chip === undefined;
×
UNCOV
522
        const isReorder = event.owner.id !== undefined;
×
523
        //const chipIndex = chipsArray.indexOf(event.owner) !== -1 ? chipsArray.indexOf(event.owner) : chipsArray.length;
UNCOV
524
        const chipIndex = currentDim.findIndex(x => x.memberName === event.owner.id) !== -1 ?
×
UNCOV
525
            currentDim.findIndex(x => x.memberName === event.owner.id) : currentDim.length;
×
UNCOV
526
        const targetIndex = this._dropPos === DropPosition.AfterDropTarget ? chipIndex + 1 : chipIndex;
×
UNCOV
527
        if (isNewChip) {
×
528
            // chip moved from an external collection
UNCOV
529
            const dim = this.grid.allDimensions.find(x => x && x.memberName === dragId);
×
UNCOV
530
            if (!dim) {
×
531
                // you have dragged something that is not a dimension
532
                return;
×
533
            }
UNCOV
534
            this.grid.moveDimension(dim, dimensionType, targetIndex);
×
UNCOV
535
        } else if (isReorder) {
×
536
            // chip from same collection, reordered.
UNCOV
537
            const newDim = currentDim.find(x => x.memberName === dragId);
×
UNCOV
538
            const dragChipIndex = currentDim.findIndex(x => x.memberName === dragId);
×
UNCOV
539
            this.grid.moveDimension(newDim, dimensionType, dragChipIndex > chipIndex ? targetIndex : targetIndex - 1);
×
540
        }
UNCOV
541
        this.grid.pipeTrigger++;
×
UNCOV
542
        this.grid.dimensionsChange.emit({ dimensions: currentDim, dimensionCollectionType: dimensionType });
×
543
        // clean states
UNCOV
544
        this.onDimDragEnd();
×
UNCOV
545
        this.onAreaDragLeave(event, area);
×
546
    }
547

548
    protected updateDropDown(value: IPivotValue, dropdown: IgxDropDownComponent, chip: IgxChipComponent) {
UNCOV
549
        this.value = value;
×
UNCOV
550
        dropdown.width = chip.nativeElement.clientWidth + 'px';
×
UNCOV
551
        this.aggregateList = PivotUtil.getAggregateList(value, this.grid);
×
UNCOV
552
        this.cdr.detectChanges();
×
UNCOV
553
        dropdown.open(this._subMenuOverlaySettings);
×
554
    }
555

556
    protected getRowDimensionColumn(dim: IPivotDimension): ColumnType {
UNCOV
557
        return this.grid.dimensionDataColumns ? this.grid.dimensionDataColumns.find((col) => col.field === dim.memberName) : null;
×
558
    }
559
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc