Compare commits
5 Commits
f03037a943
...
4a5c09d819
Author | SHA1 | Date | |
---|---|---|---|
4a5c09d819 | |||
ec2fe32afe | |||
1703661af7 | |||
8d8a556a07 | |||
30260685e4 |
@ -4,7 +4,7 @@ defmodule Memex.Notes.Note do
|
||||
"""
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
alias Ecto.UUID
|
||||
alias Ecto.{Changeset, UUID}
|
||||
alias Memex.{Accounts.User, Notes.Note}
|
||||
|
||||
@primary_key {:id, :binary_id, autogenerate: true}
|
||||
@ -23,8 +23,10 @@ defmodule Memex.Notes.Note do
|
||||
|
||||
@type t :: %Note{}
|
||||
@type id :: UUID.t()
|
||||
@type changeset :: Changeset.t(t())
|
||||
|
||||
@doc false
|
||||
@spec create_changeset(attrs :: map(), User.t()) :: changeset()
|
||||
def create_changeset(attrs, %User{id: user_id}) do
|
||||
%Note{}
|
||||
|> cast(attrs, [:title, :content, :tags, :visibility])
|
||||
@ -33,6 +35,7 @@ defmodule Memex.Notes.Note do
|
||||
|> validate_required([:title, :content, :user_id, :visibility])
|
||||
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
|
||||
note
|
||||
|> cast(attrs, [:title, :content, :tags, :visibility])
|
||||
|
@ -3,7 +3,7 @@ defmodule MemexWeb.NoteLive.Index do
|
||||
alias Memex.{Notes, Notes.Note}
|
||||
|
||||
@impl true
|
||||
def mount(params, _session, socket) do
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket |> assign(search: nil) |> display_notes()}
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user