From 0bf93b49450759536ea8e70f1a57f865e2a25ee7 Mon Sep 17 00:00:00 2001 From: shibao Date: Fri, 10 Sep 2021 00:41:06 -0400 Subject: [PATCH] fix tag field names --- lib/cannery/tags/tag.ex | 8 ++++---- .../live/tag_live/form_component.html.leex | 16 ++++++++-------- .../migrations/20210903015442_create_tags.exs | 4 ++-- test/cannery/tags_test.exs | 6 +++--- test/cannery_web/live/tag_live_test.exs | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/cannery/tags/tag.ex b/lib/cannery/tags/tag.ex index 66e5865e..521ca2fe 100644 --- a/lib/cannery/tags/tag.ex +++ b/lib/cannery/tags/tag.ex @@ -5,9 +5,9 @@ defmodule Cannery.Tags.Tag do @primary_key {:id, :binary_id, autogenerate: true} @foreign_key_type :binary_id schema "tags" do - field :"bg-color", :string + field :bg_color, :string field :name, :string - field :"text-color", :string + field :text_color, :string field :user_id, :binary_id timestamps() @@ -16,7 +16,7 @@ defmodule Cannery.Tags.Tag do @doc false def changeset(tag, attrs) do tag - |> cast(attrs, [:name, :"bg-color", :"text-color"]) - |> validate_required([:name, :"bg-color", :"text-color"]) + |> cast(attrs, [:name, :bg_color, :text_color]) + |> validate_required([:name, :bg_color, :text_color]) end end diff --git a/lib/cannery_web/live/tag_live/form_component.html.leex b/lib/cannery_web/live/tag_live/form_component.html.leex index d9329407..ae331c60 100644 --- a/lib/cannery_web/live/tag_live/form_component.html.leex +++ b/lib/cannery_web/live/tag_live/form_component.html.leex @@ -6,17 +6,17 @@ phx_change: "validate", phx_submit: "save" %> - <%= label f, :name %> - <%= text_input f, :name %> + <%= label f, :name, class: "title text-lg text-primary-500" %> + <%= text_input f, :name, class: "input input-primary" %> <%= error_tag f, :name %> - <%= label f, :"bg-color" %> - <%= text_input f, :"bg-color" %> - <%= error_tag f, :"bg-color" %> + <%= label f, :bg_color, class: "title text-lg text-primary-500" %> + <%= text_input f, :bg_color %> + <%= error_tag f, :bg_color %> - <%= label f, :"text-color" %> - <%= text_input f, :"text-color" %> - <%= error_tag f, :"text-color" %> + <%= label f, :text_color, class: "title text-lg text-primary-500" %> + <%= text_input f, :text_color %> + <%= error_tag f, :text_color %> <%= submit "Save", phx_disable_with: "Saving..." %> diff --git a/priv/repo/migrations/20210903015442_create_tags.exs b/priv/repo/migrations/20210903015442_create_tags.exs index c1c1bc59..2c492b0d 100644 --- a/priv/repo/migrations/20210903015442_create_tags.exs +++ b/priv/repo/migrations/20210903015442_create_tags.exs @@ -5,8 +5,8 @@ defmodule Cannery.Repo.Migrations.CreateTags do create table(:tags, primary_key: false) do add :id, :binary_id, primary_key: true add :name, :string - add :"bg-color", :string - add :"text-color", :string + add :bg_color, :string + add :text_color, :string add :user_id, references(:users, on_delete: :nothing, type: :binary_id) timestamps() diff --git a/test/cannery/tags_test.exs b/test/cannery/tags_test.exs index fca21f1b..1dac60a9 100644 --- a/test/cannery/tags_test.exs +++ b/test/cannery/tags_test.exs @@ -6,9 +6,9 @@ defmodule Cannery.TagsTest do describe "tags" do alias Cannery.Tags.Tag - @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"} - @invalid_attrs %{"bg-color": nil, name: nil, "text-color": nil} + @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"} + @invalid_attrs %{bg_color: nil, name: nil, text_color: nil} def tag_fixture(attrs \\ %{}) do {:ok, tag} = diff --git a/test/cannery_web/live/tag_live_test.exs b/test/cannery_web/live/tag_live_test.exs index 73245577..4a4e7f2a 100644 --- a/test/cannery_web/live/tag_live_test.exs +++ b/test/cannery_web/live/tag_live_test.exs @@ -5,9 +5,9 @@ defmodule CanneryWeb.TagLiveTest do alias Cannery.Tags - @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"} - @invalid_attrs %{"bg-color": nil, name: nil, "text-color": nil} + @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"} + @invalid_attrs %{bg_color: nil, name: nil, text_color: nil} defp fixture(:tag) do {:ok, tag} = Tags.create_tag(@create_attrs)