fix tag field names
This commit is contained in:
parent
3cdd7729a6
commit
0bf93b4945
@ -5,9 +5,9 @@ defmodule Cannery.Tags.Tag do
|
|||||||
@primary_key {:id, :binary_id, autogenerate: true}
|
@primary_key {:id, :binary_id, autogenerate: true}
|
||||||
@foreign_key_type :binary_id
|
@foreign_key_type :binary_id
|
||||||
schema "tags" do
|
schema "tags" do
|
||||||
field :"bg-color", :string
|
field :bg_color, :string
|
||||||
field :name, :string
|
field :name, :string
|
||||||
field :"text-color", :string
|
field :text_color, :string
|
||||||
field :user_id, :binary_id
|
field :user_id, :binary_id
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
@ -16,7 +16,7 @@ defmodule Cannery.Tags.Tag do
|
|||||||
@doc false
|
@doc false
|
||||||
def changeset(tag, attrs) do
|
def changeset(tag, attrs) do
|
||||||
tag
|
tag
|
||||||
|> cast(attrs, [:name, :"bg-color", :"text-color"])
|
|> cast(attrs, [:name, :bg_color, :text_color])
|
||||||
|> validate_required([:name, :"bg-color", :"text-color"])
|
|> validate_required([:name, :bg_color, :text_color])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,17 +6,17 @@
|
|||||||
phx_change: "validate",
|
phx_change: "validate",
|
||||||
phx_submit: "save" %>
|
phx_submit: "save" %>
|
||||||
|
|
||||||
<%= label f, :name %>
|
<%= label f, :name, class: "title text-lg text-primary-500" %>
|
||||||
<%= text_input f, :name %>
|
<%= text_input f, :name, class: "input input-primary" %>
|
||||||
<%= error_tag f, :name %>
|
<%= error_tag f, :name %>
|
||||||
|
|
||||||
<%= label f, :"bg-color" %>
|
<%= label f, :bg_color, class: "title text-lg text-primary-500" %>
|
||||||
<%= text_input f, :"bg-color" %>
|
<%= text_input f, :bg_color %>
|
||||||
<%= error_tag f, :"bg-color" %>
|
<%= error_tag f, :bg_color %>
|
||||||
|
|
||||||
<%= label f, :"text-color" %>
|
<%= label f, :text_color, class: "title text-lg text-primary-500" %>
|
||||||
<%= text_input f, :"text-color" %>
|
<%= text_input f, :text_color %>
|
||||||
<%= error_tag f, :"text-color" %>
|
<%= error_tag f, :text_color %>
|
||||||
|
|
||||||
<%= submit "Save", phx_disable_with: "Saving..." %>
|
<%= submit "Save", phx_disable_with: "Saving..." %>
|
||||||
</form>
|
</form>
|
||||||
|
@ -5,8 +5,8 @@ defmodule Cannery.Repo.Migrations.CreateTags do
|
|||||||
create table(:tags, primary_key: false) do
|
create table(:tags, primary_key: false) do
|
||||||
add :id, :binary_id, primary_key: true
|
add :id, :binary_id, primary_key: true
|
||||||
add :name, :string
|
add :name, :string
|
||||||
add :"bg-color", :string
|
add :bg_color, :string
|
||||||
add :"text-color", :string
|
add :text_color, :string
|
||||||
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
|
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
|
@ -6,9 +6,9 @@ defmodule Cannery.TagsTest do
|
|||||||
describe "tags" do
|
describe "tags" do
|
||||||
alias Cannery.Tags.Tag
|
alias Cannery.Tags.Tag
|
||||||
|
|
||||||
@valid_attrs %{"bg-color": "some bg-color", name: "some name", "text-color": "some text-color"}
|
@valid_attrs %{bg_color: "some bg-color", name: "some name", text_color: "some text-color"}
|
||||||
@update_attrs %{"bg-color": "some updated bg-color", name: "some updated name", "text-color": "some updated text-color"}
|
@update_attrs %{bg_color: "some updated bg-color", name: "some updated name", text_color: "some updated text-color"}
|
||||||
@invalid_attrs %{"bg-color": nil, name: nil, "text-color": nil}
|
@invalid_attrs %{bg_color: nil, name: nil, text_color: nil}
|
||||||
|
|
||||||
def tag_fixture(attrs \\ %{}) do
|
def tag_fixture(attrs \\ %{}) do
|
||||||
{:ok, tag} =
|
{:ok, tag} =
|
||||||
|
@ -5,9 +5,9 @@ defmodule CanneryWeb.TagLiveTest do
|
|||||||
|
|
||||||
alias Cannery.Tags
|
alias Cannery.Tags
|
||||||
|
|
||||||
@create_attrs %{"bg-color": "some bg-color", name: "some name", "text-color": "some text-color"}
|
@create_attrs %{bg_color: "some bg-color", name: "some name", text_color: "some text-color"}
|
||||||
@update_attrs %{"bg-color": "some updated bg-color", name: "some updated name", "text-color": "some updated text-color"}
|
@update_attrs %{bg_color: "some updated bg-color", name: "some updated name", text_color: "some updated text-color"}
|
||||||
@invalid_attrs %{"bg-color": nil, name: nil, "text-color": nil}
|
@invalid_attrs %{bg_color: nil, name: nil, text_color: nil}
|
||||||
|
|
||||||
defp fixture(:tag) do
|
defp fixture(:tag) do
|
||||||
{:ok, tag} = Tags.create_tag(@create_attrs)
|
{:ok, tag} = Tags.create_tag(@create_attrs)
|
||||||
|
Loading…
Reference in New Issue
Block a user