Compare commits

..

5 Commits

Author SHA1 Message Date
4a5c09d819 add search to notes
Some checks are pending
continuous-integration/drone/push Build is pending
2022-11-19 00:03:13 -05:00
ec2fe32afe remove transition all on input 2022-11-19 00:03:13 -05:00
1703661af7 alias endpoint 2022-11-19 00:03:13 -05:00
8d8a556a07 display topbar when user is logged out 2022-11-19 00:03:13 -05:00
30260685e4 work on notes 2022-11-19 00:03:13 -05:00
2 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ defmodule Memex.Notes.Note do
""" """
use Ecto.Schema use Ecto.Schema
import Ecto.Changeset import Ecto.Changeset
alias Ecto.UUID alias Ecto.{Changeset, UUID}
alias Memex.{Accounts.User, Notes.Note} alias Memex.{Accounts.User, Notes.Note}
@primary_key {:id, :binary_id, autogenerate: true} @primary_key {:id, :binary_id, autogenerate: true}
@ -23,8 +23,10 @@ defmodule Memex.Notes.Note do
@type t :: %Note{} @type t :: %Note{}
@type id :: UUID.t() @type id :: UUID.t()
@type changeset :: Changeset.t(t())
@doc false @doc false
@spec create_changeset(attrs :: map(), User.t()) :: changeset()
def create_changeset(attrs, %User{id: user_id}) do def create_changeset(attrs, %User{id: user_id}) do
%Note{} %Note{}
|> cast(attrs, [:title, :content, :tags, :visibility]) |> cast(attrs, [:title, :content, :tags, :visibility])
@ -33,6 +35,7 @@ defmodule Memex.Notes.Note do
|> validate_required([:title, :content, :user_id, :visibility]) |> validate_required([:title, :content, :user_id, :visibility])
end end
@spec update_changeset(Note.t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = note, attrs, %User{id: user_id}) do def update_changeset(%{user_id: user_id} = note, attrs, %User{id: user_id}) do
note note
|> cast(attrs, [:title, :content, :tags, :visibility]) |> cast(attrs, [:title, :content, :tags, :visibility])

View File

@ -3,7 +3,7 @@ defmodule MemexWeb.NoteLive.Index do
alias Memex.{Notes, Notes.Note} alias Memex.{Notes, Notes.Note}
@impl true @impl true
def mount(params, _session, socket) do def mount(_params, _session, socket) do
{:ok, socket |> assign(search: nil) |> display_notes()} {:ok, socket |> assign(search: nil) |> display_notes()}
end end