-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from daveminer/daisy-ui
Daisy UI
- Loading branch information
Showing
41 changed files
with
683 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
[ | ||
import_deps: [:ecto, :ecto_sql, :phoenix, :surface], | ||
import_deps: [:ecto, :ecto_sql, :phoenix], | ||
subdirectories: ["priv/*/migrations"], | ||
plugins: [Phoenix.LiveView.HTMLFormatter, Surface.Formatter.Plugin], | ||
plugins: [Phoenix.LiveView.HTMLFormatter], | ||
inputs: [ | ||
"*.{heex,ex,exs}", | ||
"{config,lib,test}/**/*.{heex,ex,exs}", | ||
"priv/*/seeds.exs", | ||
"{lib,test}/**/*.sface" | ||
"priv/*/seeds.exs" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,7 @@ npm-debug.log | |
|
||
# Ignore generated CSS file for components | ||
assets/css/_components.css | ||
|
||
# Editor config | ||
.vscode/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"daisyui": "^4.12.10" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Basket.Club do | ||
@moduledoc false | ||
|
||
use Ecto.Schema | ||
|
||
@type t :: %__MODULE__{} | ||
|
||
schema "clubs" do | ||
many_to_many :users, Basket.User, join_through: "club_members" | ||
|
||
timestamps() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
defmodule Basket.ClubTicker do | ||
@moduledoc """ | ||
These tickers belong to a club; every club member can view the club's | ||
portfolio. | ||
""" | ||
|
||
use Ecto.Schema | ||
|
||
import Ecto.{Changeset, Query} | ||
|
||
alias Basket.{Club, Repo} | ||
|
||
@type t :: %__MODULE__{} | ||
|
||
schema "club_tickers" do | ||
field :ticker, :string | ||
belongs_to :club, Club | ||
|
||
timestamps() | ||
end | ||
|
||
@doc false | ||
def changeset(ticker_or_changeset, attrs) do | ||
ticker_or_changeset | ||
|> Ecto.Changeset.change() | ||
|> cast(attrs, [:ticker, :user_id]) | ||
|> validate_required([:ticker, :user_id]) | ||
|> unique_constraint([:ticker, :user_id]) | ||
end | ||
|
||
@spec add!(club :: Club.t(), ticker: String.t()) :: __MODULE__.t() | ||
def add!(club, ticker) do | ||
ticker = %__MODULE__{ticker: ticker, club_id: club.id} | ||
Repo.insert!(ticker) | ||
end | ||
|
||
@spec for_club(user :: Club.t()) :: [Basket.Ticker.t()] | ||
def for_club(nil), do: [] | ||
|
||
def for_club(club) do | ||
from(t in __MODULE__, | ||
where: t.club_id == ^club.id | ||
) | ||
|> Repo.all() | ||
end | ||
|
||
@spec remove(club :: Club.t(), ticker: String.t()) :: {non_neg_integer(), nil | [term()]} | ||
def remove(club, ticker) do | ||
from(t in __MODULE__, | ||
where: t.club_id == ^club.id and t.ticker == ^ticker | ||
) | ||
|> Repo.delete_all() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
defmodule Basket.User do | ||
@moduledoc false | ||
|
||
use Ecto.Schema | ||
use Pow.Ecto.Schema | ||
|
||
use Pow.Extension.Ecto.Schema, | ||
extensions: [PowResetPassword, PowEmailConfirmation] | ||
|
||
alias Basket.Repo | ||
|
||
@type t :: %__MODULE__{} | ||
|
||
def changeset(user_or_changeset, attrs) do | ||
user_or_changeset | ||
|> pow_changeset(attrs) | ||
|> pow_extension_changeset(attrs) | ||
end | ||
|
||
def toggle_club_view!(user, value) when value in ["club", "individual"] do | ||
updated_settings = Map.put(user.settings, "ticker_view_toggle", value) | ||
changeset = Ecto.Changeset.change(user, settings: updated_settings) | ||
Repo.update!(changeset) | ||
end | ||
|
||
schema "users" do | ||
many_to_many :clubs, Basket.Club, join_through: "club_members" | ||
|
||
many_to_many :offices, Basket.Club, join_through: "club_officers" | ||
|
||
field :settings, :map | ||
|
||
pow_user_fields() | ||
|
||
timestamps() | ||
end | ||
end |
Oops, something went wrong.