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

IgniteUI / igniteui-angular / 13548823408

26 Feb 2025 04:36PM CUT coverage: 91.555% (-0.04%) from 91.599%
13548823408

Pull #15223

github

web-flow
Merge 3ac8087aa into 786685675
Pull Request #15223: fix(pivot-grid): added createRow method for grid based events - 19.0

12997 of 15250 branches covered (85.23%)

0 of 18 new or added lines in 2 files covered. (0.0%)

135 existing lines in 23 files now uncovered.

26344 of 28774 relevant lines covered (91.55%)

34046.37 hits per line

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

93.75
/projects/igniteui-angular/src/lib/grids/moving/moving.drag.directive.ts
1
import { Directive, OnDestroy, Input, ElementRef, ViewContainerRef, NgZone, ChangeDetectorRef, Renderer2 } from '@angular/core';
2
import { IgxDragDirective } from '../../directives/drag-drop/drag-drop.directive';
3
import { Subscription, fromEvent } from 'rxjs';
4
import { takeUntil } from 'rxjs/operators';
5
import { PlatformUtil } from '../../core/utils';
6
import { IgxColumnMovingService } from './moving.service';
7
import { ColumnType } from '../common/grid.interface';
8

9
/**
10
 * @hidden
11
 * @internal
12
 */
13
@Directive({
14
    selector: '[igxColumnMovingDrag]',
15
    standalone: true
16
})
17
export class IgxColumnMovingDragDirective extends IgxDragDirective implements OnDestroy {
2✔
18

19
    @Input('igxColumnMovingDrag')
20
    public column: ColumnType;
21

22
    public get draggable(): boolean {
23
        return this.column && (this.column.grid.moving || (this.column.groupable && !this.column.columnGroup));
110✔
24
    }
25

26
    public get icon(): HTMLElement {
27
        return this.cms.icon;
10✔
28
    }
29

30
    private subscription$: Subscription;
31
    private _ghostClass = 'igx-grid__drag-ghost-image';
28,315✔
32
    private ghostImgIconClass = 'igx-grid__drag-ghost-image-icon';
28,315✔
33
    private ghostImgIconGroupClass = 'igx-grid__drag-ghost-image-icon-group';
28,315✔
34
    private columnSelectedClass = 'igx-grid-th--selected';
28,315✔
35

36
    constructor(
37
        element: ElementRef<HTMLElement>,
38
        viewContainer: ViewContainerRef,
39
        zone: NgZone,
40
        renderer: Renderer2,
41
        cdr: ChangeDetectorRef,
42
        private cms: IgxColumnMovingService,
28,315✔
43
        _platformUtil: PlatformUtil,
44
    ) {
45
        super(cdr, element, viewContainer, zone, renderer, _platformUtil);
28,315✔
46
        this.ghostClass = this._ghostClass;
28,315✔
47
    }
48

49
    public override ngOnDestroy() {
50
        this._unsubscribe();
28,202✔
51
        super.ngOnDestroy();
28,202✔
52
    }
53

54
    public onEscape(event: Event) {
55
        this.cms.cancelDrop = true;
1✔
56
        this.onPointerUp(event);
1✔
57
    }
58

59
    public override onPointerDown(event: Event) {
60
        if (!this.draggable || (event.target as HTMLElement).getAttribute('draggable') === 'false') {
110✔
61
            return;
50✔
62
        }
63

64
        super.onPointerDown(event);
60✔
65
    }
66

67
    public override onPointerMove(event: Event) {
68
        if (this._clicked && !this._dragStarted) {
119✔
69
            this._removeOnDestroy = false;
57✔
70
            this.cms.column = this.column;
57✔
71
            this.column.grid.cdr.detectChanges();
57✔
72

73
            const movingStartArgs = {
57✔
74
                source: this.column
75
            };
76
            this.column.grid.columnMovingStart.emit(movingStartArgs);
57✔
77
            this.subscription$ = fromEvent(this.column.grid.document.defaultView, 'keydown').pipe(takeUntil(this._destroy)).subscribe((ev: KeyboardEvent) => {
57✔
78
                if (ev.key === this.platformUtil.KEYMAP.ESCAPE) {
×
UNCOV
79
                    this.onEscape(ev);
×
80
                }
81
            });
82
        }
83

84
        super.onPointerMove(event);
119✔
85
        if (this._dragStarted && this.ghostElement && !this.cms.column) {
119!
86
            this.cms.column = this.column;
×
UNCOV
87
            this.column.grid.cdr.detectChanges();
×
88
        }
89

90
        if (this.cms.column) {
119✔
91
            const args = {
119✔
92
                source: this.column,
93
                cancel: false
94
            };
95
            this.column.grid.columnMoving.emit(args);
119✔
96

97
            if (args.cancel) {
119✔
98
                this.onEscape(event);
1✔
99
            }
100
        }
101
    }
102

103
    public override onPointerUp(event: Event) {
104
        // Run it explicitly inside the zone because sometimes onPointerUp executes after the code below.
105
        this.zone.run(() => {
219✔
106
            super.onPointerUp(event);
219✔
107
            this.cms.column = null;
219✔
108
            this.column.grid.cdr.detectChanges();
219✔
109
        });
110

111
        this._unsubscribe();
219✔
112
    }
113

114
    protected override createGhost(pageX: number, pageY: number) {
115
        super.createGhost(pageX, pageY);
57✔
116

117
        this.ghostElement.style.height = null;
57✔
118
        this.ghostElement.style.minWidth = null;
57✔
119
        this.ghostElement.style.flexBasis = null;
57✔
120
        this.ghostElement.style.position = null;
57✔
121

122
        this.ghostElement.classList.remove(this.columnSelectedClass);
57✔
123

124
        const icon = this.column?.grid.document.createElement('i');
57✔
125
        const text = this.column?.grid.document.createTextNode('block');
57✔
126
        icon.appendChild(text);
57✔
127

128
        icon.classList.add('material-icons');
57✔
129
        this.cms.icon = icon;
57✔
130

131
        if (!this.column.columnGroup) {
57✔
132
            icon.classList.add(this.ghostImgIconClass);
47✔
133

134
            this.ghostElement.insertBefore(icon, this.ghostElement.firstElementChild);
47✔
135

136
            this.ghostLeft = this._ghostStartX = pageX - ((this.ghostElement.getBoundingClientRect().width / 3) * 2);
47✔
137
            this.ghostTop = this._ghostStartY = pageY - ((this.ghostElement.getBoundingClientRect().height / 3) * 2);
47✔
138
        } else {
139
            this.ghostElement.insertBefore(icon, this.ghostElement.childNodes[0]);
10✔
140

141
            icon.classList.add(this.ghostImgIconGroupClass);
10✔
142
            this.ghostElement.children[0].style.paddingLeft = '0px';
10✔
143

144
            this.ghostLeft = this._ghostStartX = pageX - ((this.ghostElement.getBoundingClientRect().width / 3) * 2);
10✔
145
            this.ghostTop = this._ghostStartY = pageY - ((this.ghostElement.getBoundingClientRect().height / 3) * 2);
10✔
146
        }
147
    }
148

149
    private _unsubscribe() {
150
        if (this.subscription$) {
28,421✔
151
            this.subscription$.unsubscribe();
57✔
152
            this.subscription$ = null;
57✔
153
        }
154
    }
155
}
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