show channel visibility on note form and channel index, show note count on channel index
This commit is contained in:
parent
3e549944b9
commit
45100ac98d
4 changed files with 15 additions and 3 deletions
|
@ -27,4 +27,12 @@ defmodule Chiya.Channels.Channel do
|
|||
|> validate_required([:name, :content, :visibility, :slug, :layout])
|
||||
|> validate_exclusion(:slug, ~w(admin user dev))
|
||||
end
|
||||
|
||||
def icon(%Chiya.Channels.Channel{visibility: vis}) do
|
||||
case(vis) do
|
||||
:public -> "🌍"
|
||||
:private -> "🔒"
|
||||
:unlisted -> "👁️"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ defmodule ChiyaWeb.ChannelController do
|
|||
alias Chiya.Channels.Channel
|
||||
|
||||
def index(conn, _params) do
|
||||
channels = Channels.list_channels()
|
||||
channels = Channels.list_channels() |> Channels.preload_channel()
|
||||
render(conn, :index, channels: channels)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
<.table id="channels" rows={@channels} row_click={&JS.navigate(~p"/admin/channels/#{&1}")}>
|
||||
<:col :let={channel} label="Name"><%= channel.name %></:col>
|
||||
<:col :let={channel} label="Visibility"><%= channel.visibility %></:col>
|
||||
<:col :let={channel} label="Visibility"><%= Chiya.Channels.Channel.icon(channel) %> <%= channel.visibility %></:col>
|
||||
<:col :let={channel} label="Notes"><%= Enum.count(channel.notes) %></:col>
|
||||
<:col :let={channel} label="Slug"><%= channel.slug %></:col>
|
||||
<:action :let={channel}>
|
||||
<div class="sr-only">
|
||||
|
|
|
@ -147,5 +147,8 @@ defmodule ChiyaWeb.NoteController do
|
|||
end
|
||||
|
||||
defp to_channel_options(items \\ nil),
|
||||
do: Enum.map(items || Chiya.Channels.list_channels(), fn c -> {c.name, c.id} end)
|
||||
do:
|
||||
Enum.map(items || Chiya.Channels.list_channels(), fn c ->
|
||||
{Chiya.Channels.Channel.icon(c) <> " " <> c.name, c.id}
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue