• 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

17.19
/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, takeUntil } from 'rxjs';
4
import { PlatformUtil } from '../../core/utils';
5
import { IgxColumnMovingService } from './moving.service';
6
import { ColumnType } from '../common/grid.interface';
7

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

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

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

25
    public get icon(): HTMLElement {
UNCOV
26
        return this.cms.icon;
×
27
    }
28

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

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

48
    public override ngOnDestroy() {
49
        this._unsubscribe();
247✔
50
        super.ngOnDestroy();
247✔
51
    }
52

53
    public onEscape(event: Event) {
UNCOV
54
        this.cms.cancelDrop = true;
×
UNCOV
55
        this.onPointerUp(event);
×
56
    }
57

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

UNCOV
63
        super.onPointerDown(event);
×
64
    }
65

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

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

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

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

UNCOV
96
            if (args.cancel) {
×
UNCOV
97
                this.onEscape(event);
×
98
            }
99
        }
100
    }
101

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

UNCOV
110
        this._unsubscribe();
×
111
    }
112

113
    protected override createGhost(pageX: number, pageY: number) {
UNCOV
114
        super.createGhost(pageX, pageY);
×
115

UNCOV
116
        this.ghostElement.style.height = null;
×
UNCOV
117
        this.ghostElement.style.minWidth = null;
×
UNCOV
118
        this.ghostElement.style.flexBasis = null;
×
UNCOV
119
        this.ghostElement.style.position = null;
×
120

UNCOV
121
        this.ghostElement.classList.remove(this.columnSelectedClass);
×
122

UNCOV
123
        const icon = this.column?.grid.document.createElement('i');
×
UNCOV
124
        const text = this.column?.grid.document.createTextNode('block');
×
UNCOV
125
        icon.appendChild(text);
×
126

UNCOV
127
        icon.classList.add('material-icons');
×
UNCOV
128
        this.cms.icon = icon;
×
129

UNCOV
130
        if (!this.column.columnGroup) {
×
UNCOV
131
            icon.classList.add(this.ghostImgIconClass);
×
132

UNCOV
133
            this.ghostElement.insertBefore(icon, this.ghostElement.firstElementChild);
×
134

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

UNCOV
140
            icon.classList.add(this.ghostImgIconGroupClass);
×
UNCOV
141
            this.ghostElement.children[0].style.paddingLeft = '0px';
×
142

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

148
    private _unsubscribe() {
149
        if (this.subscription$) {
247!
UNCOV
150
            this.subscription$.unsubscribe();
×
UNCOV
151
            this.subscription$ = null;
×
152
        }
153
    }
154
}
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