Skip to content

Commit

Permalink
Merge pull request #117 from TRIPTYK/tpk-bug-01-pefab-table-generic
Browse files Browse the repository at this point in the history
fix: debug table generic prefab
  • Loading branch information
Brenion authored Jan 27, 2025
2 parents 0222629 + 7364795 commit 71e112f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ module('Integration | Component | Prefabs | Tpk-table-generic-prefab', function(
});

async function renderComponent(tableParams : TableParams){

await render(
<template>
<TpkTableGenericPrefab @tableParams={{tableParams}} />
Expand Down Expand Up @@ -183,7 +182,7 @@ module('Integration | Component | Prefabs | Tpk-table-generic-prefab', function(

await render(
<template>
<TpkTableGenericPrefab
<TpkTableGenericPrefab
@tableParams={{tableParamsWithFunctions}}
@columnsComponent={{hash
selectEmail=(component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
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 { ContentValue, WithBoundArgs } from '@glint/template';
import { get } from '@ember/object';
import type { DirectInvokable } from '@glint/template/-private/integration';
import type { Invokable } from '@glint/template/-private/integration';


export interface TableParams {
entity: string;
pageSizes?: number[];
defaultSortColumn?: string;
additionalFilters?: Record<string, unknown>;
relationships?: string;
columns: {
field: string;
headerName: string;
Expand All @@ -22,11 +23,10 @@ export interface TableParams {
}

export interface TableGenericPrefabComponentSignature {
Args: TableGenericComponentSignature["Args"] & {
Args: {
tableParams:TableParams,
label:string,
placeholder:string,
columnsComponent: Record<string, DirectInvokable>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
columnsComponent?: Record<string, Invokable<any>>;
};
Blocks: {
default: [
Expand All @@ -37,11 +37,11 @@ export interface TableGenericPrefabComponentSignature {
}

export default class TableGenericPrefabComponent extends Component<TableGenericPrefabComponentSignature>{
getComponent = (component: string): DirectInvokable => {
if (!this.args.columnsComponent[component]) {
getComponent = (component: string) => {
if (!this.args.columnsComponent || !this.args.columnsComponent[component]) {
throw new Error(`Component ${component} not found`);
}
return this.args.columnsComponent[component] as DirectInvokable;
return this.args.columnsComponent[component];
}

get pageSizes(){
Expand Down Expand Up @@ -93,15 +93,12 @@ export default class TableGenericPrefabComponent extends Component<TableGenericP
<template>
<div class="tpk-table-generic-container"
data-test-table-generic-prefab>
{{log @placeholder}}
<TpkTableGeneric
@pageSizes={{this.pageSizes}}
@additionalFilters={{@additionalFilters}}
@additionalFilters={{@tableParams.additionalFilters}}
@defaultSortColumn={{@tableParams.defaultSortColumn}}
@entity={{this.entity}}
@relationships={{@relationships}}
@placeholder={{@placeholder}}
@label={{@label}}
@relationships={{@tableParams.relationships}}
as | TG |>
<TG.SearchBar />
<TG.Table as | Table |>
Expand Down

0 comments on commit 71e112f

Please sign in to comment.