Skip to content

Commit

Permalink
beginnings of factorying some data, also css
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Nelson committed Aug 6, 2024
1 parent e870495 commit 760dbab
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 2 deletions.
14 changes: 14 additions & 0 deletions test_bed/assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,18 @@
@import "tailwindcss/components";
@import "tailwindcss/utilities";

th[aria-sort="desc"] button::after {
content: "▼";
color: currentcolor;
font-size: 100%;
top: 0;
}

th[aria-sort="asc"] button::after {
content: "▲";
color: currentcolor;
font-size: 100%;
top: 0;
}

/* This file is for your main application CSS */
1 change: 1 addition & 0 deletions test_bed/lib/test_bed/blog/author.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defmodule TestBed.Blog.Author do
defaults([:read, :destroy])

create :create do
primary? true
# accept title as input
accept([:name])
end
Expand Down
5 changes: 5 additions & 0 deletions test_bed/lib/test_bed/blog/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ defmodule TestBed.Blog.Post do
defaults([:read, :destroy])

create :create do

# accept title as input
accept([:title, :author_id])

argument :author, :map

change manage_relationship(:author, type: :create)
end

update :update do
Expand Down
9 changes: 9 additions & 0 deletions test_bed/lib/test_bed/factory.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule TestBed.Factory do
use Smokestack

alias TestBed.Blog.Post

factory Post do
attribute :title, &Faker.Lorem.sentence/1
end
end
7 changes: 5 additions & 2 deletions test_bed/lib/test_bed_web/live/posts_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ defmodule TestBedWeb.PostsLive.Index do

def render(assigns) do
~H"""
<.live_component id="posts_table" limit={10} offset={0} sort={{"id", :asc}} module={AshTable.Table} query={TestBed.Blog.Post}>
<.live_component module={AshTable.Table}
id="posts_table"
limit={10} offset={0}
sort={{"id", :asc}}
query={TestBed.Blog.Post}>
<:col :let={post} label="Id"><%= post.id %></:col>
<:col :let={post} label="Title" sort_key="title">
<%= post.title %>
Expand All @@ -20,5 +24,4 @@ defmodule TestBedWeb.PostsLive.Index do
defp sort_by_author(query, direction) do
Ash.Query.sort(query, {Ash.Sort.expr_sort(author.name), direction})
end

end
2 changes: 2 additions & 0 deletions test_bed/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ defmodule TestBed.MixProject do
{:ash_phoenix, "~> 2.0"},
{:ash_authentication, "~> 4.0"},
{:ash_authentication_phoenix, "~> 2.0"},
{:smokestack, "~> 0.6.1-rc.2"},
{:faker, ">= 0.0.0"},
{:ash_table, path: ".."}
]
end
Expand Down
3 changes: 3 additions & 0 deletions test_bed/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"},
"ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"},
"expo": {:hex, :expo, "0.5.2", "beba786aab8e3c5431813d7a44b828e7b922bfa431d6bfbada0904535342efe2", [:mix], [], "hexpm", "8c9bfa06ca017c9cb4020fabe980bc7fdb1aaec059fd004c2ab3bff03b1c599c"},
"faker": {:hex, :faker, "0.18.0", "943e479319a22ea4e8e39e8e076b81c02827d9302f3d32726c5bf82f430e6e14", [:mix], [], "hexpm", "bfbdd83958d78e2788e99ec9317c4816e651ad05e24cfd1196ce5db5b3e81797"},
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"finch": {:hex, :finch, "0.18.0", "944ac7d34d0bd2ac8998f79f7a811b21d87d911e77a786bc5810adb75632ada4", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "69f5045b042e531e53edc2574f15e25e735b522c37e2ddb766e15b979e03aa65"},
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
Expand Down Expand Up @@ -57,9 +58,11 @@
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"postgrex": {:hex, :postgrex, "0.18.0", "f34664101eaca11ff24481ed4c378492fed2ff416cd9b06c399e90f321867d7e", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "a042989ba1bc1cca7383ebb9e461398e3f89f868c92ce6671feb7ef132a252d1"},
"reactor": {:hex, :reactor, "0.8.4", "344d02ba4a0010763851f4e4aa0ff190ebe7e392e3c27c6cd143dde077b986e7", [:mix], [{:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "49c1fd3c786603cec8140ce941c41c7ea72cc4411860ccdee9876c4ca2204f81"},
"recase": {:hex, :recase, "0.8.1", "ab98cd35857a86fa5ca99036f575241d71d77d9c2ab0c39aacf1c9b61f6f7d1d", [:mix], [], "hexpm", "9fd8d63e7e43bd9ea385b12364e305778b2bbd92537e95c4b2e26fc507d5e4c2"},
"req": {:hex, :req, "0.5.1", "90584216d064389a4ff2d4279fe2c11ff6c812ab00fa01a9fb9d15457f65ba70", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "7ea96a1a95388eb0fefa92d89466cdfedba24032794e5c1147d78ec90db7edca"},
"rewrite": {:hex, :rewrite, "0.10.5", "6afadeae0b9d843b27ac6225e88e165884875e0aed333ef4ad3bf36f9c101bed", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "51cc347a4269ad3a1e7a2c4122dbac9198302b082f5615964358b4635ebf3d4f"},
"slugify": {:hex, :slugify, "1.3.1", "0d3b8b7e5c1eeaa960e44dce94382bee34a39b3ea239293e457a9c5b47cc6fd3", [:mix], [], "hexpm", "cb090bbeb056b312da3125e681d98933a360a70d327820e4b7f91645c4d8be76"},
"smokestack": {:hex, :smokestack, "0.6.2", "0bd5bb477e1d6ca3aaae46641912d9f2bbb5663d3975a4b9c9fa6d082941c64e", [:mix], [{:ash, "~> 3.0", [hex: :ash, repo: "hexpm", optional: false]}, {:recase, "~> 0.7", [hex: :recase, repo: "hexpm", optional: false]}, {:spark, "~> 2.1", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "1499bcf570dbc120c6a16ca3e32d857aabe2270180c2b7e76de6543f61d05c40"},
"sourceror": {:hex, :sourceror, "1.4.0", "be87319b1579191e25464005d465713079b3fd7124a3938a1e6cf4def39735a9", [:mix], [], "hexpm", "16751ca55e3895f2228938b703ad399b0b27acfe288eff6c0e629ed3e6ec0358"},
"spark": {:hex, :spark, "2.2.6", "4f160462f45c0be2bccdc4700e7ffc6b2e97b4e38f57eed2349bc9dab4aaa66c", [:mix], [{:igniter, "~> 0.2", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.2", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "1e0e012978be808232a502a116d4b99b5059ab3760453438b155ac048f82ce20"},
"spitfire": {:hex, :spitfire, "0.1.3", "7ea0f544005dfbe48e615ed90250c9a271bfe126914012023fd5e4b6b82b7ec7", [:mix], [], "hexpm", "d53b5107bcff526a05c5bb54c95e77b36834550affd5830c9f58760e8c543657"},
Expand Down
5 changes: 5 additions & 0 deletions test_bed/priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.

alias TestBed.Blog
for i <- 0..30 do
Blog.create_post(%{title: Faker.Lorem.sentence(3), author: %{name: Faker.Person.name()}})
end

0 comments on commit 760dbab

Please sign in to comment.