Skip to content

Commit 6ea1599

Browse files
sevenseacatzachdaniel
authored andcommitted
feat: Redo of Cinder integration (#380)
* Revert "improvement: incoporate sevenseacat theme into cinder table for consistent styling and enhanced features" This reverts commit 7d39a83. * Update with simpler Cinder integration * Refactor DataTable to use Cinder's built-in pagination and data loading Remove manual data loading via AshPhoenix.Form.submit() and let Cinder handle pagination, error states, and loading internally. Add filter toggle button and pass pagination config derived from action settings. * Improve DataTable layout consistency and styling Align spacing with other ash_admin pages, constrain query argument form width, make table full-width within its card, use consistent px-6 padding throughout, and style Filters button as outline. * Fix query validation and pagination config crash Don't pass query to Cinder when form has validation errors, and handle action.pagination being false (not just nil). * chore: REUSE compliance * chore: Remove extra blank lines * chore: run `mix format` * Hide Filters button when resource has no filterable columns * chore: Fix formatting.. again
1 parent a90d5e7 commit 6ea1599

13 files changed

Lines changed: 281 additions & 655 deletions

File tree

assets/tailwind.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ module.exports = {
3434
addVariant("phx-click-loading", [
3535
".phx-click-loading&",
3636
".phx-click-loading &",
37-
])
37+
]),
3838
),
3939
plugin(({ addVariant }) =>
4040
addVariant("phx-submit-loading", [
4141
".phx-submit-loading&",
4242
".phx-submit-loading &",
43-
])
43+
]),
4444
),
4545
plugin(({ addVariant }) =>
4646
addVariant("phx-change-loading", [
4747
".phx-change-loading&",
4848
".phx-change-loading &",
49-
])
49+
]),
5050
),
5151

5252
// Embeds Heroicons (https://heroicons.com) into your app.css bundle
@@ -86,7 +86,7 @@ module.exports = {
8686
};
8787
},
8888
},
89-
{ values }
89+
{ values },
9090
);
9191
}),
9292
],

dev/resources/accounts/resources/user.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ defmodule Demo.Accounts.User do
2525
read_actions [:me, :read, :by_id, :by_name]
2626

2727
table_columns [:id, :first_name, :last_name, :representative, :admin, :full_name, :api_key, :date_of_birth]
28+
table_filterable_columns [:first_name]
29+
table_sortable_columns [:first_name, :last_name]
2830

2931
show_calculations [:multi_arguments, :is_super_admin?, :full_name, :nested_embed]
3032
end

documentation/dsls/DSL-AshAdmin.Resource.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Configure the admin dashboard for a given resource.
3333
| [`polymorphic_tables`](#admin-polymorphic_tables){: #admin-polymorphic_tables } | `list(String.t)` | | For resources that use ash_postgres' polymorphism capabilities, you can provide a list of tables that should be available to select. These will be added to the list of derivable tables based on scanning all domains and resources provided to ash_admin. |
3434
| [`polymorphic_actions`](#admin-polymorphic_actions){: #admin-polymorphic_actions } | `list(atom)` | | For resources that use ash_postgres' polymorphism capabilities, you can provide a list of actions that should require a table to be set. If this is not set, then *all* actions will require tables. |
3535
| [`table_columns`](#admin-table_columns){: #admin-table_columns } | `list(atom)` | | The list of attributes to render on the table view. |
36+
| [`table_sortable_columns`](#admin-table_sortable_columns){: #admin-table_sortable_columns } | `list(atom)` | | The list of columns that can be sorted. If not specified, no columns are sortable. |
37+
| [`table_filterable_columns`](#admin-table_filterable_columns){: #admin-table_filterable_columns } | `list(atom)` | | The list of columns that can be filtered. If not specified, no columns are filterable. |
3638
| [`format_fields`](#admin-format_fields){: #admin-format_fields } | `list(any)` | | The list of fields and their formats represented as a MFA. For example: `updated_at: {Timex, :format!, ["{0D}-{0M}-{YYYY} {h12}:{m} {AM}"]}`. Datatable pages format all given fields. Show and Update pages format given read-only fields of types `Ash.Type.Date`, `Ash.Type.DateTime`, `Ash.Type.Time`, `Ash.Type.NaiveDatetime`, `Ash.Type.UtcDatetime` and `Ash.Type.UtcDatetimeUsec`. |
3739
| [`relationship_display_fields`](#admin-relationship_display_fields){: #admin-relationship_display_fields } | `list(atom)` | | The list of attributes to render when this resource is shown as a relationship on another resource's datatable. |
3840
| [`resource_group`](#admin-resource_group){: #admin-resource_group } | `atom` | | The group in the top resource dropdown that the resource appears in. |

0 commit comments

Comments
 (0)