bhf 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +1 -1
  4. data/VERSION +1 -1
  5. data/app/assets/images/bhf/pictos.png +0 -0
  6. data/app/assets/images/bhf/pictos_2x.png +0 -0
  7. data/app/assets/javascripts/bhf/application.js +153 -116
  8. data/app/assets/javascripts/bhf/classes/ArrayFields.js +1 -1
  9. data/app/assets/javascripts/bhf/classes/MultipleFields.js +2 -2
  10. data/app/assets/javascripts/bhf/classes/PlatformHelper.js +6 -11
  11. data/app/assets/javascripts/bhf/classes/{AjaxEdit.js → QuickEdit.js} +9 -9
  12. data/app/assets/javascripts/bhf/classes/{AjaxEditStack.js → QuickEditStack.js} +4 -20
  13. data/app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js +1 -0
  14. data/app/assets/javascripts/bhf/mootools_ujs.js +11 -11
  15. data/app/assets/stylesheets/bhf/application.css.sass +86 -48
  16. data/app/controllers/bhf/application_controller.rb +8 -4
  17. data/app/controllers/bhf/embed_entries_controller.rb +2 -6
  18. data/app/controllers/bhf/entries_controller.rb +13 -16
  19. data/app/controllers/bhf/pages_controller.rb +14 -13
  20. data/app/helpers/bhf/application_helper.rb +6 -6
  21. data/app/helpers/bhf/entries_helper.rb +4 -2
  22. data/app/helpers/bhf/pages_helper.rb +0 -4
  23. data/app/views/bhf/entries/_form.haml +7 -4
  24. data/app/views/bhf/entries/show.haml +3 -4
  25. data/app/views/bhf/form/belongs_to/_radio.haml +28 -0
  26. data/app/views/bhf/form/belongs_to/_select.haml +21 -0
  27. data/app/views/bhf/form/belongs_to/_static.haml +1 -0
  28. data/app/views/bhf/{entries/form → form}/column/_array.haml +0 -0
  29. data/app/views/bhf/{entries/form → form}/column/_boolean.haml +0 -0
  30. data/app/views/bhf/{entries/form → form}/column/_date.haml +0 -0
  31. data/app/views/bhf/{entries/form → form}/column/_hash.haml +0 -0
  32. data/app/views/bhf/{entries/form → form}/column/_mappin.haml +0 -0
  33. data/app/views/bhf/{entries/form → form}/column/_markdown.haml +0 -0
  34. data/app/views/bhf/{entries/form → form}/column/_multiple_fields.haml +0 -0
  35. data/app/views/bhf/{entries/form → form}/column/_number.haml +0 -0
  36. data/app/views/bhf/{entries/form → form}/column/_paperclip.haml +0 -0
  37. data/app/views/bhf/{entries/form → form}/column/_password.haml +0 -0
  38. data/app/views/bhf/{entries/form → form}/column/_static.haml +0 -0
  39. data/app/views/bhf/{entries/form → form}/column/_string.haml +0 -0
  40. data/app/views/bhf/{entries/form → form}/column/_text.haml +0 -0
  41. data/app/views/bhf/{entries/form → form}/column/_wysiwyg.haml +0 -0
  42. data/app/views/bhf/form/embeds_many/_static.haml +26 -0
  43. data/app/views/bhf/form/embeds_one/_static.haml +2 -0
  44. data/app/views/bhf/form/has_and_belongs_to_many/_check_box.haml +22 -0
  45. data/app/views/bhf/form/has_and_belongs_to_many/_static.haml +1 -0
  46. data/app/views/bhf/form/has_many/_static.haml +26 -0
  47. data/app/views/bhf/form/has_one/_static.haml +2 -0
  48. data/app/views/bhf/helper/_definition_item.haml +1 -1
  49. data/app/views/bhf/helper/_frontend_edit.haml +1 -1
  50. data/app/views/bhf/pages/_platform.haml +39 -16
  51. data/app/views/bhf/{pages/macro → table}/belongs_to/_default.haml +1 -1
  52. data/app/views/bhf/table/column/_array.haml +1 -0
  53. data/app/views/bhf/table/column/_boolean.haml +1 -0
  54. data/app/views/bhf/table/column/_date.haml +1 -0
  55. data/app/views/bhf/table/column/_extern_link.haml +2 -0
  56. data/app/views/bhf/table/column/_file.haml +1 -0
  57. data/app/views/bhf/table/column/_hash.haml +1 -0
  58. data/app/views/bhf/table/column/_image.haml +1 -0
  59. data/app/views/bhf/table/column/_number.haml +1 -0
  60. data/app/views/bhf/table/column/_paperclip.haml +5 -0
  61. data/app/views/bhf/table/column/_primary_key.haml +1 -0
  62. data/app/views/bhf/table/column/_string.haml +1 -0
  63. data/app/views/bhf/table/column/_text.haml +1 -0
  64. data/app/views/bhf/table/embeds_many/_default.haml +1 -0
  65. data/app/views/bhf/table/embeds_one/_default.haml +1 -0
  66. data/app/views/bhf/table/has_and_belongs_to_many/_default.haml +1 -0
  67. data/app/views/bhf/table/has_many/_default.haml +2 -0
  68. data/app/views/bhf/{pages/macro → table}/has_one/_default.haml +1 -1
  69. data/bhf.gemspec +60 -59
  70. data/config/locales/de.yml +8 -8
  71. data/config/locales/en.yml +7 -7
  72. data/lib/bhf.rb +26 -21
  73. data/lib/bhf/action_view/form_builder.rb +36 -0
  74. data/lib/bhf/action_view/form_options.rb +30 -0
  75. data/lib/bhf/active_record/base.rb +58 -0
  76. data/lib/bhf/mongoid/document.rb +135 -137
  77. data/lib/bhf/platform/attribute/abstract.rb +52 -0
  78. data/lib/bhf/platform/attribute/column.rb +78 -0
  79. data/lib/bhf/platform/attribute/reflection.rb +68 -0
  80. data/lib/bhf/platform/base.rb +333 -0
  81. data/lib/bhf/{pagination.rb → platform/pagination.rb} +1 -1
  82. data/lib/bhf/{settings.rb → settings/base.rb} +14 -11
  83. data/lib/bhf/settings/platform.rb +20 -0
  84. data/lib/bhf/settings/yaml_parser.rb +84 -0
  85. data/lib/rails/generators/bhf/templates/initializer.rb +1 -1
  86. metadata +58 -57
  87. data/app/views/bhf/entries/form/belongs_to/_account_scope.haml +0 -2
  88. data/app/views/bhf/entries/form/belongs_to/_radio.haml +0 -8
  89. data/app/views/bhf/entries/form/belongs_to/_select.haml +0 -7
  90. data/app/views/bhf/entries/form/belongs_to/_static.haml +0 -1
  91. data/app/views/bhf/entries/form/embeds_many/_static.haml +0 -12
  92. data/app/views/bhf/entries/form/embeds_one/_static.haml +0 -12
  93. data/app/views/bhf/entries/form/has_and_belongs_to_many/_account_scope.haml +0 -2
  94. data/app/views/bhf/entries/form/has_and_belongs_to_many/_check_box.haml +0 -5
  95. data/app/views/bhf/entries/form/has_and_belongs_to_many/_static.haml +0 -1
  96. data/app/views/bhf/entries/form/has_many/_static.haml +0 -12
  97. data/app/views/bhf/entries/form/has_one/_account_scope.haml +0 -2
  98. data/app/views/bhf/entries/form/has_one/_static.haml +0 -9
  99. data/app/views/bhf/pages/macro/column/_array.haml +0 -1
  100. data/app/views/bhf/pages/macro/column/_boolean.haml +0 -1
  101. data/app/views/bhf/pages/macro/column/_date.haml +0 -1
  102. data/app/views/bhf/pages/macro/column/_extern_link.haml +0 -2
  103. data/app/views/bhf/pages/macro/column/_file.haml +0 -1
  104. data/app/views/bhf/pages/macro/column/_hash.haml +0 -1
  105. data/app/views/bhf/pages/macro/column/_image.haml +0 -2
  106. data/app/views/bhf/pages/macro/column/_number.haml +0 -1
  107. data/app/views/bhf/pages/macro/column/_paperclip.haml +0 -6
  108. data/app/views/bhf/pages/macro/column/_primary_key.haml +0 -1
  109. data/app/views/bhf/pages/macro/column/_string.haml +0 -1
  110. data/app/views/bhf/pages/macro/column/_text.haml +0 -1
  111. data/app/views/bhf/pages/macro/embeds_many/_default.haml +0 -1
  112. data/app/views/bhf/pages/macro/embeds_one/_default.haml +0 -1
  113. data/app/views/bhf/pages/macro/has_and_belongs_to_many/_default.haml +0 -1
  114. data/app/views/bhf/pages/macro/has_many/_default.haml +0 -2
  115. data/lib/bhf/active_record/active_record.rb +0 -59
  116. data/lib/bhf/data.rb +0 -169
  117. data/lib/bhf/form.rb +0 -36
  118. data/lib/bhf/platform.rb +0 -308
  119. data/lib/bhf/settings_parser.rb +0 -84
@@ -18,12 +18,8 @@ class Bhf::EmbedEntriesController < Bhf::EntriesController
18
18
  manage_many_to_many
19
19
  after_save
20
20
 
21
- extra_data = {
22
- edit_path: edit_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object),
23
- delete_path: entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
24
- }
25
21
  if @quick_edit
26
- render json: object_to_bhf_display_hash.merge(extra_data), status: :ok
22
+ render json: object_to_bhf_hash, status: :ok
27
23
  else
28
24
  redirect_after_save(notice: set_message('update.success', @model))
29
25
  end
@@ -43,7 +39,7 @@ class Bhf::EmbedEntriesController < Bhf::EntriesController
43
39
  after_save
44
40
 
45
41
  if @quick_edit
46
- render json: object_to_bhf_display_hash, status: :ok
42
+ render json: object_to_bhf_hash, status: :ok
47
43
  else
48
44
  redirect_after_save(notice: set_message('update.success', @model))
49
45
  end
@@ -33,7 +33,7 @@ class Bhf::EntriesController < Bhf::ApplicationController
33
33
  after_save
34
34
 
35
35
  if @quick_edit
36
- render json: object_to_bhf_display_hash, status: :ok
36
+ render json: object_to_bhf_hash, status: :ok
37
37
  else
38
38
  redirect_after_save(notice: set_message('create.success', @model), referral_entry: {id: @object.id, platform: @platform.name})
39
39
  end
@@ -55,7 +55,7 @@ class Bhf::EntriesController < Bhf::ApplicationController
55
55
  after_save
56
56
 
57
57
  if @quick_edit
58
- render json: object_to_bhf_display_hash, status: :ok
58
+ render json: object_to_bhf_hash, status: :ok
59
59
  else
60
60
  redirect_after_save(notice: set_message('update.success', @model), referral_entry: {id: @object.id, platform: @platform.name})
61
61
  end
@@ -100,32 +100,29 @@ class Bhf::EntriesController < Bhf::ApplicationController
100
100
 
101
101
  private
102
102
 
103
- def object_to_bhf_display_hash
103
+ def object_to_bhf_hash
104
104
  extra_data = {
105
- to_bhf_s: @object.to_bhf_s,
106
- object_id: @object.send(@object.class.bhf_primary_key).to_s,
107
- edit_path: edit_entry_path(@platform.name, @object),
108
- can_edit: ! @platform.hide_edit,
109
- delete_path: entry_path(@platform.name, @object),
110
- can_delete: ! @platform.hide_delete,
111
- delete_confirm: t('bhf.helpers.promts.confirm')
105
+ to_bhf_s: @object.to_bhf_s,
106
+ object_id: @object.send(@object.class.bhf_primary_key).to_s
112
107
  }
108
+ extra_data.merge!(@object.to_bhf_hash) if @object.respond_to?(:to_bhf_hash)
109
+
113
110
  @platform.columns.each_with_object(extra_data) do |column, hash|
114
- unless column.field.macro == :column && @object.send(column.name).blank?
115
- p = "bhf/pages/macro/#{column.field.macro}/#{column.field.display_type}"
116
- hash[column.name] = render_to_string partial: p, locals: {column: column, object: @object}
111
+ column_value = @object.send(column.name)
112
+ unless column.macro == :column && column_value.blank?
113
+ p = "bhf/table/#{column.macro}/#{column.display_type}"
114
+ hash[column.name] = render_to_string partial: p, locals: {object: @object, column_value: column_value}
117
115
  end
118
116
  end
119
117
  end
120
118
 
121
119
  def load_platform
122
- @platform = @settings.find_platform(params[:platform], current_account)
120
+ @platform = find_platform(params[:platform])
123
121
  end
124
122
 
125
123
  def load_model
126
124
  @model = @platform.model
127
- @model_sym = ActiveModel::Naming.singular(@model).to_sym
128
- @permited_params = ActionController::Parameters.new(params[@model_sym]).permit!
125
+ @permited_params = ActionController::Parameters.new(params[@platform.model_name.to_sym]).permit!
129
126
  end
130
127
 
131
128
  def load_object
@@ -2,6 +2,7 @@ class Bhf::PagesController < Bhf::ApplicationController
2
2
  before_filter :set_page
3
3
 
4
4
  def show
5
+ @edit_params = {}
5
6
  unless platform_options = @settings.content_for_page(@page)
6
7
  raise Exception.new("Page '#{@page}' could not be found")
7
8
  end
@@ -13,9 +14,9 @@ class Bhf::PagesController < Bhf::ApplicationController
13
14
  end
14
15
 
15
16
  @platforms = platform_options.each_with_object([]) do |opts, obj|
16
- platform = Bhf::Platform.new(opts, @page, @settings, current_account)
17
+ platform = find_platform(opts.keys[0])
18
+
17
19
  next if platform.table_hide?
18
- platform.pagination = Bhf::Pagination.new(platform.entries_per_page)
19
20
  paginate_platform_objects(platform)
20
21
  obj << platform
21
22
  end
@@ -28,30 +29,30 @@ class Bhf::PagesController < Bhf::ApplicationController
28
29
  end
29
30
 
30
31
  def render_platform(platform_name)
31
- platform = @settings.find_platform(platform_name, current_account)
32
+ platform = find_platform(platform_name)
32
33
 
33
- platform.pagination = Bhf::Pagination.new(platform.entries_per_page)
34
34
  paginate_platform_objects(platform)
35
35
 
36
36
  render layout: false, partial: 'platform', locals: {platform: platform}
37
37
  end
38
38
 
39
- def check_params(platform)
39
+ def paginate_platform_objects(platform)
40
+ p = (params[platform.name] || {})
40
41
  page = 1
41
- if params[platform.name] && !params[platform.name][:page].blank?
42
- page = params[platform.name][:page].to_i
42
+ unless p[:page].blank?
43
+ page = p[:page].to_i
43
44
  end
44
45
 
45
46
  per_page = platform.pagination.offset_per_page
46
- if params[platform.name] && !params[platform.name][:per_page].blank?
47
- per_page = params[platform.name][:per_page].to_i
47
+ unless p[:per_page].blank?
48
+ per_page = p[:per_page].to_i
48
49
  end
49
50
 
50
- return { page: page, per_page: per_page }
51
- end
51
+ page_params = { page: page, per_page: per_page }
52
52
 
53
- def paginate_platform_objects(platform)
54
- platform.prepare_objects(params[platform.name] || {}, check_params(platform))
53
+ @edit_params[platform.name] = page_params
54
+
55
+ platform.get_objects(p, page_params)
55
56
  end
56
57
 
57
58
  end
@@ -2,23 +2,23 @@ module Bhf
2
2
  module ApplicationHelper
