diff --git a/doc-app/tests/integration/components/ember-ui/prefabs/tpk-table-generic-prefab-test.gts b/doc-app/tests/integration/components/ember-ui/prefabs/tpk-table-generic-prefab-test.gts new file mode 100644 index 00000000..2ab197b9 --- /dev/null +++ b/doc-app/tests/integration/components/ember-ui/prefabs/tpk-table-generic-prefab-test.gts @@ -0,0 +1,43 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { setupIntl } from 'ember-intl/test-support'; +import { render } from '@ember/test-helpers'; +import { TableGenericUserWorker } from 'doc-app/tests/workers/table-generic'; +import { worker } from 'doc-app/tests/worker'; +import TpkTableGenericPrefab from '@triptyk/ember-ui/components/prefabs/tpk-table-generic-prefab'; + +module('Integration | Component | Prefabs | Tpk-table-generic-prefab', function(hooks) { + setupRenderingTest(hooks); + setupIntl(hooks, 'fr-fr'); + + hooks.beforeEach(async function () { + await TableGenericUserWorker(worker); + }); + + async function renderComponent(){ + const columns = [ + { + field: 'lastName', + headerName: 'Nom', + sortable: true, + }, + { + field: 'fisrtName', + headerName: 'Prénom', + sortable: true, + }]; + + await render( + + ) + } + + test('Render prefab table generic', async function(assert) { + await renderComponent() + await this.pauseTest(); + assert.dom('[data-test-table-generic-container]').exists(); + }); + +}) \ No newline at end of file diff --git a/packages/ember-ui/package.json b/packages/ember-ui/package.json index 9f0770ed..e74aa7de 100644 --- a/packages/ember-ui/package.json +++ b/packages/ember-ui/package.json @@ -126,6 +126,7 @@ }, "app-js": { "./components/prefabs/tpk-confirm-modal-prefab.js": "./dist/_app_/components/prefabs/tpk-confirm-modal-prefab.js", + "./components/prefabs/tpk-table-generic-prefab.js": "./dist/_app_/components/prefabs/tpk-table-generic-prefab.js", "./components/tpk-actions-menu.js": "./dist/_app_/components/tpk-actions-menu.js", "./components/tpk-actions-menu/element.js": "./dist/_app_/components/tpk-actions-menu/element.js", "./components/tpk-confirm-modal.js": "./dist/_app_/components/tpk-confirm-modal.js", diff --git a/packages/ember-ui/src/components/prefabs/tpk-table-generic-prefab.gts b/packages/ember-ui/src/components/prefabs/tpk-table-generic-prefab.gts new file mode 100644 index 00000000..f4eaaf75 --- /dev/null +++ b/packages/ember-ui/src/components/prefabs/tpk-table-generic-prefab.gts @@ -0,0 +1,78 @@ +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'; + +export interface TableGenericPrefabComponentSignature { + Args: TableGenericComponentSignature["Args"] & { + columns: { + field: string; + headerName: string; + sortable: boolean; + }[] + }; + Blocks: { + default: [ + WithBoundArgs + ]; + }; + Element: HTMLElement; +} + +export default class TableGenericPrefabComponent extends Component{ + + get pageSizes(){ + if(this.args.pageSizes){ + return this.args.pageSizes; + } + return [5, 10, 25]; + } + + get filterText(): string | undefined { + if(this.args.filterText){ + return this.args.filterText; + } + return this.filterText; + } + + get columns() { + console.log(this.args.columns); + if(!this.args.columns){ + throw new Error("entityKeys is required"); + + } + return this.args.columns + } + + +} \ No newline at end of file diff --git a/packages/ember-ui/src/template-registry.ts b/packages/ember-ui/src/template-registry.ts index 31e35ea4..a4c04b00 100644 --- a/packages/ember-ui/src/template-registry.ts +++ b/packages/ember-ui/src/template-registry.ts @@ -23,6 +23,7 @@ import type TpkActionsMenuElementComponent from './components/tpk-actions-menu/e import type TpkStackListTitleComponent from './components/tpk-stack-list/title.gts'; import type TpkLazyImageComponent from './components/tpk-lazy-image.gts'; import type TpkConfirmModalPrefabComponent from './components/prefabs/tpk-confirm-modal-prefab.gts'; +import type TableGenericPrefabComponent from './components/prefabs/tpk-table-generic-prefab'; export default interface Registry { 'tpk-actions-menu/element': typeof TpkActionsMenuElementComponent; @@ -59,4 +60,5 @@ export default interface Registry { 'table-generic/header/cell': typeof TableGenericHeaderCellComponent; 'tpk-confirm-modal': typeof TpkConfirmModalComponent; 'tpk-confirm-modal-prefab' : typeof TpkConfirmModalPrefabComponent; + 'tpk-table-generic-prefab' : typeof TableGenericPrefabComponent; }