Skip to content

Commit 1fea8aa

Browse files
committed
[admin] allow to update organization logo + other minor enhancements
1 parent d3e5413 commit 1fea8aa

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

app/admin/category.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
index do
33
id_column
44
column :name do |category|
5-
"#{tag.span(nil, class: "glyphicon glyphicon-#{category.icon_name}")} #{category.name}".html_safe
5+
"#{category_icon(category)} #{category.name}".html_safe
66
end
77
actions
88
end
@@ -15,7 +15,7 @@
1515
f.actions
1616
end
1717

18-
show do |cat|
18+
show title: -> (cat) { "#{category_icon(cat)} #{cat.name}".html_safe } do |cat|
1919
attributes_table do
2020
row :created_at
2121
row :updated_at

app/admin/organization.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
ActiveAdmin.register Organization do
22
index do
33
id_column
4-
column :name
4+
column :name do |organization|
5+
output = tag.p organization.name
6+
7+
if organization.logo.attached?
8+
output << image_tag(organization.logo.variant(resize: "40^x"))
9+
end
10+
11+
output.html_safe
12+
end
513
column :created_at do |organization|
614
l organization.created_at.to_date, format: :long
715
end
816
column :city
917
column :neighborhood
1018
column :email
1119
column :phone
20+
column :members do |organization|
21+
organization.members.count
22+
end
1223
actions
1324
end
1425

26+
show do
27+
div do
28+
if organization.logo.attached?
29+
image_tag(organization.logo.variant(resize: "100^x"))
30+
end
31+
end
32+
default_main_content
33+
end
34+
1535
form do |f|
1636
f.inputs do
1737
f.input :name
@@ -23,6 +43,7 @@
2343
f.input :address
2444
f.input :description
2545
f.input :public_opening_times
46+
f.input :logo, as: :file
2647
end
2748
f.actions
2849
end
@@ -47,5 +68,5 @@ def destroy
4768
filter :neighborhood
4869

4970
permit_params :name, :email, :web, :phone, :city, :neighborhood,
50-
:address, :description, :public_opening_times
71+
:address, :description, :public_opening_times, :logo
5172
end

app/admin/user.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
column :organizations do |u|
2424
u.organizations.map(&:to_s).join(", ")
2525
end
26+
column :posts do |u|
27+
u.posts.count
28+
end
2629
actions
2730
end
2831

0 commit comments

Comments
 (0)