• 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

5.88
/src/date-picker/lib/calendar/calendar-table.component.ts
1
import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange, SimpleChanges, TemplateRef } from '@angular/core';
2
import { SafeAny } from 'ngx-tethys/types';
3
import { FunctionProp, isTemplateRef, TinyDate } from 'ngx-tethys/util';
4
import { DateCell, DateBodyRow } from '../date/types';
5

6
/**
7
 * @private
1✔
8
 */
9
@Directive()
×
10
export abstract class CalendarTable implements OnInit, OnChanges {
×
11
    isTemplateRef = isTemplateRef;
×
12
    headRow: DateCell[] = [];
×
13
    bodyRows: DateBodyRow[] = [];
×
14
    MAX_ROW = 6;
×
15
    MAX_COL = 7;
×
16

×
17
    @Input() prefixCls: string = 'thy-calendar';
×
18
    @Input() value: TinyDate;
×
19
    @Input() activeDate: TinyDate = new TinyDate();
×
20
    @Input() showWeek: boolean = false;
×
21
    @Input() selectedValue: TinyDate[] = []; // Range ONLY
22
    @Input() hoverValue: TinyDate[] = []; // Range ONLY
23
    @Input() disabledDate?: (d: Date) => boolean;
×
24
    @Input() cellRender?: FunctionProp<TemplateRef<Date> | string>;
×
25
    @Input() fullCellRender?: FunctionProp<TemplateRef<Date> | string>;
×
26
    @Output() readonly valueChange = new EventEmitter<TinyDate>();
27

28
    @Output() readonly cellHover = new EventEmitter<TinyDate>(); // Emitted when hover on a day by mouse enter
29

×
30
    constructor() {}
31

32
    protected render(): void {
×
33
        if (this.activeDate) {
34
            this.headRow = this.makeHeadRow();
35
            this.bodyRows = this.makeBodyRows();
×
36
        }
37
    }
38

×
39
    trackByBodyRow(_index: number, item: DateBodyRow): SafeAny {
40
        return item.trackByIndex;
41
    }
×
42

×
43
    trackByBodyColumn(_index: number, item: DateCell): SafeAny {
44
        return item.trackByIndex;
×
45
    }
46

47
    hasRangeValue(): boolean {
48
        return this.selectedValue?.length > 0 || this.hoverValue?.length > 0;
49
    }
50

51
    abstract makeHeadRow(): DateCell[];
×
52
    abstract makeBodyRows(): DateBodyRow[];
53

54
    ngOnInit(): void {
55
        this.render();
×
56
    }
×
57

×
58
    ngOnChanges(changes: SimpleChanges): void {
×
59
        if (changes.activeDate && !changes.activeDate.currentValue) {
×
60
            this.activeDate = new TinyDate();
61
        }
62

×
63
        if (
×
64
            changes.disabledDate ||
65
            changes.locale ||
66
            changes.showWeek ||
67
            this.isDateRealChange(changes.activeDate) ||
×
68
            this.isDateRealChange(changes.value) ||
69
            this.isDateRealChange(changes.selectedValue) ||
70
            this.isDateRealChange(changes.hoverValue)
×
71
        ) {
72
            this.render();
73
        }
×
74
    }
75

1✔
76
    private isDateRealChange(change: SimpleChange): boolean {
1✔
77
        if (change) {
78
            const previousValue: TinyDate | TinyDate[] = change.previousValue;
79
            const currentValue: TinyDate | TinyDate[] = change.currentValue;
80
            if (Array.isArray(currentValue)) {
81
                return (
82
                    !Array.isArray(previousValue) ||
83
                    currentValue.length !== previousValue.length ||
84
                    currentValue.some((value, index) => {
85
                        const previousCandyDate = previousValue[index];
86
                        return previousCandyDate instanceof TinyDate ? previousCandyDate.isSameDay(value) : previousCandyDate !== value;
87
                    })
88
                );
89
            } else {
90
                return !this.isSameDate(previousValue as TinyDate, currentValue);
1✔
91
            }
92
        }
93
        return false;
94
    }
95

96
    private isSameDate(left: TinyDate, right: TinyDate): boolean {
97
        return (!left && !right) || (left && right && right.isSameDay(left));
98
    }
99
}
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