Skip to content
6 changes: 6 additions & 0 deletions .changeset/spotty-chairs-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@example/erp": patch
"@genseki/react": patch
---

feat: add action select
7 changes: 7 additions & 0 deletions examples/erp/genseki/collections/tags.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please provide an example for the select flag?

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ export const tagsCollection = createPlugin('tags', (app) => {
search: ['name'],
sortBy: ['name'],
},
actions: {
create: true,
select: true,
delete: true,
},
})
)
.addPageAndApiRouter(collection.create(fields, {}))
.addPageAndApiRouter(collection.update(fields, {}))
.addPageAndApiRouter(collection.one(fields))
.addApiRouter(collection.deleteApiRouter(fields))
})
2 changes: 2 additions & 0 deletions packages/react/src/core/collection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
update?: boolean
delete?: boolean
one?: boolean
select?: boolean
}
}

Expand Down Expand Up @@ -361,7 +362,7 @@
}

// TODO: This is not correct, it should return default value of form instead of just simple findOne response
export type CollectionUpdateDefaultApiReturn<TFields extends Fields> = any

Check warning on line 365 in packages/react/src/core/collection/index.tsx

View workflow job for this annotation

GitHub Actions / ci

'TFields' is defined but never used. Allowed unused vars must match /^_/u

export type CollectionUpdateDefaultApiHandler<
TContext extends AnyContextable,
Expand Down Expand Up @@ -786,4 +787,5 @@
update?: boolean
delete?: boolean
one?: boolean
select?: boolean
}
7 changes: 5 additions & 2 deletions packages/react/src/react/views/collections/list/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function DefaultCollectionListPage() {

const columnHelper = createColumnHelper<BaseData>()
return [
...(context.actions?.delete
...(context.actions?.select
? [
columnHelper.display({
id: 'select',
Expand Down Expand Up @@ -114,7 +114,10 @@ export function DefaultCollectionListPage() {
<Banner slug={context.slug} />
<CollectionListTableContainer>
<CollectionListToolbar />
<CollectionListTable<any> columns={columns} />
<CollectionListTable<any>
columns={columns}
onRowClick={context.actions?.select ? 'toggleSelect' : undefined}
/>
<CollectionListPagination />
</CollectionListTableContainer>
</>
Expand Down
Loading