@@ -35,14 +35,18 @@ import { TableColumnConfigExtended } from '../table.service';
35
35
[htTooltip]="this.getTooltip(this.columnConfig.titleTooltip, this.columnConfig.title)"
36
36
class="table-header-cell-renderer"
37
37
>
38
- <ng-container *ngIf="this.leftAlignFilterButton">
38
+ <ng-container *ngIf="this.isShowOptionButton && this. leftAlignFilterButton">
39
39
<ng-container *ngTemplateOutlet="optionsButton"></ng-container>
40
40
</ng-container>
41
41
<div class="title" [ngClass]="this.classes" (click)="this.onSortChange()">{{ this.columnConfig.title }}</div>
42
- <ng-container *ngIf="!this.leftAlignFilterButton">
42
+ <ng-container *ngIf="this.isShowOptionButton && !this.leftAlignFilterButton">
43
43
<ng-container *ngTemplateOutlet="optionsButton"></ng-container>
44
44
</ng-container>
45
45
46
+ <ng-template #htmlTooltip>
47
+ <div [innerHTML]="this.columnConfig?.titleTooltip"></div>
48
+ </ng-template>
49
+
46
50
<ng-template #optionsButton>
47
51
<ht-popover class="options-button" [closeOnClick]="true">
48
52
<ht-popover-trigger>
@@ -54,9 +58,9 @@ import { TableColumnConfigExtended } from '../table.service';
54
58
<div [style.min-width.px]="trigger.offsetWidth" class="popover-content">
55
59
<ng-container *ngIf="this.isFilterable">
56
60
<div class="popover-item" (click)="this.onFilterValues()" *ngIf="this.isFilterable">Filter Values</div>
57
- <div class="popover-item-divider" *ngIf="this.columnConfig.sortable !== false || this.editable"></div>
58
61
</ng-container>
59
62
<ng-container *ngIf="this.columnConfig.sortable !== false">
63
+ <div class="popover-item-divider"></div>
60
64
<div class="popover-item sort-ascending" (click)="this.onSortChange(SORT_ASC)">
61
65
Sort Ascending
62
66
<ht-icon class="popover-item-icon" icon="${ IconType . ArrowUp } " size="${ IconSize . Small } "></ht-icon>
@@ -65,19 +69,15 @@ import { TableColumnConfigExtended } from '../table.service';
65
69
Sort Descending
66
70
<ht-icon class="popover-item-icon" icon="${ IconType . ArrowDown } " size="${ IconSize . Small } "></ht-icon>
67
71
</div>
68
- <div class="popover-item-divider" *ngIf="this.editable"></div>
69
72
</ng-container>
70
73
71
- <ng-container *ngIf="this.editable">
74
+ <ng-container *ngIf="this.editable && this.isEditableAvailableColumns">
75
+ <div class="popover-item-divider"></div>
72
76
<div class="popover-item" (click)="this.onEditColumns()">Edit Columns</div>
73
77
</ng-container>
74
78
</div>
75
79
</ht-popover-content>
76
80
</ht-popover>
77
-
78
- <ng-template #htmlTooltip>
79
- <div [innerHTML]="this.columnConfig?.titleTooltip"></div>
80
- </ng-template>
81
81
</ng-template>
82
82
</div>
83
83
`
@@ -115,6 +115,8 @@ export class TableHeaderCellRendererComponent implements OnInit, OnChanges {
115
115
public classes : string [ ] = [ ] ;
116
116
117
117
public isFilterable : boolean = false ;
118
+ public isEditableAvailableColumns : boolean = false ;
119
+ public isShowOptionButton : boolean = false ;
118
120
119
121
@ViewChild ( 'htmlTooltip' )
120
122
public htmlTooltipTemplate ?: TemplateRef < unknown > ;
@@ -132,6 +134,9 @@ export class TableHeaderCellRendererComponent implements OnInit, OnChanges {
132
134
133
135
if ( changes . columnConfig || changes . metadata ) {
134
136
this . isFilterable = this . isAttributeFilterable ( ) ;
137
+ this . isEditableAvailableColumns = this . areAnyAvailableColumnsEditable ( ) ;
138
+ this . isShowOptionButton =
139
+ this . isFilterable || this . isEditableAvailableColumns || this . columnConfig ?. sortable === true ;
135
140
}
136
141
}
137
142
@@ -183,6 +188,18 @@ export class TableHeaderCellRendererComponent implements OnInit, OnChanges {
183
188
) ;
184
189
}
185
190
191
+ private areAnyAvailableColumnsEditable ( ) : boolean {
192
+ if ( this . availableColumns === undefined ) {
193
+ return false ;
194
+ }
195
+
196
+ return this . availableColumns . some ( column => this . isColumnEditable ( column ) ) ;
197
+ }
198
+
199
+ private isColumnEditable ( columnConfig : TableColumnConfigExtended ) : boolean {
200
+ return columnConfig . editable === true ;
201
+ }
202
+
186
203
public onFilterValues ( ) : void {
187
204
this . isFilterable &&
188
205
this . modalService . createModal < InFilterModalData > ( {
0 commit comments