• 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

5.63
/src/date-picker/lib/year/year-table.component.ts
1
import { ChangeDetectionStrategy, Component, EventEmitter, OnChanges, Output } from '@angular/core';
2
import { TinyDate } from 'ngx-tethys/util';
3
import { CalendarTable } from '../calendar/calendar-table.component';
4
import { DateCell, DateBodyRow, YearCell } from '../date/types';
5
import { NgClass } from '@angular/common';
6

7
/**
8
 * @private
9
 */
1✔
10
@Component({
UNCOV
11
    changeDetection: ChangeDetectionStrategy.OnPush,
×
UNCOV
12
    // eslint-disable-next-line @angular-eslint/component-selector
×
UNCOV
13
    selector: 'year-table',
×
UNCOV
14
    templateUrl: 'year-table.component.html',
×
15
    imports: [NgClass]
16
})
UNCOV
17
export class YearTable extends CalendarTable implements OnChanges {
×
UNCOV
18
    MAX_ROW = 4;
×
UNCOV
19

×
20
    MAX_COL = 3;
21

UNCOV
22
    @Output() readonly decadePanelShow = new EventEmitter<void>();
×
23

24
    constructor() {
UNCOV
25
        super();
×
UNCOV
26
    }
×
UNCOV
27
    private chooseYear(year: number): void {
×
UNCOV
28
        this.value = this.activeDate.setYear(year);
×
UNCOV
29
        this.valueChange.emit(this.value);
×
UNCOV
30
        this.render();
×
UNCOV
31
    }
×
UNCOV
32

×
33
    makeHeadRow(): DateCell[] {
34
        return [];
35
    }
UNCOV
36

×
UNCOV
37
    makeBodyRows(): DateBodyRow[] {
×
UNCOV
38
        const years: DateBodyRow[] = [];
×
UNCOV
39
        const currentYear = this.activeDate && this.activeDate.getYear();
×
UNCOV
40
        const startYear = parseInt(`${currentYear / 10}`, 10) * 10;
×
UNCOV
41
        const endYear = startYear + 9;
×
42
        const previousYear = startYear - 1;
43
        let yearValue = 0;
44
        for (let rowIndex = 0; rowIndex < this.MAX_ROW; rowIndex++) {
45
            const row: DateBodyRow = {
46
                dateCells: [],
47
                trackByIndex: rowIndex
×
48
            };
×
49
            for (let colIndex = 0; colIndex < this.MAX_COL; colIndex++) {
UNCOV
50
                const yearNum = previousYear + yearValue;
×
51
                const year = this.activeDate.setYear(yearNum);
52
                const content = String(yearNum);
UNCOV
53
                const isDisabled = this.disabledDate ? this.disabledDate(year.nativeDate) : false;
×
UNCOV
54

×
UNCOV
55
                const cell: YearCell = {
×
56
                    trackByIndex: colIndex,
UNCOV
57
                    isDisabled,
×
58
                    content,
UNCOV
59
                    value: year.nativeDate,
×
60
                    title: content,
61
                    isSelected: yearNum === (this.value && this.value.getYear()),
UNCOV
62
                    isSameDecade: yearNum >= startYear && yearNum <= endYear,
×
UNCOV
63
                    classMap: {},
×
UNCOV
64
                    onClick: () => this.chooseYear(cell.value?.getFullYear()),
×
UNCOV
65
                    onMouseEnter: () => {}
×
66
                };
UNCOV
67
                this.addCellProperty(cell, year);
×
UNCOV
68
                row.dateCells.push(cell);
×
69
                yearValue++;
UNCOV
70
            }
×
UNCOV
71
            years.push(row);
×
UNCOV
72
        }
×
73
        return years;
UNCOV
74
    }
×
UNCOV
75

×
76
    private addCellProperty(cell: DateCell, year: TinyDate): void {
UNCOV
77
        if (this.selectedValue?.length > 0) {
×
78
            const [startSelected, endSelected] = this.selectedValue;
79
            if (startSelected?.isSameYear(year)) {
UNCOV
80
                cell.isSelected = true;
×
UNCOV
81
            }
×
82

83
            if (endSelected?.isSameYear(year)) {
UNCOV
84
                cell.isSelected = true;
×
85
            }
86

87
            cell.isStartSingle = startSelected && !endSelected;
88
            cell.isEndSingle = !startSelected && !!endSelected;
89
            cell.isInRange = startSelected?.isBeforeYear(year) && year?.isBeforeYear(endSelected);
90
        } else if (year.isSameYear(this.value)) {
91
            cell.isSelected = true;
92
        }
1✔
93
        cell.classMap = this.getClassMap(cell);
1✔
94
    }
95

96
    yearCellClick(event: Event, yearCell: DateCell) {
97
        event.stopPropagation();
1✔
98
        return yearCell.isDisabled ? null : yearCell.onClick();
99
    }
100

101
    getClassMap(cell: YearCell): { [key: string]: boolean } {
102
        return {
103
            [`${this.prefixCls}-year-panel-cell`]: true,
104
            [`${this.prefixCls}-year-panel-selected-cell`]: cell.isSelected,
105
            [`${this.prefixCls}-year-panel-cell-disabled`]: cell.isDisabled,
106
            [`${this.prefixCls}-year-panel-cell-in-view`]: cell.isSameDecade,
107
            [`${this.prefixCls}-in-range-cell`]: !!cell.isInRange
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