• 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

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

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

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

×
30
export type FixedDirection = 'left' | 'right';
31

32
/**
33
 * 表格列组件
34
 * @name thy-table-column
×
35
 * @order 20
36
 */
37
@Component({
×
38
    selector: 'thy-table-column',
×
39
    template: '<ng-content></ng-content>',
×
40
    encapsulation: ViewEncapsulation.None,
41
    standalone: true
42
})
×
43
export class ThyTableColumnComponent implements OnInit {
44
    /**
45
     * 设置数据属性 Key,读取数组中对象的当前 Key 值
46
     * @type string
×
47
     */
48
    @Input('thyModelKey') model = '';
49

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

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

×
62
    public width: string = '';
×
63

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

×
72
    public minWidth: string = '';
73

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

82
    /**
83
     * 设置列的样式
84
     */
1✔
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('thyDisabled') @InputBoolean() disabled = false;
98

99
    /**
100
     * thyType 为 checkbox 或者 radio 类型时选中的数据 ,支持单个对象,单个 Id,同时支持多个 Id,多个对象
101
     */
102
    @Input('thySelections')
103
    set selections(value: any) {
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;
1✔
108
            });
109
            if (!this._firstChange) {
110
                this.parent.updateColumnSelections(this.key, this._selections);
111
            }
1✔
112
        }
113
    }
114

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

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

1✔
129
    public sortable: boolean;
130

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

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

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

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

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

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

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

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

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

190
    public key?: string;
191

192
    public left: number;
193

194
    public right: number;
195

196
    private _selections: any;
197

198
    private _firstChange = true;
199

200
    constructor(
201
        private el: ElementRef,
202
        @Optional()
203
        @Inject(THY_TABLE_COLUMN_PARENT_COMPONENT)
204
        public parent: IThyTableColumnParentComponent
205
    ) {}
206

207
    ngOnInit() {
208
        this.key = this._generateKey();
209
        this._firstChange = false;
210
    }
211

212
    private _generateKey() {
213
        return '[$$column]' + Math.random().toString(16).slice(2, 10);
214
    }
215
}
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