Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD committed Jan 3, 2025
1 parent b0d3caf commit 21d61e1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Component from '@glimmer/component';
import type { TableGenericComponentSignature } from "../tpk-table-generic.gts";
import TableGenericComponent from "../tpk-table-generic.gts";
import TpkTableGeneric from "../tpk-table-generic.gts";
import type { WithBoundArgs } from '@glint/template';
import t from 'ember-intl/helpers/t';
import type { ContentValue, WithBoundArgs } from '@glint/template';
import { get } from '@ember/object';

export interface TableGenericPrefabComponentSignature {
Args: TableGenericComponentSignature["Args"] & {
Expand Down Expand Up @@ -38,14 +38,18 @@ export default class TableGenericPrefabComponent extends Component<TableGenericP
}

get columns() {
console.log(this.args.columns);
if(!this.args.columns){
throw new Error("entityKeys is required");

}
return this.args.columns
}


displayValue = (element: unknown, field: string): ContentValue => {
const value = get(element, field);
return String(value);
}

<template>
<TpkTableGeneric
@pageSizes={{this.pageSizes}}
Expand All @@ -59,20 +63,20 @@ export default class TableGenericPrefabComponent extends Component<TableGenericP
<TG.Table as | Table |>
<Table.Header as |Header|>
{{#each this.columns as |column|}}
{{!-- <Header.Cell @sortable={{column.sortable}} @prop={{column.field}} data-test-table={{column.field}}>
<Header.Cell @sortable={{column.sortable}} @prop={{column.field}}>
{{column.headerName}}
</Header.Cell> --}}
</Header.Cell>
{{/each}}
</Table.Header>
<Table.Body as |Body element|>
{{!-- {{#each this.columns as |column|}}
{{#each this.columns as |column|}}
<Body.Cell >
{{element[column.field}]}}
{{this.displayValue element column.field}}
</Body.Cell>
{{/each}} --}}
{{/each}}
</Table.Body>
<Table.Footer />
</TG.Table>
</TpkTableGeneric>
</template>
}
}
4 changes: 2 additions & 2 deletions packages/ember-ui/src/components/tpk-table-generic/body.gts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@glimmer/component';
import { tracked } from 'tracked-built-ins';
import { action } from '@ember/object';
import type { ComponentLike, WithBoundArgs } from '@glint/template';
import type { WithBoundArgs } from '@glint/template';
import TableGenericBodyCellComponent from './body/cell.gts';
import TableGenericBodyActionMenuComponent from './body/action-menu.gts';
import { fn, hash } from '@ember/helper';
Expand All @@ -20,7 +20,7 @@ export interface TableGenericBodyComponentSignature {
Blocks: {
default: [
{
Cell: ComponentLike<typeof TableGenericBodyCellComponent>;
Cell: WithBoundArgs<typeof TableGenericBodyCellComponent, 'row'>;
ActionMenu: WithBoundArgs<
typeof TableGenericBodyActionMenuComponent,
'registerActionMenu'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import type { TOC } from '@ember/component/template-only';
import type { ComponentLike } from '@glint/template';

export interface TableGenericBodyCellComponentSignature {
Args: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
row: any;
row: ComponentLike;
};
Element: HTMLDivElement;
Element: HTMLElement;
Blocks: {
default: [];
};
}

const TableGenericBodyCellComponent: TOC<TableGenericBodyCellComponentSignature> =
<template>
{{!-- @glint-ignore --}}
<@row.cell ...attributes>
{{yield}}
{{!-- @glint-ignore --}}
</@row.cell>
</template>;

Expand Down
5 changes: 2 additions & 3 deletions packages/ember-ui/src/components/tpk-table-generic/header.gts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentLike } from '@glint/template';
import type { WithBoundArgs } from '@glint/template';
import TableGenericHeaderCellComponent from './header/cell.gts';
import type { TOC } from '@ember/component/template-only';
import { hash } from '@ember/helper';
Expand All @@ -9,11 +9,10 @@ export interface TableGenericHeaderComponentSignature {
table: any;
hasActionMenu: boolean;
};
Element: HTMLDivElement;
Blocks: {
default: [
{
Cell: ComponentLike<typeof TableGenericHeaderCellComponent>;
Cell: WithBoundArgs<typeof TableGenericHeaderCellComponent, 'header'>;
},
];
};
Expand Down

0 comments on commit 21d61e1

Please sign in to comment.