3
3
 
4
4
  def show_t(platform)
5
- t("bhf.helpers.entry.models.#{platform.model_name}.show", platform_name: platform.title_singular, default: t('bhf.helpers.entry.show')).html_safe
5
+ t("bhf.helpers.entry.models.#{platform.model_name}.show", platform_title: platform.title_singular, default: t('bhf.helpers.entry.show')).html_safe
6
6
  end
7
7
 
8
8
  def new_t(platform)
9
- t("bhf.helpers.entry.models.#{platform.model_name}.new", platform_name: platform.title_singular, default: t('bhf.helpers.entry.new')).html_safe
9
+ t("bhf.helpers.entry.models.#{platform.model_name}.new", platform_title: platform.title_singular, default: t('bhf.helpers.entry.new')).html_safe
10
10
  end
11
11
 
12
12
  def duplicate_t(platform)
13
- t("bhf.helpers.entry.models.#{platform.model_name}.duplicate", platform_name: platform.title_singular, default: t('bhf.helpers.entry.duplicate')).html_safe
13
+ t("bhf.helpers.entry.models.#{platform.model_name}.duplicate", platform_title: platform.title_singular, default: t('bhf.helpers.entry.duplicate')).html_safe
14
14
  end
15
15
 
16
16
  def edit_t(platform)
17
- t("bhf.helpers.entry.models.#{platform.model_name}.edit", platform_name: platform.title_singular, default: t('bhf.helpers.entry.edit')).html_safe
17
+ t("bhf.helpers.entry.models.#{platform.model_name}.edit", platform_title: platform.title_singular, default: t('bhf.helpers.entry.edit')).html_safe
18
18
  end
19
19
 
20
20
  def delete_t(platform)
21
- t("bhf.helpers.entry.models.#{platform.model_name}.delete", platform_name: platform.title_singular, default: t('bhf.helpers.entry.delete')).html_safe
21
+ t("bhf.helpers.entry.models.#{platform.model_name}.delete", platform_title: platform.title_singular, default: t('bhf.helpers.entry.delete')).html_safe
22
22
  end
23
23
 
24
24
  def find_smallest_size_url_for_file(file)
@@ -32,7 +32,7 @@ module Bhf
32
32
  end
33
33
 
34
34
  def type_is_image?(type)
35
- Bhf::PAPERCLIP_IMAGE_TYPES.include?(type)
35
+ Bhf.configuration.paperclip_image_types.include?(type)
36
36
  end
37
37
 
38
38
  end
@@ -1,5 +1,6 @@
1
1
  module Bhf
2
2
  module EntriesHelper
3
+ include Bhf::ActionView::FormOptions
3
4
 
4
5
  def node(f, field, &block)
5
6
  render partial: 'bhf/helper/node', locals: {f: f, field: field, input: with_output_buffer(&block)}
@@ -16,12 +17,13 @@ module Bhf
16
17
  }
17
18
  end
18
19
 
19
- def reflection_title(f, field)
20
+ def reflection_title(f, field, count = 2)
20
21
  title = f.object.class.human_attribute_name(field.reflection.name)
21
22
  if field.link
22
- title = t("bhf.platforms.#{field.link}.title", count: f.object.send(field.reflection.name).to_a.count, default: title)
23
+ title = t("bhf.platforms.#{field.link.name}.title", count: count, default: title)
23
24
  end
24
25
  title
25
26
  end
27
+
26
28
  end
27
29
  end
@@ -30,9 +30,5 @@ module Bhf
30
30
  params_platfrom['direction'] == 'desc' ? 'sorted desc' : 'sorted asc'
31
31
  end
32
32
 
33
- def has_link?(display_type)
34
- display_type.to_s.include? '_link'
35
- end
36
-
37
33
  end
38
34
  end
@@ -1,22 +1,25 @@
1
1
  - html = { id: (:main_form unless @quick_edit), multipart: (!@quick_edit && @platform.has_file_upload?), class: 'js_bhf_form' }
2
- = form_for @object, url: @form_url, builder: Bhf::Form::Builder, html: html do |f|
2
+ = form_for @object, url: @form_url, builder: Bhf::ActionView::FormBuilder, html: html do |f|
3
3
 
4
4
  - if f.object.errors.any?
5
5
  = render partial: 'bhf/entries/validation_errors', locals: {f: f}
6
6
 
7
7
  - @platform.fields.each do |field|
8
8
  - unless field.form_type == :hidden
9
- = render partial: "bhf/entries/form/#{field.macro}/#{field.form_type}", locals: {f: f, field: field}
9
+ - if !field.form_type
10
+ = d field
11
+ = render partial: "bhf/form/#{field.macro}/#{field.form_type}", locals: {f: f, field: field}
10
12
 
11
13
  - unless @quick_edit
14
+
12
15
  - if params[:return_to]
13
16
  = hidden_field :return, :to, name: :return_to, value: params[:return_to]
14
-
17
+
15
18
  .node
16
19
  .label
17
20
  .input
18
21
  - unless @object.class.bhf_embedded?
19
- = f.submit t('bhf.helpers.form.buttons.save', platform_name: @platform.title_singular)
22
+ = f.submit t('bhf.helpers.form.buttons.save', platform_title: @platform.title_singular)
20
23
  - unless @platform.hide_edit
21
24
  = f.submit t('bhf.helpers.form.buttons.and_edit'), name: :return_to_edit, class: 'alt_button'
22
25
  - unless @platform.hide_create
@@ -2,13 +2,12 @@
2
2
  - if @platform.definitions.any?
3
3
  .dl.content_box
4
4
  - @platform.definitions.each do |column|
5
- - tmp = column.field.show_type ? column.field.show_type : column.field.display_type
6
- - if ! @object.send(column.name).blank?
5
+ - column_value = @object.send(column.name)
6
+ - if ! column_value.blank?
7
7
  = definition_item @object, column do
8
- = render(partial: "bhf/pages/macro/#{column.field.macro}/#{tmp}", locals: {column: column, object: @object})
8
+ = render(partial: "bhf/table/#{column.macro}/#{column.show_type}", locals: {column_value: column_value, object: @object})
9
9
 
10
10
  - if @platform.show_extra_fields and @platform.show_extra_fields.any?
11
11
  .content_box
12
12
  - @platform.show_extra_fields.each do |name|
13
13
  = render(partial: "bhf/pages/show/#{name}", locals: {name: name, object: @object})
