diff --git a/.formatter.exs b/.formatter.exs index 2b73acd..cb2a852 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -10,6 +10,6 @@ :phoenix ], subdirectories: ["priv/*/migrations"], - plugins: [Spark.Formatter, Phoenix.LiveView.HTMLFormatter], + # plugins: [Spark.Formatter, Phoenix.LiveView.HTMLFormatter], # FIXME:seems broken inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] ] diff --git a/config/config.exs b/config/config.exs index bb6592b..c4857cf 100644 --- a/config/config.exs +++ b/config/config.exs @@ -47,7 +47,7 @@ config :spark, config :putzplan, ecto_repos: [Putzplan.Repo], generators: [timestamp_type: :utc_datetime], - ash_domains: [Putzplan.Accounts] + ash_domains: [Putzplan.Accounts, Putzplan.Tasks] # Configures the endpoint config :putzplan, PutzplanWeb.Endpoint, diff --git a/flake.nix b/flake.nix index f123b83..b11a8f6 100644 --- a/flake.nix +++ b/flake.nix @@ -16,6 +16,9 @@ buildInputs = with pkgs; [ erlang_25 beam.packages.erlang_25.elixir_1_18 + lexical + beam.packages.erlang_25.elixir-ls + next-ls ] ++ lib.optionals stdenv.isLinux [ # For ExUnit Notifier on Linux. @@ -46,7 +49,7 @@ export PATH=$HEX_HOME/bin:$PATH # enables history for IEx - export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.erlang-history\"'" + export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.nix/erlang-history\"'" ''; }; } diff --git a/lib/putzplan/tasks.ex b/lib/putzplan/tasks.ex new file mode 100644 index 0000000..7d79493 --- /dev/null +++ b/lib/putzplan/tasks.ex @@ -0,0 +1,7 @@ +defmodule Putzplan.Tasks do + use Ash.Domain + + resources do + resource Putzplan.Tasks.Definition + end +end diff --git a/lib/putzplan/tasks/definition.ex b/lib/putzplan/tasks/definition.ex new file mode 100644 index 0000000..1a11202 --- /dev/null +++ b/lib/putzplan/tasks/definition.ex @@ -0,0 +1,31 @@ +defmodule Putzplan.Tasks.Definition do + # This turns this module into a resource + use Ash.Resource, domain: Putzplan.Tasks + + actions do + # Use the default implementation of the :read action + defaults [:read] + + # and a create action, which we'll customize later + create :create do + accept [:description, :repetition_days] + end + end + + # Attributes are the simple pieces of data that exist on your resource + attributes do + # Add an autogenerated UUID primary key called `:id`. + uuid_primary_key :id + + attribute :description, :string do + allow_nil? false + public? true + end + + attribute :repetition_days, :integer do + allow_nil? false + public? true + constraints min: 1 + end + end +end diff --git a/priv/repo/migrations/20250403101322_initialize_and_add_authentication_resources.exs b/priv/repo/migrations/20250403101322_initialize_and_add_authentication_resources.exs index 6698f24..6885785 100644 --- a/priv/repo/migrations/20250403101322_initialize_and_add_authentication_resources.exs +++ b/priv/repo/migrations/20250403101322_initialize_and_add_authentication_resources.exs @@ -28,4 +28,4 @@ defmodule Putzplan.Repo.Migrations.InitializeAndAddAuthenticationResources do drop table(:users) end -end \ No newline at end of file +end