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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/enjoy/faq/admin/category.rb', line 4
def self.config(fields = {})
Proc.new {
navigation_label "FAQ"
list do
scopes [:sorted, :enabled, nil]
field :enabled, :toggle
field :name
field :questions do
read_only true
pretty_value do
bindings[:object].questions.to_a.map { |q|
route = bindings[:view] || bindings[:controller]
model_name = q.rails_admin_model
route.link_to(q.full_name, route.rails_admin.show_path(model_name: model_name, id: q.id), title: q.name)
}.join("<br>").html_safe
end
end
end
edit do
field :enabled, :toggle
field :name
group :URL do
active false
field :slugs, :enjoy_slugs
field :text_slug
end
group :content do
active false
field :excerpt, :enjoy_html
field :content, :enjoy_html
end
group :seo do
active false
field :seo do
active true
end
end
group :sitemap_data do
active false
field :sitemap_data do
active true
end
end
fields.each_pair do |name, type|
if type.nil?
field name
else
if type.is_a?(Array)
field name, type[0], &type[1]
else
field name, type
end
end
end
group :questions do
active false
field :questions do
read_only true
help 'Список вопросов'
pretty_value do
bindings[:object].questions.to_a.map { |q|
route = (bindings[:view] || bindings[:controller])
model_name = q.rails_admin_model
route.link_to(q.name, route.rails_admin.show_path(model_name: model_name, id: q.id), title: q.full_name)
}.join("<br>").html_safe
end
end
end
end
show do
field :name
field :slugs, :enjoy_slugs
field :text_slug
field :enabled
field :excerpt
field :content
fields.each_pair do |name, type|
if type.nil?
field name
else
if type.is_a?(Array)
field name, type[0], &type[1]
else
field name, type
end
end
end
field :questions do
read_only true
pretty_value do
bindings[:object].questions.to_a.map { |q|
route = (bindings[:view] || bindings[:controller])
model_name = q.rails_admin_model
route.link_to(i.full_name, route.rails_admin.show_path(model_name: model_name, id: q.id), title: q.name)
}.join("<br>").html_safe
end
end
end
nested_set({max_depth: 2, scopes: []})
if block_given?
yield self
end
}
end
|