rails_admin_cms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +36 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/javascripts/rails_admin_cms/all.js.coffee +2 -0
  6. data/app/assets/javascripts/rails_admin_cms/cms.js.coffee +18 -0
  7. data/app/assets/javascripts/rails_admin_cms/cms/flashes.js.coffee +2 -0
  8. data/app/assets/javascripts/rails_admin_cms/cms/with_scope/forms.js.coffee +4 -0
  9. data/app/assets/javascripts/rails_admin_cms/cms/with_scope/viewables.js.coffee +14 -0
  10. data/app/assets/stylesheets/rails_admin_cms/all.css.sass +0 -0
  11. data/app/controllers/cms/attachments_controller.rb +20 -0
  12. data/app/controllers/cms/files_controller.rb +19 -0
  13. data/app/controllers/cms/forms_controller.rb +89 -0
  14. data/app/controllers/cms/pages_controller.rb +13 -0
  15. data/app/controllers/cms/viewables_controller.rb +49 -0
  16. data/app/controllers/concerns/cms/editing.rb +21 -0
  17. data/app/controllers/concerns/cms/localize.rb +15 -0
  18. data/app/helpers/cms/cache_helper.rb +26 -0
  19. data/app/helpers/cms/form_helper.rb +67 -0
  20. data/app/helpers/cms/locale_helper.rb +34 -0
  21. data/app/helpers/cms/view_helper.rb +37 -0
  22. data/app/helpers/cms/viewable_helper.rb +155 -0
  23. data/app/helpers/rails_admin/form_builder_decorator.rb +11 -0
  24. data/app/helpers/rails_admin/navigation_helper.rb +77 -0
  25. data/app/mailers/cms/forms_mailer.rb +48 -0
  26. data/app/models/admin/form/email.rb +41 -0
  27. data/app/models/admin/form/field.rb +25 -0
  28. data/app/models/admin/form/row.rb +36 -0
  29. data/app/models/admin/form/static/object.rb +15 -0
  30. data/app/models/admin/form/structure.rb +18 -0
  31. data/app/models/admin/setting.rb +21 -0
  32. data/app/models/admin/unique_key.rb +15 -0
  33. data/app/models/admin/viewable/block.rb +25 -0
  34. data/app/models/admin/viewable/form.rb +36 -0
  35. data/app/models/admin/viewable/image.rb +18 -0
  36. data/app/models/admin/viewable/link.rb +21 -0
  37. data/app/models/admin/viewable/page.rb +27 -0
  38. data/app/models/admin/viewable/select.rb +15 -0
  39. data/app/models/admin/viewable/text.rb +16 -0
  40. data/app/models/callbacks/form/field_after_create.rb +16 -0
  41. data/app/models/callbacks/form/field_after_destroy.rb +16 -0
  42. data/app/models/callbacks/form/field_before_update.rb +29 -0
  43. data/app/models/callbacks/restrictor.rb +30 -0
  44. data/app/models/callbacks/unique_key_before_update.rb +46 -0
  45. data/app/models/callbacks/viewable_after_destroy.rb +27 -0
  46. data/app/models/callbacks/viewable_before_update.rb +15 -0
  47. data/app/models/form.rb +43 -0
  48. data/app/models/form/email.rb +21 -0
  49. data/app/models/form/field.rb +75 -0
  50. data/app/models/form/row.rb +30 -0
  51. data/app/models/form/static.rb +17 -0
  52. data/app/models/form/static/attachment.rb +62 -0
  53. data/app/models/form/static/base.rb +10 -0
  54. data/app/models/form/static/email.rb +23 -0
  55. data/app/models/form/static/object.rb +12 -0
  56. data/app/models/form/structure.rb +90 -0
  57. data/app/models/setting.rb +85 -0
  58. data/app/models/unique_key.rb +62 -0
  59. data/app/models/viewable.rb +93 -0
  60. data/app/models/viewable/block.rb +39 -0
  61. data/app/models/viewable/field/url.rb +45 -0
  62. data/app/models/viewable/field/uuid.rb +61 -0
  63. data/app/models/viewable/form.rb +67 -0
  64. data/app/models/viewable/image.rb +6 -0
  65. data/app/models/viewable/link.rb +10 -0
  66. data/app/models/viewable/page.rb +24 -0
  67. data/app/models/viewable/select.rb +6 -0
  68. data/app/models/viewable/text.rb +6 -0
  69. data/app/presenters/base_list_presenter.rb +42 -0
  70. data/app/presenters/base_presenter.rb +17 -0
  71. data/app/presenters/viewable/block_presenter.rb +10 -0
  72. data/app/presenters/viewable/form_presenter.rb +15 -0
  73. data/app/presenters/viewable/image_presenter.rb +11 -0
  74. data/app/presenters/viewable/link_list_presenter.rb +44 -0
  75. data/app/presenters/viewable/link_presenter.rb +64 -0
  76. data/app/presenters/viewable/page_presenter.rb +4 -0
  77. data/app/presenters/viewable/select_list_presenter.rb +7 -0
  78. data/app/presenters/viewable/select_presenter.rb +15 -0
  79. data/app/presenters/viewable/text_presenter.rb +11 -0
  80. data/app/presenters/viewable/view_presenter.rb +38 -0
  81. data/app/presenters/viewable_list_presenter.rb +54 -0
  82. data/app/presenters/viewable_presenter.rb +27 -0
  83. data/app/views/cms/forms/create.js.erb +3 -0
  84. data/app/views/cms/shared/_flash_messages.js.erb +2 -0
  85. data/app/views/cms/viewables/update.js.erb +1 -0
  86. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +10 -0
  87. data/config/initializers/assets.rb +6 -0
  88. data/config/initializers/route_translator.rb +3 -0
  89. data/config/locales/cms.en.yml +32 -0
  90. data/config/locales/cms.fr.yml +32 -0
  91. data/config/locales/flash.en.yml +43 -0
  92. data/config/locales/flash.fr.yml +43 -0
  93. data/config/locales/routes.en.yml +3 -0
  94. data/config/locales/routes.fr.yml +3 -0
  95. data/config/routes.rb +36 -0
  96. data/config/spring.rb +1 -0
  97. data/db/migrate/20151226023652_create_unique_key.rb +19 -0
  98. data/db/migrate/20151226054335_create_viewable_link.rb +14 -0
  99. data/db/migrate/20151227064933_create_viewable_text.rb +10 -0
  100. data/db/migrate/20151227072412_create_rich_rich_images.rich.rb +18 -0
  101. data/db/migrate/20151227072413_add_uri_cache_to_rich_image.rich.rb +6 -0
  102. data/db/migrate/20151227072414_refactor_image_to_file.rich.rb +13 -0
  103. data/db/migrate/20151228231201_create_viewable_image.rb +10 -0
  104. data/db/migrate/20151230050603_create_setting.rb +13 -0
  105. data/db/migrate/20151230072904_add_cms_mail_from_and_bcc_settings.rb +14 -0
  106. data/db/migrate/20151230085947_create_viewable_select.rb +10 -0
  107. data/db/migrate/20151231054310_create_viewable_block.rb +9 -0
  108. data/db/migrate/20151231102148_create_viewable_page.rb +13 -0
  109. data/db/migrate/20160101124428_create_viewable_form.rb +15 -0
  110. data/db/migrate/20160101140244_create_form_structure.rb +9 -0
  111. data/db/migrate/20160101141844_create_form_row.rb +13 -0
  112. data/db/migrate/20160102010317_create_form_field.rb +17 -0
  113. data/db/migrate/20160103120544_create_form_email.rb +18 -0
  114. data/lib/generators/cms/install/USAGE +8 -0
  115. data/lib/generators/cms/install/install_generator.rb +14 -0
  116. data/lib/generators/cms/install/templates/Gemfile +47 -0
  117. data/lib/generators/cms/install/templates/app/assets/javascripts/application.js +19 -0
  118. data/lib/generators/cms/install/templates/app/assets/stylesheets/application.css +17 -0
  119. data/lib/generators/cms/install/templates/app/controllers/application_controller.rb +9 -0
  120. data/lib/generators/cms/install/templates/app/controllers/cms/authenticate.rb +34 -0
  121. data/lib/generators/cms/install/templates/app/models/form/contact.rb +20 -0
  122. data/lib/generators/cms/install/templates/app/views/cms/blocks/_example.html.erb +13 -0
  123. data/lib/generators/cms/install/templates/app/views/cms/forms/contact/_form.html.erb +30 -0
  124. data/lib/generators/cms/install/templates/app/views/cms/forms/contact/new.html.erb +19 -0
  125. data/lib/generators/cms/install/templates/app/views/cms/forms_mailer/contact.html.erb +6 -0
  126. data/lib/generators/cms/install/templates/app/views/cms/forms_mailer/contact.text.erb +6 -0
  127. data/lib/generators/cms/install/templates/app/views/cms/pages/page.html.erb +29 -0
  128. data/lib/generators/cms/install/templates/app/views/layouts/application.html.erb +23 -0
  129. data/lib/generators/cms/install/templates/config/application.rb +36 -0
  130. data/lib/generators/cms/install/templates/config/initializers/rails_admin.rb +97 -0
  131. data/lib/generators/cms/install/templates/config/initializers/rich.rb +142 -0
  132. data/lib/generators/cms/install/templates/config/initializers/simple_form.rb +165 -0
  133. data/lib/generators/cms/install/templates/config/initializers/simple_form_bootstrap.rb +149 -0
  134. data/lib/generators/cms/install/templates/config/locales/routes.en.yml +4 -0
  135. data/lib/generators/cms/install/templates/config/locales/simple_form.en.yml +31 -0
  136. data/lib/generators/cms/install/templates/config/routes.rb +61 -0
  137. data/lib/generators/cms/install/templates/vendor/assets/javascripts/rails_admin/custom/ui.js.coffee +1 -0
  138. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/mixins.sass +0 -0
  139. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/theming.sass +1 -0
  140. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rails_admin/custom/variables.sass +0 -0
  141. data/lib/generators/cms/install/templates/vendor/assets/stylesheets/rich/editor.css +20 -0
  142. data/lib/rails_admin_cms.rb +28 -0
  143. data/lib/rails_admin_cms/config.rb +45 -0
  144. data/lib/rails_admin_cms/core_ext/boolean.rb +29 -0
  145. data/lib/rails_admin_cms/engine.rb +11 -0
  146. data/lib/rails_admin_cms/inflections.rb +4 -0
  147. data/lib/rails_admin_cms/utils.rb +30 -0
  148. data/lib/rails_admin_cms/version.rb +3 -0
  149. data/lib/tasks/rails_admin_cms_tasks.rake +4 -0
  150. metadata +669 -0
@@ -0,0 +1,34 @@
1
+ module CMS
2
+ module LocaleHelper
3
+ def cms_locale_selector
4
+ links = [ link_to(t('cms.locale_selector.language'), '#', class: 'active') ]
5
+
6
+ I18n.available_locales.reject{ |l| l == locale }.each do |locale|
7
+ path = current_url_for(locale)
8
+ links << link_to(t('cms.locale_selector.language', locale: locale), path)
9
+ end
10
+
11
+ content_tag(:ul) do
12
+ links.each do |link|
13
+ concat content_tag(:li, link)
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def current_url_for(locale)
21
+ url = case controller_path
22
+ when /^cms\/(pages|forms)/
23
+ if @cms_view
24
+ @cms_view.other_uuid(locale).try(:url)
25
+ else
26
+ main_app.try("#{params[:cms_view_type]}_#{locale}_path")
27
+ end
28
+ else
29
+ url_for(:locale => locale.to_s)
30
+ end
31
+ url.presence || main_app.root_path(locale: locale)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,37 @@
1
+ module CMS
2
+ module ViewHelper
3
+ def cms_body_class(*args)
4
+ controller_name = controller_path.gsub('/','-')
5
+ classes = [
6
+ params[:cms_body_class],
7
+ controller_name,
8
+ "#{controller_name}-#{action_name}",
9
+ I18n.locale,
10
+ ]
11
+ classes << 'cms-edit-mode' if cms_edit_mode?
12
+ classes.concat(args) if args.any?
13
+ classes.compact.join(' ')
14
+ end
15
+
16
+ def cms_flash_messages(*args)
17
+ content_tag :div, class: 'cms-flash-messages', 'data-cms-flash' => true do
18
+ flash_messages(*args)
19
+ end
20
+ end
21
+
22
+ def cms_title(default = nil)
23
+ @cms_page_title || default
24
+ end
25
+
26
+ def cms_meta_data_tags(default = nil)
27
+ if @cms_page_meta_keywords || @cms_page_meta_description
28
+ html = tag(:meta, name: 'meta_keywords', content: @cms_page_meta_keywords)
29
+ html << "\n"
30
+ html << tag(:meta, name: 'meta_description', content: @cms_page_meta_description)
31
+ html.html_safe
32
+ else
33
+ default
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,155 @@
1
+ module CMS
2
+ module ViewableHelper
3
+ def self.define_cms_view_helper(type)
4
+ define_method "cms_view_#{type}" do |name = 'cms', min = 1, max = nil|
5
+ name, min, max = adjust_arguments(name, min, max)
6
+
7
+ public_send("cms_#{type}", @cms_view.uuid_with(name), min, max)
8
+ end
9
+ end
10
+
11
+ Viewable::Block.names.each do |type|
12
+ define_cms_view_helper(type)
13
+
14
+ define_method "cms_#{type}" do |name = 'cms', min = 1, max = nil| # max = FLOAT::INFINITY
15
+ name, min, max = adjust_arguments(name, min, max)
16
+
17
+ cms_block("#{type}/#{name}", min, max)
18
+ end
19
+ end
20
+
21
+ Viewable.names.each do |type|
22
+ define_cms_view_helper(type)
23
+
24
+ define_method "cms_#{type}" do |name = 'cms', min = 1, max = nil| # max = FLOAT::INFINITY
25
+ name, min, max = adjust_arguments(name, min, max)
26
+
27
+ validate_arguments! type, min, max
28
+
29
+ name, presenter = adjust_name_or_build_view_presenter type, name
30
+
31
+ return presenter if presenter
32
+
33
+ presenter_list = (1..min).map do |position|
34
+ find_or_create_presenter(type, name, position)
35
+ end
36
+
37
+ list_key = cms_list_key(type, name)
38
+
39
+ if max.nil?
40
+ if min == 1
41
+ return presenter_list.first
42
+ else
43
+ return build_list_presenter(presenter_list, list_key, max)
44
+ end
45
+ end
46
+
47
+ ((min + 1)..max).each do |position|
48
+ if (presenter = find_presenter(type, name, position))
49
+ presenter_list << presenter
50
+ else
51
+ break
52
+ end
53
+ end
54
+
55
+ build_list_presenter(presenter_list, list_key, max)
56
+ end
57
+ end
58
+
59
+ def cms_link_to_edit_mode
60
+ next_mode = cms_edit_mode? ? t('cms.show_mode') : t('cms.edit_mode')
61
+
62
+ path = "#{request.path}?#{{ edit_mode: !cms_edit_mode? }.to_query}"
63
+
64
+ link_to next_mode, path
65
+ end
66
+
67
+ def cms_list_key(type, name)
68
+ {
69
+ viewable_type: "Viewable::#{type.camelize}",
70
+ view_path: @virtual_path,
71
+ name: name,
72
+ locale: locale,
73
+ }
74
+ end
75
+
76
+ private
77
+
78
+ def adjust_arguments(name, min, max)
79
+ if !name.is_a?(String) && !name.is_a?(Symbol)
80
+ max, min = min, name
81
+ name = 'cms'
82
+ end
83
+ [name, min, max]
84
+ end
85
+
86
+ def validate_arguments!(type, min, max)
87
+ if min == Float::INFINITY
88
+ raise ArgumentError, "'min' can not be Float::INFINITY"
89
+ end
90
+ if max.nil?
91
+ if min == 0
92
+ raise ArgumentError, "if 'max' is not defined, 'min' must be greater than 0"
93
+ end
94
+ elsif max < 1
95
+ raise ArgumentError, "'max' must be greater than 0 or nil"
96
+ end
97
+ if type == 'block' && @cms_view_partial
98
+ raise ArgumentError, "can not have cms_block(...) within block partials"
99
+ end
100
+ end
101
+
102
+ def adjust_name_or_build_view_presenter(type, name)
103
+ case type
104
+ when 'page'
105
+ if @cms_view
106
+ presenter = Viewable::PagePresenter.new(@cms_view, self)
107
+ end
108
+ when 'form'
109
+ if @cms_view
110
+ presenter = Viewable::FormPresenter.new(@cms_view, self)
111
+ end
112
+ else
113
+ if @cms_view_partial
114
+ name = @cms_view_partial.uuid_with(name)
115
+ end
116
+ end
117
+ [name, presenter]
118
+ end
119
+
120
+ def find_presenter(type, name, position)
121
+ unique_key = to_unique_key(type, name, position)
122
+ if (viewable = UniqueKey.find_viewable(unique_key))
123
+ build_presenter(unique_key, viewable)
124
+ end
125
+ end
126
+
127
+ def find_or_create_presenter(type, name, position)
128
+ unique_key = to_unique_key(type, name, position)
129
+ viewable = UniqueKey.find_or_create_viewable!(unique_key)
130
+ build_presenter(unique_key, viewable)
131
+ end
132
+
133
+ def build_presenter(unique_key, viewable)
134
+ presenter_class = "#{unique_key[:viewable_type]}Presenter".safe_constantize
135
+ if presenter_class
136
+ presenter_class.new(viewable, self)
137
+ else
138
+ ViewablePresenter.new(viewable, self)
139
+ end
140
+ end
141
+
142
+ def build_list_presenter(viewables, list_key, max)
143
+ list_presenter_class = "#{list_key[:viewable_type]}ListPresenter".safe_constantize
144
+ if list_presenter_class
145
+ list_presenter_class.new(viewables, self, list_key, max)
146
+ else
147
+ ViewableListPresenter.new(viewables, self, list_key, max)
148
+ end
149
+ end
150
+
151
+ def to_unique_key(type, name, position)
152
+ cms_list_key(type, name).merge(position: position)
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,11 @@
1
+ module RailsAdmin
2
+ FormBuilder.class_eval do
3
+
4
+ private
5
+
6
+ def nested_field_association?(field, nested_in)
7
+ field.inverse_of.presence && nested_in.presence && field.inverse_of == nested_in.name &&
8
+ (@template.instance_variable_get(:@model_config).abstract_model == field.abstract_model || field.name == nested_in.inverse_of)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,77 @@
1
+ module RailsAdmin
2
+ module NavigationHelper
3
+ CMSViewableEdit ||= /viewable~(\w+)\/(\d+)\/edit/
4
+ CMSPageType ||= /^cms\/pages\/(\w+)$/
5
+ CMSPageFormType ||= /^cms\/forms\/(\w+)\/new$/
6
+ CMSFormType ||= /^cms\/forms\/(\w+)\/_form$/
7
+ CMSPageUUID ||= /^P\[(.+)\]/
8
+
9
+ def admin_locale_selector
10
+ selectors = I18n.available_locales.reject{ |l| l == locale }.map do |locale|
11
+ if request.path =~ CMSViewableEdit
12
+ viewable = extract_viewable($1, $2)
13
+ unique_key = viewable.unique_key_hash(locale)
14
+ other_id = UniqueKey.find_viewable(unique_key).id
15
+
16
+ path = "#{dashboard_path}/viewable~#{$1}/#{other_id}/edit?locale=#{locale}"
17
+ else
18
+ path = "#{request.path}?#{ { locale: locale }.to_query }"
19
+ end
20
+ [locale, path]
21
+ end
22
+
23
+ selectors.map do |locale, path|
24
+ content_tag :li do
25
+ link_to t('cms.locale_selector.language', locale: locale), path
26
+ end
27
+ end.join.html_safe
28
+ end
29
+
30
+ def admin_back_home
31
+ if request.path =~ CMSViewableEdit
32
+ viewable = extract_viewable($1, $2)
33
+ view_path, name, type = viewable.slice(:view_path, :unique_key_name, :viewable_type).values
34
+
35
+ if type == 'Viewable::Page'
36
+ path = viewable.url
37
+ elsif name =~ CMSPageUUID
38
+ path = Viewable::Page.find_by_uuid($1).url
39
+ else
40
+ case view_path
41
+ when CMSPageType, CMSPageFormType, CMSFormType
42
+ path = main_app.try "#{$1}_path"
43
+ when /\/(\w+)\/index$/
44
+ resources = $1
45
+ if resources.singularize == resources
46
+ path = main_app.try "#{resources}_index_path"
47
+ else
48
+ path = main_app.try "#{resources}_path"
49
+ end
50
+ when /\/\w+\/show$/
51
+ scopes = view_path.split('/')
52
+ scopes.pop
53
+ resource = scopes.pop.singularize
54
+ namespace = scopes.map(&:camelize).join('::')
55
+ first_object = "#{namespace}::#{resource.camelize}".constantize.first
56
+
57
+ if first_object
58
+ path = main_app.try "#{resource}_path", first_object
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ path ||= main_app.root_path
65
+
66
+ content_tag :li do
67
+ link_to t('admin.home.name'), path
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def extract_viewable(type, id)
74
+ @_viewable ||= "Viewable::#{type.camelize}".constantize.find(id)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,48 @@
1
+ module CMS
2
+ class FormsMailer < RailsAdminCMS::Config.parent_mailer
3
+ def send_email(form)
4
+ options = {
5
+ from: form.send_from,
6
+ to: form.send_to,
7
+ bcc: Setting[:cms_mail_bcc],
8
+ subject: form.subject,
9
+ template_name: form.form_name,
10
+ }
11
+
12
+ if form.has_attachments?
13
+ options[:content_type] = 'multipart/form-data'
14
+ form.attachments.each do |name|
15
+ attachment = form.send(name)
16
+ next unless attachment.exists?
17
+ attachments[attachment.original_filename] = File.read(attachment.path)
18
+ end
19
+ end
20
+
21
+ @form = form
22
+ mail options
23
+
24
+ # https://github.com/rails/rails/issues/2686
25
+ fix_mixed_attachments
26
+ end
27
+
28
+ def fix_mixed_attachments
29
+ # do nothing if we have no actual attachments
30
+ return if @_message.parts.select { |p| p.attachment? && !p.inline? }.none?
31
+
32
+ mail = Mail.new
33
+
34
+ related = Mail::Part.new
35
+ related.content_type = @_message.content_type
36
+ @_message.parts.select { |p| !p.attachment? || p.inline? }.each { |p| related.add_part(p) }
37
+ mail.add_part related
38
+
39
+ mail.header = @_message.header.to_s
40
+ mail.bcc = @_message.header[:bcc].value # copy bcc manually because it is omitted in header.to_s
41
+ mail.content_type = nil
42
+ @_message.parts.select { |p| p.attachment? && !p.inline? }.each { |p| mail.add_part(p) }
43
+
44
+ @_message = mail
45
+ wrap_delivery_behavior!(delivery_method.to_sym)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,41 @@
1
+ module Admin
2
+ module Form
3
+ module Email
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ rails_admin do
8
+ visible false
9
+
10
+ object_label_method do
11
+ :rails_admin_label
12
+ end
13
+
14
+ edit do
15
+ toolbar = Rich.editor[:toolbar].deep_dup
16
+ toolbar.delete_at(-2)
17
+
18
+ if RailsAdminCMS::Config.with_email_body?
19
+ I18n.available_locales.each do |locale|
20
+ configure :"body_#{locale}", :rich_editor do
21
+ config(toolbar: toolbar)
22
+ end
23
+ end
24
+ exclude_fields :structure
25
+ else
26
+ exclude_fields :structure, *I18n.available_locales.map{ |l| :"body_#{l}" }
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def rails_admin_label
33
+ if with_email?
34
+ '<i class="icon-ok"></i>'
35
+ else
36
+ '<i>-</i>'
37
+ end.html_safe
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ module Admin
2
+ module Form
3
+ module Field
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ rails_admin do
8
+ visible false
9
+
10
+ object_label_method do
11
+ :rails_admin_label
12
+ end
13
+
14
+ edit do
15
+ exclude_fields :structure, :fields
16
+ end
17
+ end
18
+ end
19
+
20
+ def rails_admin_label
21
+ default_label.presence || position
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ module Admin
2
+ module Form
3
+ module Row
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ rails_admin do
8
+ object_label_method do
9
+ :id
10
+ end
11
+
12
+ configure :structure do
13
+ read_only true
14
+ pretty_value do
15
+ h = bindings[:view]
16
+ p = ViewablePresenter.new value, h
17
+ h.link_to value.name, p.__send__(:edit_path)
18
+ end
19
+ end
20
+
21
+ edit do
22
+ exclude_fields :fields, :viewable
23
+ end
24
+
25
+ list do
26
+ configure :id do
27
+ sort_reverse false
28
+ end
29
+
30
+ scopes ::Form::Structure.scopes
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end