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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

6.67
/src/guider/guider.service.ts
1
import { Router } from '@angular/router';
2
import { helpers } from 'ngx-tethys/util';
3
import { DOCUMENT } from '@angular/common';
4
import { ThyGuiderRef } from './guider-ref';
5
import { Inject, NgZone } from '@angular/core';
6
import { ThyPopover } from 'ngx-tethys/popover';
7
import { ThyGuiderManager } from './guider-manager';
8
import { Injectable, RendererFactory2 } from '@angular/core';
9
import { ThyGuiderStep, ThyGuiderConfig, defaultGuiderPositionConfig } from './guider.class';
10
import { Overlay } from '@angular/cdk/overlay';
11

12
/**
13
 * 新手引导服务
14
 * @public
15
 * @order 10
16
 */
17
@Injectable({
1✔
18
    providedIn: 'root'
19
})
×
20
export class ThyGuider {
×
21
    private guiderRef: ThyGuiderRef;
×
22

×
23
    private guiderRefs: ThyGuiderRef[] = [];
×
24

×
25
    constructor(
×
26
        private readonly rendererFactory: RendererFactory2,
×
27
        private popover: ThyPopover,
28
        private router: Router,
29
        private guiderManager: ThyGuiderManager,
×
30
        private ngZone: NgZone,
×
31
        private overlay: Overlay,
×
32
        @Inject(DOCUMENT) private document: any
33
    ) {}
34

×
35
    public create(config: ThyGuiderConfig): ThyGuiderRef {
×
36
        if (typeof ngDevMode === 'undefined' || ngDevMode) {
×
37
            if (!config || !config?.steps || !helpers.isArray(config?.steps)) {
×
38
                throw new Error(`'config.steps' must be an array of length greater than 0`);
×
39
            }
40
        }
×
41
        const normalizeConfig = this.normalizeConfig(config);
×
42
        this.guiderRef = new ThyGuiderRef(
43
            normalizeConfig,
44
            this.rendererFactory,
×
45
            this.popover,
×
46
            this.router,
×
47
            this.guiderManager,
48
            this.ngZone,
×
49
            this.overlay,
50
            this.document
51
        );
×
52
        this.guiderRef.closed().subscribe(() => {
53
            const index = this.guiderRefs.findIndex(guiderRef => guiderRef === this.guiderRef);
54
            this.guiderRefs.splice(index, 1);
55
        });
56
        this.guiderRefs.push(this.guiderRef);
×
57
        return this.guiderRef;
58
    }
59

×
60
    private normalizeConfig(config: ThyGuiderConfig): ThyGuiderConfig {
×
61
        const normalizeConfig = Object.assign({}, defaultGuiderPositionConfig, config);
×
62
        normalizeConfig.steps = normalizeConfig.steps.map(step => {
×
63
            return this.normalizeStep(step, normalizeConfig);
×
64
        });
65
        return normalizeConfig;
66
    }
67

1✔
68
    private normalizeStep(step: ThyGuiderStep, config: ThyGuiderConfig): ThyGuiderStep {
69
        const tempStep = Object.assign(
70
            {
71
                hintPlacement: config.hintPlacement,
72
                hintOffset: config.hintOffset,
73
                pointOffset: config.pointOffset
74
            },
75
            step
76
        );
77

1✔
78
        return tempStep;
79
    }
80

81
    close() {
82
        if (this.guiderRefs.length > 0) {
83
            const lasGuiderRef = this.guiderRefs[this.guiderRefs.length - 1];
84
            if (lasGuiderRef) {
85
                lasGuiderRef.close();
86
                this.guiderRefs.pop();
87
            }
88
        }
89
    }
90
}
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