Compare commits
5 Commits
4a5c09d819
...
f03037a943
Author | SHA1 | Date | |
---|---|---|---|
f03037a943 | |||
282d2b7664 | |||
3dbbb7e21c | |||
b641e96601 | |||
e0f0e39326 |
@ -4,7 +4,7 @@ defmodule Memex.Notes.Note do
|
|||||||
"""
|
"""
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
alias Ecto.{Changeset, UUID}
|
alias Ecto.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,10 +23,8 @@ 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])
|
||||||
@ -35,7 +33,6 @@ 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])
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user