14
-
@@ -0,0 +1,28 @@
1
+ - data_source ||= field.link ? field.link.get_objects : field.reflection.klass.all
2
+ - fk = field.db_name
3
+ = reflection_node f, field do
4
+ .quick_edit_block
5
+ %ul.relation.quick_edit_inject
6
+ - data_source.each do |obj|
7
+ %li.quick_edit_entry
8
+ = f.radio_button fk, obj.id, id: "belongs_to_#{fk}_#{obj.id}"
9
+ - if field.link && ! field.link.hide_edit
10
+ = link_to obj.to_bhf_s, edit_entry_path(field.link.name, obj), class: 'js_edit_field qe_button quick_edit'
11
+ - else
12
+ = label_tag "belongs_to_#{fk}_#{obj.id}", obj.to_bhf_s
13
+ - if field.link && ! field.link.hide_delete
14
+ = link_to '&times;'.html_safe, entry_path(field.link.name, obj), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
15
+
16
+ %template.quick_edit_template{type: 'text/template'}
17
+ %li
18
+ = f.radio_button fk, '{object_id}', id: "belongs_to_#{fk}_{object_id}"
19
+ - if field.link && ! field.link.hide_edit
20
+ = link_to '{to_bhf_s}', edit_entry_path(field.link.name, '{object_id}'), class: 'js_edit_field qe_button quick_edit'
21
+ - else
22
+ = label_tag "belongs_to_#{fk}_#{obj.id}", obj.to_bhf_s
23
+ - if field.link && ! field.link.hide_delete
24
+ = link_to '&times;'.html_safe, entry_path(field.link.name, '{object_id}'), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
25
+
26
+
27
+ - if field.link && ! field.link.hide_create
28
+ = link_to '+', new_entry_path(field.link.name), class: 'js_add_field plus_button qe_button quick_edit'
@@ -0,0 +1,21 @@
1
+ - data_source ||= field.link ? field.link.get_objects : field.reflection.klass.all
2
+ - fk = field.db_name
3
+ .node
4
+ .label= f.label fk, reflection_title(f, field, 1)
5
+ .input.select_input.quick_edit_block
6
+ - if field.link
7
+ %template.quick_edit_template{type: 'text/template'}
8
+ = options_for_select([['{to_bhf_s}', '{object_id}', {data: {edit: edit_entry_path(field.link.name, '{object_id}'), delete: entry_path(field.link.name, '{object_id}')}}]])
9
+ - select_options ||= options_from_collection_for_select_with_html_attrs(data_source, :id, :to_bhf_s, f.object.send(fk), Proc.new {|obj| {data: {edit: edit_entry_path(field.link.name, obj), delete: entry_path(field.link.name, obj)}}})
10
+ - else
11
+ - select_options ||= options_from_collection_for_select(data_source, :id, :to_bhf_s, f.object.send(fk))
12
+
13
+ = f.select fk, select_options, {include_blank: true}, {class: ('quick_edit_inject quick_edit_select' if field.link)}
14
+ = render partial: 'bhf/helper/field_errors', locals: {f: f, field: fk}
15
+
16
+ - if field.link && ! field.link.hide_edit
17
+ = link_to edit_t(field.link), '', class: 'js_edit_field icon edit quick_edit'
18
+ - if field.link && ! field.link.hide_delete
19
+ = link_to '&times;'.html_safe, '', method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
20
+ - if field.link && ! field.link.hide_create
21
+ = link_to '+', new_entry_path(field.link.name), class: 'js_add_field plus_button qe_button quick_edit'
@@ -0,0 +1 @@
1
+ = render partial: 'bhf/form/has_one/static', locals: {ref_object: f.object.send(field.reflection.name), field: field, f: f}
@@ -0,0 +1,26 @@
1
+ = reflection_node f, field do
2
+ - ref_objects ||= f.object.send(field.reflection.name)
3
+ - is_one = field.macro == :embeds_one
4
+ .quick_edit_block
5
+ %p.empty{class: ('hide' unless ref_objects.blank?)}= t 'bhf.helpers.entry.empty', count: (is_one ? 1 : 2)
6
+ %ul.relation.quick_edit_inject{class: field.macro}
7
+ - ref_objects.each do |ref_object|
8
+ %li.quick_edit_entry
9
+ - if field.link && ! field.link.hide_edit
10
+ = link_to ref_object.to_bhf_s, edit_entry_embed_path(field.link.name, f.object, ref_object), class: 'js_edit_field qe_button quick_edit'
11
+ - else
12
+ = ref_object.to_bhf_s
13
+ - if field.link && ! field.link.hide_delete
14
+ = link_to '&times;'.html_safe, entry_embed_path(field.link.name, f.object, ref_object), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
15
+
16
+ %template.quick_edit_template{type: 'text/template'}
17
+ %li.quick_edit_entry
18
+ - if field.link && ! field.link.hide_edit
19
+ = link_to '{to_bhf_s}', edit_entry_embed_path(field.link.name, f.object, '{object_id}'), class: 'js_edit_field qe_button quick_edit'
20
+ - else
21
+ = '{to_bhf_s}'
22
+ - if field.link && ! field.link.hide_delete
23
+ = link_to '&times;'.html_safe, entry_embed_path(field.link.name, f.object, '{object_id}'), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
24
+
25
+ - if ! is_one && field.link && ! field.link.hide_create
26
+ = link_to '+', new_entry_embed_path(field.link.name, f.object), class: 'js_add_field plus_button qe_button quick_edit default_form_align'
@@ -0,0 +1,2 @@
1
+ - ref_object ||= f.object.send(field.reflection.name)
2
+ = render partial: 'bhf/form/embeds_many/static', locals: {ref_objects: [ref_object], field: field, f: f}
@@ -0,0 +1,22 @@
1
+ - data_source ||= field.link ? field.link.get_objects : field.reflection.klass.all
2
+ = reflection_node f, field do
3
+ .quick_edit_block
4
+ %ul.relation.quick_edit_inject
5
+ - data_source.each do |ref_object|
6
+ %li.quick_edit_entry
7
+ = f.many_to_many_check_box(ref_object, field.reflection.name, params, field.link && ! field.link.hide_edit)
8
+ - if field.link && ! field.link.hide_edit
9
+ = link_to ref_object.to_bhf_s, edit_entry_path(field.link.name, ref_object), class: 'js_edit_field qe_button quick_edit'
10
+ - if field.link && ! field.link.hide_delete
11
+ = link_to '&times;'.html_safe, entry_path(field.link.name, ref_object), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
12
+
13
+ %template.quick_edit_template{type: 'text/template'}
14
+ %li.quick_edit_entry
15
+ = f.many_to_many_check_box(OpenStruct.new(to_bhf_s: '{to_bhf_s}'), field.reflection.name, params, field.link && ! field.link.hide_edit, true, "{object_id}").gsub('_object_id_', '{object_id}').html_safe # fix for id attr
16
+ - if field.link && ! field.link.hide_edit
17
+ = link_to '{to_bhf_s}', edit_entry_path(field.link.name, '{object_id}'), class: 'js_edit_field qe_button quick_edit'
18
+ - if field.link && ! field.link.hide_delete
19
+ = link_to '&times;'.html_safe, entry_path(field.link.name, '{object_id}'), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
20
+
21
+ - if field.link && ! field.link.hide_create
22
+ = link_to '+', new_entry_path(field.link.name), class: 'js_add_field plus_button qe_button quick_edit default_form_align'
@@ -0,0 +1 @@
1
+ = render partial: 'bhf/form/has_many/static', locals: {ref_objects: f.object.send(field.reflection.name), field: field, f: f}
@@ -0,0 +1,26 @@
1
+ = reflection_node f, field do
2
+ - ref_objects ||= f.object.send(field.reflection.name)
3
+ - is_one = (field.macro == :has_one || field.macro == :belongs_to)
4
+ .quick_edit_block
5
+ %p.empty{class: ('hide' unless ref_objects.blank?)}= t 'bhf.helpers.entry.empty', count: (is_one ? 1 : 2)
6
+ %ul.relation.quick_edit_inject{class: field.macro}
7
+ - ref_objects.each do |ref_object|
8
+ %li.quick_edit_entry
9
+ - if field.link && ! field.link.hide_edit
10
+ = link_to ref_object.to_bhf_s, edit_entry_path(field.link.name, ref_object), class: 'js_edit_field qe_button quick_edit'
11
+ - else
12
+ = ref_object.to_bhf_s
13
+ - if field.link && ! field.link.hide_delete
14
+ = link_to '&times;'.html_safe, entry_path(field.link.name, ref_object), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
15
+
16
+ %template.quick_edit_template{type: 'text/template'}
17
+ %li.quick_edit_entry
18
+ - if field.link && ! field.link.hide_edit
19
+ = link_to '{to_bhf_s}', edit_entry_path(field.link.name, '{object_id}'), class: 'js_edit_field qe_button quick_edit'
20
+ - else
21
+ = '{to_bhf_s}'
22
+ - if field.link && ! field.link.hide_delete
23
+ = link_to '&times;'.html_safe, entry_path(field.link.name, '{object_id}'), method: :delete, class: 'qe_delete js_delete', remote: true, data: {confirm: t('bhf.helpers.promts.confirm', platform_title: field.link.title_singular)}
24
+
25
+ - if ! is_one && field.link && ! field.link.hide_create
26
+ = link_to '+', new_entry_path(field.link.name), class: 'js_add_field plus_button qe_button quick_edit default_form_align'