commit
d19cf2468d
5 changed files with 24 additions and 7 deletions
|
@ -9,6 +9,7 @@ defmodule Chiya.Channels.Channel do
|
|||
field :name, :string
|
||||
field :slug, ChannelSlug.Type
|
||||
field :visibility, Ecto.Enum, values: [:public, :private, :unlisted]
|
||||
field :layout, Ecto.Enum, values: [:default, :gallery]
|
||||
|
||||
many_to_many :notes, Chiya.Notes.Note,
|
||||
join_through: "channels_notes",
|
||||
|
@ -20,10 +21,10 @@ defmodule Chiya.Channels.Channel do
|
|||
@doc false
|
||||
def changeset(channel, attrs) do
|
||||
channel
|
||||
|> cast(attrs, [:name, :content, :visibility, :slug])
|
||||
|> cast(attrs, [:name, :content, :visibility, :slug, :layout])
|
||||
|> ChannelSlug.maybe_generate_slug()
|
||||
|> ChannelSlug.unique_constraint()
|
||||
|> validate_required([:name, :content, :visibility, :slug])
|
||||
|> validate_required([:name, :content, :visibility, :slug, :layout])
|
||||
|> validate_exclusion(:slug, ~w(admin user dev))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -107,7 +107,7 @@ defmodule ChiyaWeb.AdminComponents do
|
|||
href={~p"/admin"}
|
||||
class="text-xs leading-6 text-gray-900 dark:text-gray-100 font-semibold dark:hover:text-gray-300 hover:text-gray-700"
|
||||
>
|
||||
Admin
|
||||
<.icon name="hero-star-mini" class="w-4 h-4" /> Admin
|
||||
</.link>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -5,25 +5,25 @@
|
|||
href={~p"/admin/notes"}
|
||||
class="text-xs font-semibold leading-6 text-gray-900 hover:text-gray-700 dark:text-gray-200"
|
||||
>
|
||||
Notes
|
||||
<.icon name="hero-document-text" class="w-4 h-4" /> Notes
|
||||
</.link>
|
||||
<.link
|
||||
href={~p"/admin/channels"}
|
||||
class="text-xs font-semibold leading-6 text-gray-900 hover:text-gray-700 dark:text-gray-200"
|
||||
>
|
||||
Channels
|
||||
<.icon name="hero-speaker-wave" class="w-4 h-4" /> Channels
|
||||
</.link>
|
||||
<.link
|
||||
href={~p"/admin/identities"}
|
||||
class="text-xs font-semibold leading-6 text-gray-900 hover:text-gray-700 dark:text-gray-200"
|
||||
>
|
||||
Identities
|
||||
<.icon name="hero-user" class="w-4 h-4" /> Identities
|
||||
</.link>
|
||||
<.link
|
||||
href={~p"/admin/settings"}
|
||||
class="text-xs font-semibold leading-6 text-gray-900 hover:text-gray-700 dark:text-gray-200"
|
||||
>
|
||||
Settings
|
||||
<.icon name="hero-wrench-screwdriver" class="w-4 h-4" /> Settings
|
||||
</.link>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,6 +11,13 @@
|
|||
prompt="Choose a value"
|
||||
options={Ecto.Enum.values(Chiya.Channels.Channel, :visibility)}
|
||||
/>
|
||||
<.input
|
||||
field={f[:layout]}
|
||||
type="select"
|
||||
label="Layout"
|
||||
prompt="Choose a value"
|
||||
options={Ecto.Enum.values(Chiya.Channels.Channel, :layout)}
|
||||
/>
|
||||
<.input field={f[:slug]} type="text" label="Slug" />
|
||||
<:actions>
|
||||
<.button>Save Channel</.button>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Chiya.Repo.Migrations.AddLayoutToChannel do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:channels) do
|
||||
add :layout, :string, default: "default"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue