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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

4.69
/src/date-picker/lib/month/month-table.component.ts
1
import { ChangeDetectionStrategy, Component, OnChanges, inject } from '@angular/core';
2
import { TinyDate } from 'ngx-tethys/util';
3
import { DateHelperService } from '../../date-helper.service';
4
import { CalendarTable } from '../calendar/calendar-table.component';
5
import { DateCell, DateBodyRow } from '../date/types';
6
import { NgClass } from '@angular/common';
7

8
/**
9
 * @private
10
 */
11
@Component({
1✔
12
    changeDetection: ChangeDetectionStrategy.OnPush,
UNCOV
13
    // eslint-disable-next-line @angular-eslint/component-selector
×
UNCOV
14
    selector: 'month-table',
×
UNCOV
15
    exportAs: 'monthTable',
×
UNCOV
16
    templateUrl: 'month-table.component.html',
×
17
    imports: [NgClass]
18
})
UNCOV
19
export class MonthTable extends CalendarTable implements OnChanges {
×
UNCOV
20
    private dateHelper = inject(DateHelperService);
×
UNCOV
21

×
22
    MAX_ROW = 4;
23

UNCOV
24
    MAX_COL = 3;
×
25

26
    constructor() {
UNCOV
27
        super();
×
UNCOV
28
    }
×
UNCOV
29

×
UNCOV
30
    private chooseMonth(month: number): void {
×
31
        this.value = this.activeDate.setMonth(month);
32
        this.valueChange.emit(this.value);
33
        this.render();
UNCOV
34
    }
×
UNCOV
35

×
UNCOV
36
    makeHeadRow(): DateCell[] {
×
UNCOV
37
        return [];
×
UNCOV
38
    }
×
UNCOV
39

×
40
    makeBodyRows(): DateBodyRow[] {
41
        const months: DateBodyRow[] = [];
42
        let monthValue = 0;
43
        for (let rowIndex = 0; rowIndex < this.MAX_ROW; rowIndex++) {
44
            const row: DateBodyRow = {
45
                dateCells: [],
46
                trackByIndex: rowIndex
UNCOV
47
            };
×
48
            for (let colIndex = 0; colIndex < this.MAX_COL; colIndex++) {
49
                const month = this.activeDate.setMonth(monthValue);
UNCOV
50
                const monthFormat = this.locale().zhMonthFormat;
×
UNCOV
51
                const isDisabled = this.disabledDate ? this.disabledDate(this.activeDate.setMonth(monthValue).nativeDate) : false;
×
UNCOV
52
                const content = this.dateHelper.format(month.nativeDate, monthFormat);
×
53
                const cell: DateCell = {
UNCOV
54
                    trackByIndex: colIndex,
×
55
                    value: month.nativeDate,
UNCOV
56
                    isDisabled,
×
57
                    content,
58
                    title: content,
UNCOV
59
                    classMap: null,
×
UNCOV
60
                    isSelected: month.isSameMonth(this.value),
×
UNCOV
61
                    onClick: () => this.chooseMonth(cell.value.getMonth()),
×
UNCOV
62
                    onMouseEnter: () => {}
×
UNCOV
63
                };
×
64
                this.addCellProperty(cell, month);
UNCOV
65
                row.dateCells.push(cell);
×
UNCOV
66
                monthValue++;
×
UNCOV
67
            }
×
68
            months.push(row);
UNCOV
69
        }
×
UNCOV
70
        return months;
×
UNCOV
71
    }
×
72

UNCOV
73
    private addCellProperty(cell: DateCell, month: TinyDate): void {
×
UNCOV
74
        if (this.selectedValue?.length > 0) {
×
75
            const [startSelected, endSelected] = this.selectedValue;
UNCOV
76
            if (startSelected?.isSameMonth(month)) {
×
77
                cell.isSelectedStartDate = true;
78
                cell.isSelected = true;
UNCOV
79
            }
×
UNCOV
80

×
81
            if (endSelected?.isSameMonth(month)) {
82
                cell.isSelectedEndDate = true;
UNCOV
83
                cell.isSelected = true;
×
84
            }
85

86
            cell.isStartSingle = startSelected && !endSelected;
87
            cell.isEndSingle = !startSelected && !!endSelected;
88
            cell.isInRange = startSelected?.isBeforeMonth(month) && month?.isBeforeMonth(endSelected);
×
89
        } else if (month.isSameMonth(this.value)) {
90
            cell.isSelected = true;
91
        }
1✔
92
        cell.classMap = this.getClassMap(cell);
93
    }
1✔
94

95
    monthCellClick(event: Event, monthCell: DateCell) {
96
        event.stopPropagation();
97
        return monthCell.isDisabled ? null : monthCell.onClick();
98
    }
99

100
    getClassMap(cell: DateCell): { [key: string]: boolean } {
101
        return {
102
            [`${this.prefixCls}-month-panel-cell`]: true,
103
            [`${this.prefixCls}-month-panel-cell-disabled`]: cell.isDisabled,
104
            [`${this.prefixCls}-month-panel-selected-cell`]: cell.isSelected,
105
            [`${this.prefixCls}-in-range-cell`]: !!cell.isInRange,
106
            [`${this.prefixCls}-month-panel-current-cell`]:
107
                new TinyDate().getYear() === this.activeDate.getYear() && cell.value.getMonth() === new TinyDate().getMonth()
108
        };
109
    }
110
}
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