-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: test table generic with my solution biatch
- Loading branch information
Showing
7 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class TableRoute extends Route {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import Component from '@glimmer/component'; | ||
import RouteTemplate from 'ember-route-template'; | ||
import type { RouteTemplateSignature } from 'doc-app/utils/route-template'; | ||
import type TableRoute from 'doc-app/routes/table'; | ||
import type UserModel from 'doc-app/models/user'; | ||
import type { TpkSelectSignature } from '@triptyk/ember-input/components/tpk-select'; | ||
import TpkSelectComponent from '@triptyk/ember-input/components/tpk-select'; | ||
import TpkTableGenericPrefab, { type TableParams } from '@triptyk/ember-ui/components/prefabs/tpk-table-generic-prefab'; | ||
import { hash } from '@ember/helper'; | ||
|
||
export interface TableRouteComponentSignature {} | ||
|
||
class TableRouteComponent extends Component<RouteTemplateSignature<TableRoute>> { | ||
emailOptions = ['info@triptyk.eu','loempia@triptyk.eu']; | ||
|
||
tableParamsWithFunctions: TableParams = { | ||
entity: 'user', | ||
pageSizes: [10,30,50,75], | ||
defaultSortColumn: 'firstName', | ||
columns:[ | ||
{ | ||
field: 'firstName', | ||
headerName: 'Prénom', | ||
sortable: true, | ||
}, | ||
{ | ||
field: 'email', | ||
headerName: 'Email', | ||
sortable:false, | ||
component : 'selectEmail', | ||
}, | ||
], | ||
actionMenu: [], | ||
}; | ||
|
||
onUpdate = (selection: unknown, row: UserModel) => { | ||
row.set('email', selection as string); | ||
console.log(selection); | ||
console.log(row); | ||
} | ||
|
||
<template> | ||
<div class="flex justify-center items-center h-screen px-32"> | ||
<TpkTableGenericPrefab | ||
@tableParams={{this.tableParamsWithFunctions}} | ||
@columnsComponent={{hash | ||
selectEmail=(component | ||
SelectTableRegister | ||
label="Email" | ||
options=this.emailOptions | ||
onUpdate=this.onUpdate | ||
) | ||
}} | ||
/> | ||
</div> | ||
</template> | ||
} | ||
|
||
export default RouteTemplate(TableRouteComponent); | ||
|
||
class SelectTableRegister extends Component<TpkSelectSignature & { | ||
Args: { | ||
cellValue: string, | ||
onUpdate: (selection: unknown, row: UserModel) => void, | ||
row: UserModel | ||
} | ||
}> { | ||
|
||
onChange = (selection: unknown) => { | ||
this.args.onUpdate(selection, this.args.row); | ||
} | ||
|
||
<template> | ||
<div data-test-table-generic-select> | ||
<TpkSelectComponent @options={{@options}} @onChange={{this.onChange}} @selected={{@cellValue}} @label="" as |S| > | ||
<S.Option as |O|> | ||
{{O.option}} | ||
</S.Option> | ||
</TpkSelectComponent> | ||
</div> | ||
</template>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Route from '@ember/routing/route'; | ||
import type Controller from '@ember/controller'; | ||
|
||
export type ModelFrom<R extends Route> = Awaited<ReturnType<R['model']>>; | ||
|
||
export type RouteTemplateSignature< | ||
R extends Route, | ||
C extends Controller | undefined = undefined, | ||
> = C extends Controller | ||
? { | ||
Args: { | ||
model: ModelFrom<R>; | ||
controller: C; | ||
}; | ||
} | ||
: { | ||
Args: { | ||
model: ModelFrom<R>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.