• 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

12.82
/src/time-picker/inner/inner-time-picker.store.ts
1
import { MiniStore, MiniAction } from 'ngx-tethys/core';
2
import { TimeChangeEvent, TimePickerComponentState, Time, TimePickerControls } from './inner-time-picker.class';
3
import { canChangeHours, canChangeMinutes, canChangeSeconds, canChangeValue, timePickerControls } from '../time-picker-controls.util';
4
import { changeTime, setTime, isValidLimit } from '../time-picker.utils';
5
import { Injectable } from '@angular/core';
6
import { TimePickerConfig } from './inner-time-picker.config';
7

1✔
8
export interface TimePickerState {
9
    value: Date;
10
    config: TimePickerComponentState;
11
    controls: TimePickerControls;
12
}
13

14
export const initialState: TimePickerState = {
15
    value: null,
16
    config: new TimePickerConfig(),
17
    controls: {
18
        canIncrementHours: true,
19
        canIncrementMinutes: true,
20
        canIncrementSeconds: true,
21

22
        canDecrementHours: true,
23
        canDecrementMinutes: true,
1✔
24
        canDecrementSeconds: true,
25

×
26
        canToggleMeridian: true
27
    }
28
};
×
29

30
/**
31
 * @internal
×
32
 */
×
33
@Injectable()
×
34
export class ThyTimePickerStore extends MiniStore<TimePickerState> {
35
    constructor() {
×
36
        super(initialState);
×
37
    }
×
38

39
    @MiniAction()
×
40
    writeValue(value: Date) {
41
        this.setState({ value: value });
42
    }
×
43

×
44
    @MiniAction()
×
45
    changeHours(event: TimeChangeEvent) {
46
        const state = this.snapshot;
×
47
        if (!canChangeValue(state.config, event) || !canChangeHours(event, state.controls)) {
×
48
            return state;
×
49
        }
50

×
51
        const _newTime = changeTime(state.value, { hour: event.step });
52

53
        if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
×
54
            return state;
×
55
        }
×
56

57
        this.setState({ value: _newTime });
×
58
    }
59

60
    @MiniAction()
×
61
    changeMinutes(event: TimeChangeEvent) {
×
62
        const state = this.snapshot;
63
        if (!canChangeValue(state.config, event) || !canChangeMinutes(event, state.controls)) {
×
64
            return state;
65
        }
66

×
67
        const _newTime = changeTime(state.value, { minute: event.step });
×
68

×
69
        if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
70
            return state;
×
71
        }
×
72

73
        this.setState({ value: _newTime });
74
    }
×
75

×
76
    @MiniAction()
×
77
    changeSeconds(event: TimeChangeEvent) {
78
        const state = this.snapshot;
79
        if (!canChangeValue(state.config, event) || !canChangeSeconds(event, state.controls)) {
80
            return state;
81
        }
×
82

×
83
        const _newTime = changeTime(state.value, {
×
84
            seconds: event.step
85
        });
86

×
87
        if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
88
            return state;
1✔
89
        }
90

1✔
91
        this.setState({ value: _newTime });
92
    }
93

94
    @MiniAction()
95
    setTime(value: Time) {
96
        const state = this.snapshot;
1✔
97
        if (!canChangeValue(state.config)) {
98
            return state;
99
        }
100

101
        const _newTime = setTime(state.value, value);
102
        this.setState({ value: _newTime });
1✔
103
    }
104

105
    @MiniAction()
106
    updateControls(value: TimePickerComponentState) {
107
        const state = this.snapshot;
108
        const _newControlsState = timePickerControls(state.value, value);
1✔
109
        const _newState: TimePickerState = {
110
            value: state.value,
111
            config: value,
112
            controls: _newControlsState
113
        };
114

1✔
115
        if (state.config.showMeridian !== _newState.config.showMeridian) {
116
            if (state.value) {
117
                _newState.value = new Date(state.value);
118
            }
119
        }
120

1✔
121
        this.setState(_newState);
122
    }
123
}
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