• 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

7.02
/src/table/table-column.component.ts
1
import { _isNumberValue, coerceCssPixelValue } from '@angular/cdk/coercion';
2
import {
3
    Component,
4
    ContentChild,
5
    ElementRef,
6
    EventEmitter,
7
    InjectionToken,
8
    Input,
9
    OnInit,
1✔
10
    Output,
11
    TemplateRef,
12
    ViewEncapsulation,
13
    inject
14
} from '@angular/core';
15
import { coerceBooleanProperty, isArray, isObject } from 'ngx-tethys/util';
1✔
16
import { ThyTableSortDirection, ThyTableSortEvent } from './table.interface';
UNCOV
17

×
UNCOV
18
export interface IThyTableColumnParentComponent {
×
UNCOV
19
    rowKey: string;
×
UNCOV
20
    updateColumnSelections(key: string, selections: any): void;
×
UNCOV
21
}
×
UNCOV
22

×
UNCOV
23
/**
×
UNCOV
24
 * Injection token used to provide the parent component to options.
×
UNCOV
25
 */
×
UNCOV
26
export const THY_TABLE_COLUMN_PARENT_COMPONENT = new InjectionToken<IThyTableColumnParentComponent>('THY_TABLE_COLUMN_PARENT_COMPONENT');
×
UNCOV
27

×
UNCOV
28
export type FixedDirection = 'left' | 'right';
×
UNCOV
29

×
UNCOV
30
/**
×
UNCOV
31
 * 表格列组件
×
32
 * @name thy-table-column
33
 * @order 20
UNCOV
34
 */
×
35
@Component({
36
    selector: 'thy-table-column',
37
    template: '<ng-content></ng-content>',
×
38
    encapsulation: ViewEncapsulation.None
39
})
UNCOV
40
export class ThyTableColumnComponent implements OnInit {
×
UNCOV
41
    private el = inject(ElementRef);
×
UNCOV
42
    parent = inject(THY_TABLE_COLUMN_PARENT_COMPONENT, { optional: true })!;
×
43

×
44
    /**
UNCOV
45
     * 设置数据属性 Key,读取数组中对象的当前 Key 值
×
46
     * @type string
×
47
     */
48
    @Input('thyModelKey') model = '';
49

50
    /**
UNCOV
51
     * 设置列名,显示在表头
×
52
     * @type string
53
     */
UNCOV
54
    @Input('thyTitle') title = '';
×
UNCOV
55

×
UNCOV
56
    /**
×
57
     * 设置列的特殊类型,序列号、选择框、单选框、切换按钮
58
     * @type string
59
     */
×
60
    @Input('thyType') type = '';
61

62
    public width: string = '';
UNCOV
63

×
64
    /**
65
     * 设置列的宽度
66
     */
UNCOV
67
    @Input()
×
UNCOV
68
    set thyWidth(value: string | number) {
×
69
        this.width = coerceCssPixelValue(value);
×
70
    }
71

72
    public minWidth: string = '';
73

UNCOV
74
    /**
×
UNCOV
75
     * 设置列的最小宽度
×
76
     */
77
    @Input()
UNCOV
78
    set thyMinWidth(value: string | number) {
×
79
        this.minWidth = coerceCssPixelValue(value);
80
    }
1✔
81

82
    /**
83
     * 设置列的样式
84
     */
85
    @Input('thyClassName') className = '';
86

87
    /**
88
     * 设置列头部的 Class,即 th 元素上的样式
89
     * @type string
90
     */
91
    @Input('thyHeaderClassName') headerClassName = '';
92

93
    /**
94
     * 设置自定义类型的禁用状态
95
     * @type boolean
96
     */
97
    @Input({ alias: 'thyDisabled', transform: coerceBooleanProperty }) disabled = false;
98

99
    /**
100
     * thyType 为 checkbox 或者 radio 类型时选中的数据 ,支持单个对象,单个 Id,同时支持多个 Id,多个对象
101
     */
102
    @Input('thySelections')
103
    set selections(value: any) {
1✔
104
        if (value) {
105
            this._selections = isArray(value) ? value : [value];
106
            this._selections = this._selections.map((item: string | number | object) => {
107
                return isObject(item) ? item[this.parent.rowKey] : item;
108
            });
109
            if (!this._firstChange) {
110
                this.parent.updateColumnSelections(this.key, this._selections);
111
            }
112
        }
113
    }
114

115
    get selections() {
116
        return this._selections;
117
    }
118
    /**
119
     * 设置数据为空的时候显示的文本
120
     * @type string
121
     */
122
    @Input('thyDefaultText') defaultText = '';
123

124
    /**
125
     * 设置 Tree 模式下折叠展开按钮展示列,不传默认第一列
126
     */
127
    @Input({ alias: 'thyExpand', transform: coerceBooleanProperty }) expand = false;
128

129
    public sortable: boolean;
130

131
    /**
132
     * 是否开启列排序功能(开启时 thyModelKey 为 必传)
133
     * @default false
134
     */
135
    @Input({ transform: coerceBooleanProperty })
136
    set thySortable(value: boolean) {
137
        if (value) {
138
            if (this.model) {
139
                this.sortable = true;
140
            } else {
141
                throw new Error(`thyModelKey is required when sortable`);
142
            }
143
        } else {
144
            this.sortable = false;
145
        }
146
    }
147

148
    /**
149
     * 默认列排序顺序
150
     * @type 'asc' | 'desc' | ''
151
     */
152
    @Input('thySortDirection') sortDirection = ThyTableSortDirection.default;
153

154
    /**
155
     * 设置固定列
156
     */
157
    @Input('thyFixed') fixed: FixedDirection;
158

159
    /**
160
     * 当前列是否是操作列,设置为 true 时会追加 thy-operation-links 样式类,文字居中
161
     * @default false
162
     */
163
    @Input({ alias: 'thyOperational', transform: coerceBooleanProperty }) operational: boolean;
164

165
    /**
166
     * 当前列是否是次要列,设置为 true 时会追加 thy-table-column-secondary 样式类,文字颜色为 $gray-600
167
     * @default false
168
     */
169
    @Input({ alias: 'thySecondary', transform: coerceBooleanProperty }) secondary: boolean;
170

171
    /**
172
     * 列排序修改事件
173
     */
174
    @Output('thySortChange') sortChange: EventEmitter<ThyTableSortEvent> = new EventEmitter<ThyTableSortEvent>();
175

176
    @ContentChild('header', { static: true }) headerTemplateRef: TemplateRef<any>;
177

178
    @ContentChild('cell', { static: true }) cellTemplateRef: TemplateRef<any>;
179

180
    @ContentChild(TemplateRef, { static: true })
181
    set templateRef(value: TemplateRef<any>) {
182
        if (value) {
183
            if (!this.headerTemplateRef && !this.cellTemplateRef) {
184
                this.cellTemplateRef = value;
185
            }
186
        }
187
    }
188

189
    public key?: string;
190

191
    public left: number;
192

193
    public right: number;
194

195
    private _selections: any;
196

197
    private _firstChange = true;
198

199
    ngOnInit() {
200
        this.key = this._generateKey();
201
        this._firstChange = false;
202
    }
203

204
    private _generateKey() {
205
        return '[$$column]' + Math.random().toString(16).slice(2, 10);
206
    }
207
}
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