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

atinc / ngx-tethys / 129e0fd3-b436-4e51-a99e-27a86ab79bed

14 Dec 2023 05:55AM UTC coverage: 90.399% (-0.009%) from 90.408%
129e0fd3-b436-4e51-a99e-27a86ab79bed

Pull #2969

circleci

luxiaobei
feat(property): property-item add thyEditingChange #INFR-10910
Pull Request #2969: feat(property): property-item add thyEditingChange #INFR-10910

5353 of 6582 branches covered (0.0%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 2 files covered. (100.0%)

20 existing lines in 5 files now uncovered.

13336 of 14092 relevant lines covered (94.64%)

972.82 hits per line

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

88.54
/src/date-picker/lib/popups/inner-popup.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    Component,
4
    EventEmitter,
5
    HostBinding,
6
    Input,
7
    OnChanges,
8
    Output,
9
    SimpleChanges,
10
    TemplateRef
11
} from '@angular/core';
12

13
import { coerceBooleanProperty, FunctionProp, TinyDate } from 'ngx-tethys/util';
14
import { DateHelperService } from '../../date-helper.service';
15
import { RangePartType } from '../../inner-types';
16
import { isAfterMoreThanLessOneYear, isAfterMoreThanOneDecade, isAfterMoreThanOneMonth, isAfterMoreThanOneYear } from '../../picker.util';
17
import { DisabledDateFn, ThyPanelMode } from '../../standard-types';
18
import { DateHeaderComponent } from '../date/date-header.component';
19
import { DateTableComponent } from '../date/date-table.component';
20

1✔
21
import { NgIf, NgSwitch, NgSwitchCase, NgSwitchDefault } from '@angular/common';
22
import { ThyInputDirective } from 'ngx-tethys/input';
193✔
23
import { DecadeHeaderComponent } from '../decade/decade-header.component';
24
import { DecadeTableComponent } from '../decade/decade-table.component';
25
import { MonthHeaderComponent } from '../month/month-header.component';
402✔
26
import { MonthTableComponent } from '../month/month-table.component';
27
import { YearHeaderComponent } from '../year/year-header.component';
28
import { YearTableComponent } from '../year/year-table.component';
191✔
29

191✔
30
/**
191✔
31
 * @private
191✔
32
 */
