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

atinc / ngx-tethys / c9d10b12-973e-4ba4-b197-e38769ff9e9c

11 Dec 2023 07:01AM UTC coverage: 90.189% (-0.2%) from 90.364%
c9d10b12-973e-4ba4-b197-e38769ff9e9c

Pull #2967

circleci

mengshuicmq
fix(datePicker): remove note
Pull Request #2967: feat(datePicker): date-picker support quarter(#INFR-10719)

5362 of 6614 branches covered (0.0%)

Branch coverage included in aggregate %.

60 of 83 new or added lines in 7 files covered. (72.29%)

18 existing lines in 4 files now uncovered.

13382 of 14169 relevant lines covered (94.45%)

968.07 hits per line

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

63.49
/src/date-picker/lib/quarter/quarter-table.component.ts
1
import { ChangeDetectionStrategy, Component, OnChanges } 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 { NgFor, NgClass, NgSwitch, NgSwitchCase } from '@angular/common';
7

8
/**
9
 * @private
10
 */
11
@Component({
1✔
12
    changeDetection: ChangeDetectionStrategy.OnPush,
13
    // eslint-disable-next-line @angular-eslint/component-selector
6✔
14
    selector: 'quarter-table',
6✔
15
    exportAs: 'quarterTable',
6✔
16
    templateUrl: 'quarter-table.component.html',
6✔
17
    standalone: true,
18
    imports: [NgFor, NgClass, NgSwitch, NgSwitchCase]
19
})
2✔
20
export class QuarterTableComponent extends CalendarTable implements OnChanges {
2✔
21
    MAX_ROW = 1;
2✔
22

23
    MAX_COL = 4;
24

17✔
25
    constructor(private dateHelper: DateHelperService) {
26
        super();
27
    }
17✔
28

17✔
29
    private chooseQuarter(quarter: number): void {
17✔
30
        this.value = this.activeDate.setQuarter(quarter);
17✔
31
        this.valueChange.emit(this.value);
32
        this.render();
33
    }
34

17✔
35
    makeHeadRow(): DateCell[] {
68✔
36
        return [];
68!
37
    }
68✔
38

68✔
39
    makeBodyRows(): DateBodyRow[] {
40
        const quarters: DateBodyRow[] = [];
41
        let quarterValue = 0;
42
        for (let rowIndex = 0; rowIndex < this.MAX_ROW; rowIndex++) {
43
            const row: DateBodyRow = {
44
                dateCells: [],
45
                trackByIndex: rowIndex
46
            };
47
            for (let colIndex = 0; colIndex < this.MAX_COL; colIndex++) {
2✔
48
                const quarter = this.activeDate.setQuarter(quarterValue + 1);
49
                const isDisabled = this.disabledDate ? this.disabledDate(quarter.nativeDate) : false;
50
                const content = `${quarter.format('qqq')}`;
51
                const cell: DateCell = {
68✔
52
                    trackByIndex: colIndex,
68✔
53
                    value: quarter.nativeDate,
68✔
54
                    isDisabled,
55
                    content,
17✔
56
                    title: content,
57
                    classMap: null,
17✔
58
                    isSelected: quarter.isSameQuarter(this.value),
59
                    onClick: () => {
60
                        this.chooseQuarter(quarter.getQuarter());
68!
NEW
61
                    },
×
NEW
62
                    onMouseEnter: () => {}
×
NEW
63
                };
×
NEW
64
                this.addCellProperty(cell, quarter);
×
65
                row.dateCells.push(cell);
NEW
66
                quarterValue++;
×
NEW
67
            }
×
NEW
68
            quarters.push(row);
×
69
        }
NEW
70
        return quarters;
×
NEW
71
    }
×
NEW
72

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

2✔
81
            if (endSelected?.isSameQuarter(quarter)) {
2!
82
                cell.isSelectedEndDate = true;
83
                cell.isSelected = true;
84
            }
68✔
85

86
            cell.isStartSingle = startSelected && !endSelected;
87
            cell.isEndSingle = !startSelected && !!endSelected;
88
            cell.isInRange = startSelected?.isBeforeQuarter(quarter) && quarter?.isBeforeQuarter(endSelected);
89
        } else if (quarter.isSameQuarter(this.value)) {
128✔
90
            cell.isSelected = true;
91
        }
92
        cell.classMap = this.getClassMap(cell, quarter);
1✔
93
    }
94

95
    quarterCellClick(event: Event, quarterCell: DateCell) {
96
        event.stopPropagation();
1✔
97
        return quarterCell.isDisabled ? null : quarterCell.onClick();
98
    }
99

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