• 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

1.59
/projects/igniteui-angular/src/lib/stepper/stepper.service.ts
1
import { Injectable } from '@angular/core';
2
import { IgxStepper, IgxStepperOrientation, IStepChangingEventArgs } from './stepper.common';
3
import { IgxStepComponent } from './step/step.component';
4

5
/** @hidden @internal */
6
@Injectable()
7
export class IgxStepperService {
2✔
8
    public activeStep: IgxStepComponent;
9
    public previousActiveStep: IgxStepComponent;
10
    public focusedStep: IgxStepComponent;
11

UNCOV
12
    public collapsingSteps: Set<IgxStepComponent> = new Set<IgxStepComponent>();
×
UNCOV
13
    public linearDisabledSteps: Set<IgxStepComponent> = new Set<IgxStepComponent>();
×
UNCOV
14
    public visitedSteps: Set<IgxStepComponent> = new Set<IgxStepComponent>();
×
15
    public stepper: IgxStepper;
16

17
    /**
18
     * Activates the step, fires the steps change event and plays animations.
19
     */
20
    public expand(step: IgxStepComponent): void {
UNCOV
21
        if (this.activeStep === step) {
×
UNCOV
22
            return;
×
23
        }
24

UNCOV
25
        const cancel = this.emitActivatingEvent(step);
×
UNCOV
26
        if (cancel) {
×
UNCOV
27
            return;
×
28
        }
29

UNCOV
30
        this.collapsingSteps.delete(step);
×
31

UNCOV
32
        this.previousActiveStep = this.activeStep;
×
UNCOV
33
        this.activeStep = step;
×
UNCOV
34
        this.activeStep.activeChange.emit(true);
×
35

UNCOV
36
        this.collapsingSteps.add(this.previousActiveStep);
×
UNCOV
37
        this.visitedSteps.add(this.activeStep);
×
38

UNCOV
39
        if (this.stepper.orientation === IgxStepperOrientation.Vertical) {
×
UNCOV
40
            this.previousActiveStep.playCloseAnimation(
×
41
                this.previousActiveStep.contentContainer
42
            );
UNCOV
43
            this.activeStep.cdr.detectChanges();
×
44

UNCOV
45
            this.activeStep.playOpenAnimation(
×
46
                this.activeStep.contentContainer
47
            );
48
        } else {
UNCOV
49
            this.activeStep.cdr.detectChanges();
×
UNCOV
50
            this.stepper.playHorizontalAnimations();
×
51
        }
52
    }
53

54
    /**
55
     * Activates the step and fires the steps change event without playing animations.
56
     */
57
    public expandThroughApi(step: IgxStepComponent): void {
UNCOV
58
        if (this.activeStep === step) {
×
UNCOV
59
            return;
×
60
        }
61

UNCOV
62
        this.collapsingSteps.clear();
×
63

UNCOV
64
        this.previousActiveStep = this.activeStep;
×
UNCOV
65
        this.activeStep = step;
×
66

UNCOV
67
        if (this.previousActiveStep) {
×
UNCOV
68
            this.previousActiveStep.tabIndex = -1;
×
69
        }
UNCOV
70
        this.activeStep.tabIndex = 0;
×
UNCOV
71
        this.visitedSteps.add(this.activeStep);
×
72

UNCOV
73
        this.activeStep.cdr.markForCheck();
×
UNCOV
74
        this.previousActiveStep?.cdr.markForCheck();
×
75

UNCOV
76
        this.activeStep.activeChange.emit(true);
×
UNCOV
77
        this.previousActiveStep?.activeChange.emit(false);
×
78
    }
79

80
    /**
81
     * Collapses the currently active step and fires the change event.
82
     */
83
    public collapse(step: IgxStepComponent): void {
UNCOV
84
        if (this.activeStep === step) {
×
85
            return;
×
86
        }
UNCOV
87
        step.activeChange.emit(false);
×
UNCOV
88
        this.collapsingSteps.delete(step);
×
89
    }
90

91
    /**
92
     * Determines the steps that should be marked as visited based on the active step.
93
     */
94
    public calculateVisitedSteps(): void {
UNCOV
95
        this.stepper.steps.forEach(step => {
×
UNCOV
96
            if (step.index <= this.activeStep.index) {
×
UNCOV
97
                this.visitedSteps.add(step);
×
98
            } else {
UNCOV
99
                this.visitedSteps.delete(step);
×
100
            }
101
        });
102
    }
103

104
    /**
105
     * Determines the steps that should be disabled in linear mode based on the validity of the active step.
106
     */
107
    public calculateLinearDisabledSteps(): void {
UNCOV
108
        if (!this.activeStep) {
×
109
            return;
×
110
        }
111

UNCOV
112
        if (this.activeStep.isValid) {
×
UNCOV
113
            const firstRequiredIndex = this.getNextRequiredStep();
×
UNCOV
114
            if (firstRequiredIndex !== -1) {
×
UNCOV
115
                this.updateLinearDisabledSteps(firstRequiredIndex);
×
116
            } else {
UNCOV
117
                this.linearDisabledSteps.clear();
×
118
            }
119
        } else {
UNCOV
120
            this.stepper.steps.forEach(s => {
×
UNCOV
121
                if (s.index > this.activeStep.index) {
×
UNCOV
122
                    this.linearDisabledSteps.add(s);
×
123
                }
124
            });
125
        }
126
    }
127

128
    public emitActivatingEvent(step: IgxStepComponent): boolean {
UNCOV
129
        const args: IStepChangingEventArgs = {
×
130
            owner: this.stepper,
131
            newIndex: step.index,
132
            oldIndex: this.activeStep.index,
133
            cancel: false
134
        };
135

UNCOV
136
        this.stepper.activeStepChanging.emit(args);
×
UNCOV
137
        return args.cancel;
×
138
    }
139

140
    /**
141
     * Updates the linearDisabled steps from the current active step to the next required invalid step.
142
     *
143
     * @param toIndex the index of the last step that should be enabled.
144
     */
145
    private updateLinearDisabledSteps(toIndex: number): void {
UNCOV
146
        this.stepper.steps.forEach(s => {
×
UNCOV
147
            if (s.index > this.activeStep.index) {
×
UNCOV
148
                if (s.index <= toIndex) {
×
UNCOV
149
                    this.linearDisabledSteps.delete(s);
×
150
                } else {
UNCOV
151
                    this.linearDisabledSteps.add(s);
×
152
                }
153
            }
154
        });
155
    }
156

157
    private getNextRequiredStep(): number {
UNCOV
158
        if (!this.activeStep) {
×
159
            return;
×
160
        }
UNCOV
161
        return this.stepper.steps.findIndex(s => s.index > this.activeStep.index && !s.optional && !s.disabled && !s.isValid);
×
162
    }
163
}
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