1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require "pro_tacts/admin/phlex"
module ProTacts
module Admin
# A group's name wherever one is shown. A group needs no name
# (db/migrations/005_group_identity.rb), and one without is shown by
# its id, marked `data-nameless` so admin.css can set it as an
# identifier rather than let it pass for a name.
class GroupLabel < Phlex::HTML
# @rbs @group: Group | Store::GroupChoice
# A Group or the lighter GroupChoice a picker carries: this reads
# only the name and the id, which both hold.
#: (group: Group | Store::GroupChoice) -> void
def initialize(group:)
@group = group
end
def view_template
name = @group.name
if name
plain name
else
span(data: {nameless: true}) { @group.id }
end
end
end
end
end