191✔
33
@Component({
191✔
34
    changeDetection: ChangeDetectionStrategy.OnPush,
191✔
35
    // eslint-disable-next-line @angular-eslint/component-selector
191✔
36
    selector: 'inner-popup',
37
    exportAs: 'innerPopup',
38
    templateUrl: 'inner-popup.component.html',
402✔
39
    standalone: true,
59✔
40
    imports: [
41
        NgIf,
402!
UNCOV
42
        ThyInputDirective,
×
43
        NgSwitch,
44
        NgSwitchCase,
45
        DecadeHeaderComponent,
46
        DecadeTableComponent,
8✔
47
        YearHeaderComponent,
48
        YearTableComponent,
49
        MonthHeaderComponent,
28!
50
        MonthTableComponent,
28✔
51
        NgSwitchDefault,
52
        DateHeaderComponent,
53
        DateTableComponent
3✔
54
    ]
3✔
55
})
2✔
56
export class InnerPopupComponent implements OnChanges {
2✔
57
    @HostBinding('class.thy-calendar-picker-inner-popup') className = true;
58
    @HostBinding('class.thy-calendar-picker-inner-popup-with-range-input') _showDateRangeInput = false;
59

1✔
60
    @Input() showWeek: boolean;
1✔
61
    @Input() isRange: boolean;
62
    @Input() activeDate: TinyDate;
63
    @Input() rangeActiveDate: TinyDate[]; // Range ONLY
64
    @Input() enablePrev: boolean;
3✔
65
    @Input() enableNext: boolean;
3✔
66
    @Input() disabledDate: DisabledDateFn;
2✔
67
    @Input() dateRender: FunctionProp<TemplateRef<Date> | string>;
2✔
68
    @Input() selectedValue: TinyDate[]; // Range ONLY
69
    @Input() hoverValue: TinyDate[]; // Range ONLY
70

1✔
71
    @Input() panelMode: ThyPanelMode;
1✔
72

73
    @Input() set showDateRangeInput(value: boolean) {
74
        this._showDateRangeInput = coerceBooleanProperty(value);
UNCOV
75
    }
×
UNCOV
76

×
UNCOV
77
    get showDateRangeInput() {
×
UNCOV
78
        return this._showDateRangeInput;
×
79
    }
80

UNCOV
81
    @Input() partType: RangePartType;
×
UNCOV
82

×
83
    @Input() endPanelMode: ThyPanelMode;
84

85
    @Output() readonly panelModeChange = new EventEmitter<ThyPanelMode>();
86

666✔
87
    @Input() value: TinyDate;
432✔
88

188✔
89
    @Output() readonly headerChange = new EventEmitter<TinyDate>();
188✔
90
    @Output() readonly selectDate = new EventEmitter<TinyDate>();
91
    @Output() readonly dayHover = new EventEmitter<TinyDate>();
92

244✔
93
    prefixCls = 'thy-calendar';
94

95
    constructor(private dateHelper: DateHelperService) {}
96

234✔
97
    ngOnChanges(changes: SimpleChanges): void {
98
        if (changes.activeDate && !changes.activeDate.currentValue) {
99
            this.activeDate = new TinyDate();
100
        }
804✔
101
        if (changes.panelMode && changes.panelMode.currentValue === 'time') {
490✔
102
            this.panelMode = 'date';
217✔
103
        }
217✔
104
    }
188✔
105

106
    getReadableValue(value: TinyDate) {
29✔
107
        return value ? this.dateHelper.format(value.nativeDate, 'yyyy-MM-dd') : '';
20✔
108
    }
109

9✔
110
    onSelectDate(date: TinyDate | Date): void {
5✔
111
        const value = date instanceof TinyDate ? date : new TinyDate(date);
112

113
        this.selectDate.emit(value);
114
    }
273✔
115

116
    onChooseMonth(value: TinyDate): void {
117
        this.activeDate = this.activeDate.setMonth(value.getMonth());
118
        if (this.endPanelMode === 'month') {
314✔
119
            this.value = value;
120
            this.selectDate.emit(value);
121
        } else {
1✔
122
            this.headerChange.emit(value);
123
            this.panelModeChange.emit(this.endPanelMode);
124
        }
1✔
125
    }
126
    onChooseYear(value: TinyDate): void {
127
        this.activeDate = this.activeDate.setYear(value.getYear());
128
        if (this.endPanelMode === 'year') {
129
            this.value = value;
130
            this.selectDate.emit(value);
131
        } else {
132
            this.headerChange.emit(value);
133
            this.panelModeChange.emit(this.endPanelMode);
134
        }
135
    }
136

137
    onChooseDecade(value: TinyDate): void {
138
        this.activeDate = this.activeDate.setYear(value.getYear());
139
        if (this.endPanelMode === 'decade') {
140
            this.value = value;
141
            this.selectDate.emit(value);
142
        } else {
143
            this.headerChange.emit(value);
144
            this.panelModeChange.emit('year');
145
        }
146
    }
147

148
    enablePrevNext(direction: 'prev' | 'next', mode: ThyPanelMode): boolean {
1✔
149
        if (this.isRange) {
150
            if ((this.partType === 'left' && direction === 'next') || (this.partType === 'right' && direction === 'prev')) {
151
                const [headerLeftDate, headerRightDate] = this.rangeActiveDate;
152
                return isAfterMoreThanOneMonth(headerRightDate, headerLeftDate);
153
            } else {
154
                return true;
155
            }
156
        } else {
157
            return true;
158
        }
159
    }
160

161
    enableSuperPrevNext(direction: 'prev' | 'next', panelMode: ThyPanelMode) {
162
        if (this.isRange) {
163
            if ((this.partType === 'left' && direction === 'next') || (this.partType === 'right' && direction === 'prev')) {
164
                const [headerLeftDate, headerRightDate] = this.rangeActiveDate;
165
                if (panelMode === 'date') {
166
                    return isAfterMoreThanLessOneYear(headerRightDate, headerLeftDate);
167
                } else if (panelMode === 'month') {
168
                    return isAfterMoreThanOneYear(headerRightDate, headerLeftDate);
169
                } else if (panelMode === 'year') {
170
                    return isAfterMoreThanOneDecade(headerRightDate, headerLeftDate);
171
                }
172
            } else {
173
                return true;
174
            }
175
        } else {
176
            return true;
177
        }
178
    }
179
}
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