{"id":25522289,"url":"https://github.com/launchscout/ash_table","last_synced_at":"2025-04-11T01:32:21.750Z","repository":{"id":246693571,"uuid":"821865803","full_name":"launchscout/ash_table","owner":"launchscout","description":"A sortable paginated table component for Ash resources","archived":false,"fork":false,"pushed_at":"2024-08-06T18:48:13.000Z","size":71,"stargazers_count":35,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-20T05:41:45.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchscout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-29T16:59:07.000Z","updated_at":"2025-02-13T06:35:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"c718c61d-a398-4a90-bf89-28f825019b81","html_url":"https://github.com/launchscout/ash_table","commit_stats":null,"previous_names":["launchscout/ash_table"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fash_table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fash_table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fash_table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fash_table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchscout","download_url":"https://codeload.github.com/launchscout/ash_table/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248325102,"owners_count":21084867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-19T18:19:15.065Z","updated_at":"2025-04-11T01:32:21.731Z","avatar_url":"https://github.com/launchscout.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AshTable\n\nThis is a sortable, paginated table component for Ash resources or queries\n\n## Status\n\n- [X] Sort by attribute\n- [X] Sort by relation (using function passed to column)\n- [X] Pagination\n\n## Usage\n\nHere's an example taken from the test_bed:\n\n```elixir\ndefmodule TestBedWeb.PostsLive.Index do\n  use TestBedWeb, :live_view\n\n  def render(assigns) do\n    ~H\"\"\"\n    \u003c.live_component id=\"posts_table\" limit={10} offset={0} sort={{\"id\", :asc}} module={AshTable.Table} query={TestBed.Blog.Post}\u003e\n      \u003c:col :let={post} label=\"Id\" sort_key=\"id\"\u003e\u003c%= post.id %\u003e\u003c/:col\u003e\n      \u003c:col :let={post} label=\"Title\" sort_key=\"title\"\u003e\n        \u003c%= post.title %\u003e\n      \u003c/:col\u003e\n      \u003c:col :let={post} label=\"Author\" apply_sort={\u0026sort_by_author/2} sort_key=\"author.name\"\u003e\n        \u003c%= if post.author, do: post.author.name %\u003e\n      \u003c/:col\u003e\n    \u003c/.live_component\u003e\n    \"\"\"\n  end\n\n  require Ash.Sort\n\n  defp sort_by_author(query, direction) do\n    Ash.Query.sort(query, {Ash.Sort.expr_sort(author.name), direction})\n  end\n\nend\n```\n\nIn this case the `TestBed.Blog.Post` resource has a title, content, and belongs to Author which has a name. The table is paginated, and sortable by Title and Author name. \n\nNote use of the `apply_sort` being passed into the `:col`. This is needed for sorting by related properties due to how Ash works, or til I better understand it and find a simpler way :) The `sort_key` assign is still required so that the correct column is identified when the sort event fires.\n\n## Running the test_bed example project\n\n```\ncd test_bed\nmix deps.get\nmix ash.setup\nmix phx.server\n```\n\n## Future\n\nCurrently there is very little styling. The goal would be to allow a good default, but great flexiblity. Harcoding a dependency on Tailwind or other css frameworks is not desirable, but allowing the user to decide to use one would be great.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchscout%2Fash_table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchscout%2Fash_table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchscout%2Fash_table/lists"}