Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
feat: ability to set th and td class names in a UiTable column defini…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
mdeanjones committed Dec 30, 2022
1 parent cb406f9 commit 75606ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
20 changes: 15 additions & 5 deletions addon/components/ui-table/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ input of the next tier down.
@description={{column.description}}
@recordSet={{Filter.filteredRecords}}
@sortCriterion={{Sorter.Criterion}}
class={{column.thClassName}}
/>
{{/each}}
</tr>
Expand All @@ -91,14 +92,23 @@ input of the next tier down.

<tbody>
{{#if (has-block "row")}}
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record index|}}
{{yield record index to="row"}}
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record rowIndex|}}
{{yield record rowIndex to="row"}}
{{/each}}
{{else if this.columns}}
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record|}}
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record rowIndex|}}
<tr>
{{#each this.columns as |column|}}
<td>{{get record column.propertyName}}</td>
{{#each this.columns as |column columnIndex|}}
{{#if column.tdComponent}}
{{component column.tdComponent
column=column
record=record
rowIndex=rowIndex
columnIndex=columnIndex
}}
{{else}}
<td class={{column.tdClassName}}>{{get record column.propertyName}}</td>
{{/if}}
{{/each}}
</tr>
{{/each}}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/ui-table/th/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class UiTableTh extends Component {

public recordSet?: unknown[];

public showColumnFilter = true;
public showColumnFilter = false;

protected declare sortCriterion: UiSorterCriterion;

Expand Down
5 changes: 5 additions & 0 deletions addon/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type Controller from '@ember/controller';
import type EmberComponent from '@ember/component';
import type GlimmerComponent from '@glimmer/component';

export type DirectionsX = Directions.Left | Directions.Right;

Expand Down Expand Up @@ -33,6 +35,9 @@ export interface ITableColumn {
filterStartsWith?: boolean;
filterCaseSensitive?: boolean;
filterBooleanMap?: [string, string];
thClassName?: string;
tdClassName?: string;
tdComponent?: string | typeof EmberComponent | typeof GlimmerComponent;
}

export enum Directions {
Expand Down

0 comments on commit 75606ac

Please sign in to comment.