• 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

20.0
/projects/igniteui-angular/src/lib/grids/moving/moving.drop.directive.ts
1
import { Directive, Input, OnDestroy, ElementRef, Renderer2, NgZone } from '@angular/core';
2
import { DropPosition, IgxColumnMovingService } from './moving.service';
3
import { Subject, interval, animationFrameScheduler } from 'rxjs';
4
import { IgxColumnMovingDragDirective } from './moving.drag.directive';
5
import { takeUntil } from 'rxjs/operators';
6
import { IgxDropDirective } from '../../directives/drag-drop/drag-drop.directive';
7
import { IgxForOfDirective, IgxGridForOfDirective } from '../../directives/for-of/for_of.directive';
8
import { ColumnType } from '../common/grid.interface';
9
// import { IgxGridHeaderGroupComponent } from '../headers/grid-header-group.component';
10

11

12
@Directive({
13
    selector: '[igxColumnMovingDrop]',
14
    standalone: true
15
})
16
export class IgxColumnMovingDropDirective extends IgxDropDirective implements OnDestroy {
2✔
17

18
    @Input('igxColumnMovingDrop')
19
    public override set data(val: ColumnType | IgxForOfDirective<ColumnType, ColumnType[]>) {
20
        if (val instanceof IgxGridForOfDirective) {
253!
UNCOV
21
            this._displayContainer = val;
×
22
        } else {
23
            this._column = val as ColumnType;
253✔
24
        }
25

26
    }
27

28
    public get column() {
UNCOV
29
        return this._column;
×
30
    }
31

32
    public get isDropTarget(): boolean {
UNCOV
33
        return this.column && this.column.grid.moving &&
×
34
            ((!this.column.pinned && this.cms.column?.disablePinning) || !this.cms.column?.disablePinning);
35
    }
36

37
    public get horizontalScroll() {
UNCOV
38
        if (this._displayContainer) {
×
UNCOV
39
            return this._displayContainer;
×
40
        }
41
    }
42

43
    public get nativeElement() {
UNCOV
44
        return this.ref.nativeElement;
×
45
    }
46

47
    private _dropPos: DropPosition;
48
    private _dropIndicator = null;
247✔
49
    private _lastDropIndicator = null;
247✔
50
    private _column: ColumnType;
51
    private _displayContainer: IgxGridForOfDirective<ColumnType, ColumnType[]>;
52
    private _dragLeave = new Subject<boolean>();
247✔
53
    private _dropIndicatorClass = 'igx-grid-th__drop-indicator--active';
247✔
54

55
    constructor(
56
        private ref: ElementRef<HTMLElement>,
247✔
57
        private renderer: Renderer2,
247✔
58
        private _: NgZone,
247✔
59
        private cms: IgxColumnMovingService
247✔
60
    ) {
61
        super(ref, renderer, _);
247✔
62
    }
63

64
    public override ngOnDestroy() {
65
        this._dragLeave.next(true);
247✔
66
        this._dragLeave.complete();
247✔
67
        super.ngOnDestroy();
247✔
68
    }
69

70
    public override onDragOver(event) {
UNCOV
71
        const drag = event.detail.owner;
×
UNCOV
72
        if (!(drag instanceof IgxColumnMovingDragDirective)) {
×
UNCOV
73
            return;
×
74
        }
75

UNCOV
76
        if (this.isDropTarget &&
×
77
            this.cms.column !== this.column &&
78
            this.cms.column.level === this.column.level &&
79
            this.cms.column.parent === this.column.parent) {
80

UNCOV
81
            if (this._lastDropIndicator) {
×
82
                this.renderer.removeClass(this._dropIndicator, this._dropIndicatorClass);
×
83
            }
84

UNCOV
85
            const clientRect = this.nativeElement.getBoundingClientRect();
×
UNCOV
86
            const pos = clientRect.left + clientRect.width / 2;
×
87

UNCOV
88
            const parent = this.nativeElement.parentElement;
×
UNCOV
89
            if (event.detail.pageX < pos) {
×
UNCOV
90
                this._dropPos = DropPosition.BeforeDropTarget;
×
UNCOV
91
                this._lastDropIndicator = this._dropIndicator = parent.firstElementChild;
×
92
            } else {
UNCOV
93
                this._dropPos = DropPosition.AfterDropTarget;
×
UNCOV
94
                this._lastDropIndicator = this._dropIndicator = parent.lastElementChild;
×
95
            }
96

UNCOV
97
            if (this.cms.icon.innerText !== 'block') {
×
UNCOV
98
                this.renderer.addClass(this._dropIndicator, this._dropIndicatorClass);
×
99
            }
100
        }
101
    }
102

103
    public override onDragEnter(event) {
UNCOV
104
        const drag = event.detail.owner;
×
UNCOV
105
        if (!(drag instanceof IgxColumnMovingDragDirective)) {
×
UNCOV
106
            return;
×
107
        }
108

UNCOV
109
        if (this.column && this.cms.column.grid.id !== this.column.grid.id) {
×
110
            this.cms.icon.innerText = 'block';
×
111
            return;
×
112
        }
113

UNCOV
114
        if (this.isDropTarget &&
×
115
            this.cms.column !== this.column &&
116
            this.cms.column.level === this.column.level &&
117
            this.cms.column.parent === this.column.parent) {
118

UNCOV
119
            if (!this.column.pinned || (this.column.pinned && this.cms.column.pinned)) {
×
UNCOV
120
                this.cms.icon.innerText = 'swap_horiz';
×
121
            }
122

UNCOV
123
            this.cms.icon.innerText = 'save_alt';
×
124
        } else {
UNCOV
125
            this.cms.icon.innerText = 'block';
×
126
        }
127

UNCOV
128
        if (this.horizontalScroll) {
×
UNCOV
129
            this.cms.icon.innerText = event.target.id === 'right' ? 'arrow_forward' : 'arrow_back';
×
130

UNCOV
131
            interval(0, animationFrameScheduler).pipe(takeUntil(this._dragLeave)).subscribe(() => {
×
UNCOV
132
                if (event.target.id === 'right') {
×
133
                    this.horizontalScroll.scrollPosition += 10;
×
134
                } else {
UNCOV
135
                    this.horizontalScroll.scrollPosition -= 10;
×
136
                }
137
            });
138
        }
139
    }
140

141
    public override onDragLeave(event) {
UNCOV
142
        const drag = event.detail.owner;
×
UNCOV
143
        if (!(drag instanceof IgxColumnMovingDragDirective)) {
×
UNCOV
144
            return;
×
145
        }
146

UNCOV
147
        this.cms.icon.innerText = 'block';
×
148

UNCOV
149
        if (this._dropIndicator) {
×
UNCOV
150
            this.renderer.removeClass(this._dropIndicator, this._dropIndicatorClass);
×
151
        }
152

UNCOV
153
        if (this.horizontalScroll) {
×
UNCOV
154
            this._dragLeave.next(true);
×
155
        }
156
    }
157

158
    public override onDragDrop(event) {
UNCOV
159
        event.preventDefault();
×
UNCOV
160
        const drag = event.detail.owner;
×
UNCOV
161
        if (this.cms.cancelDrop || !(drag instanceof IgxColumnMovingDragDirective)) {
×
UNCOV
162
            this.cms.cancelDrop = false;
×
UNCOV
163
            return;
×
164
        }
165

UNCOV
166
        if (this.column && (this.cms.column.grid.id !== this.column.grid.id)) {
×
167
            return;
×
168
        }
169

UNCOV
170
        if (this.horizontalScroll) {
×
171
            this._dragLeave.next(true);
×
172
        }
173

UNCOV
174
        if (this.isDropTarget) {
×
UNCOV
175
            this.column.grid.moveColumn(this.cms.column, this.column, this._dropPos);
×
176

UNCOV
177
            this.cms.column = null;
×
UNCOV
178
            this.column.grid.cdr.detectChanges();
×
179
        }
180
    }
181
}
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