alchemy_cms 4.1.2 → 4.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/Bug_report.md +0 -5
  3. data/.rubocop.yml +4 -1
  4. data/.travis.yml +3 -3
  5. data/CHANGELOG.md +29 -10
  6. data/Gemfile +5 -7
  7. data/README.md +114 -62
  8. data/Rakefile +2 -2
  9. data/alchemy_cms.gemspec +5 -5
  10. data/app/assets/images/alchemy/icon.svg +1 -1
  11. data/app/assets/javascripts/alchemy/admin.js +2 -0
  12. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +0 -24
  13. data/app/assets/javascripts/alchemy/alchemy.datepicker.js.coffee +11 -9
  14. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +7 -24
  15. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +9 -8
  16. data/app/assets/javascripts/alchemy/alchemy.fixed_elements.js +38 -0
  17. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +2 -4
  18. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +1 -1
  19. data/app/assets/stylesheets/alchemy/_mixins.scss +2 -1
  20. data/app/assets/stylesheets/alchemy/_variables.scss +7 -2
  21. data/app/assets/stylesheets/alchemy/admin.scss +2 -1
  22. data/app/assets/stylesheets/alchemy/archive.scss +18 -4
  23. data/app/assets/stylesheets/alchemy/buttons.scss +1 -1
  24. data/app/assets/stylesheets/alchemy/dialogs.scss +1 -1
  25. data/app/assets/stylesheets/alchemy/elements.scss +154 -90
  26. data/app/assets/stylesheets/alchemy/filter_field.scss +30 -0
  27. data/app/assets/stylesheets/alchemy/flatpickr.scss +839 -0
  28. data/app/assets/stylesheets/alchemy/forms.scss +5 -1
  29. data/app/assets/stylesheets/alchemy/frame.scss +6 -14
  30. data/app/assets/stylesheets/alchemy/navigation.scss +109 -98
  31. data/app/assets/stylesheets/alchemy/search.scss +11 -29
  32. data/app/assets/stylesheets/alchemy/tables.scss +0 -23
  33. data/app/assets/stylesheets/alchemy/tags.scss +4 -27
  34. data/app/assets/stylesheets/alchemy/toolbar.scss +12 -2
  35. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +4 -33
  36. data/app/controllers/alchemy/admin/attachments_controller.rb +1 -12
  37. data/app/controllers/alchemy/admin/contents_controller.rb +2 -24
  38. data/app/controllers/alchemy/admin/elements_controller.rb +11 -49
  39. data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
  40. data/app/controllers/alchemy/admin/pictures_controller.rb +1 -14
  41. data/app/controllers/alchemy/api/contents_controller.rb +1 -1
  42. data/app/controllers/alchemy/api/elements_controller.rb +1 -1
  43. data/app/controllers/alchemy/api/pages_controller.rb +1 -1
  44. data/app/controllers/concerns/alchemy/admin/archive_overlay.rb +20 -0
  45. data/app/helpers/alchemy/admin/base_helper.rb +8 -18
  46. data/app/helpers/alchemy/admin/elements_helper.rb +55 -85
  47. data/app/helpers/alchemy/admin/pictures_helper.rb +0 -23
  48. data/app/helpers/alchemy/elements_helper.rb +80 -120
  49. data/app/helpers/alchemy/pages_helper.rb +5 -24
  50. data/app/models/alchemy/content.rb +0 -1
  51. data/app/models/alchemy/content/factory.rb +33 -57
  52. data/app/models/alchemy/element.rb +46 -66
  53. data/app/models/alchemy/element/element_contents.rb +2 -2
  54. data/app/models/alchemy/page.rb +34 -4
  55. data/app/models/alchemy/page/page_elements.rb +30 -122
  56. data/app/serializers/alchemy/attachment_serializer.rb +0 -2
  57. data/app/serializers/alchemy/content_serializer.rb +0 -2
  58. data/app/serializers/alchemy/element_serializer.rb +0 -3
  59. data/app/serializers/alchemy/essence_boolean_serializer.rb +0 -2
  60. data/app/serializers/alchemy/essence_date_serializer.rb +0 -2
  61. data/app/serializers/alchemy/essence_file_serializer.rb +0 -2
  62. data/app/serializers/alchemy/essence_html_serializer.rb +0 -2
  63. data/app/serializers/alchemy/essence_link_serializer.rb +0 -2
  64. data/app/serializers/alchemy/essence_picture_serializer.rb +0 -2
  65. data/app/serializers/alchemy/essence_richtext_serializer.rb +0 -2
  66. data/app/serializers/alchemy/essence_select_serializer.rb +0 -2
  67. data/app/serializers/alchemy/essence_text_serializer.rb +0 -2
  68. data/app/serializers/alchemy/legacy_element_serializer.rb +0 -3
  69. data/app/serializers/alchemy/page_serializer.rb +2 -8
  70. data/app/serializers/alchemy/page_tree_serializer.rb +1 -1
  71. data/app/serializers/alchemy/picture_serializer.rb +0 -2
  72. data/app/views/alchemy/admin/clipboard/index.html.erb +2 -2
  73. data/app/views/alchemy/admin/clipboard/insert.js.erb +9 -12
  74. data/app/views/alchemy/admin/contents/create.js.erb +4 -30
  75. data/app/views/alchemy/admin/elements/_element.html.erb +27 -12
  76. data/app/views/alchemy/admin/elements/_element_toolbar.html.erb +1 -1
  77. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +0 -10
  78. data/app/views/alchemy/admin/elements/create.js.erb +12 -12
  79. data/app/views/alchemy/admin/elements/fold.js.erb +1 -1
  80. data/app/views/alchemy/admin/elements/index.html.erb +20 -19
  81. data/app/views/alchemy/admin/elements/publish.js.erb +5 -0
  82. data/app/views/alchemy/admin/elements/trash.js.erb +4 -1
  83. data/app/views/alchemy/admin/essence_pictures/assign.js.erb +0 -7
  84. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +0 -22
  85. data/app/views/alchemy/admin/pages/_publication_fields.html.erb +2 -4
  86. data/app/views/alchemy/admin/pages/edit.html.erb +1 -1
  87. data/app/views/alchemy/admin/pages/index.html.erb +14 -10
  88. data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +1 -1
  89. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +1 -1
  90. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +7 -5
  91. data/app/views/alchemy/admin/partials/_routes.html.erb +0 -1
  92. data/app/views/alchemy/admin/partials/_search_form.html.erb +6 -4
  93. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +6 -3
  94. data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
  95. data/app/views/alchemy/admin/trash/index.html.erb +8 -7
  96. data/app/views/alchemy/elements/_editor_not_found.html.erb +1 -1
  97. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +4 -19
  98. data/app/views/layouts/alchemy/admin.html.erb +1 -0
  99. data/bin/rspec +0 -5
  100. data/config/alchemy/config.yml +3 -0
  101. data/config/brakeman.ignore +1 -1
  102. data/config/locales/alchemy.en.yml +6 -12
  103. data/config/routes.rb +1 -5
  104. data/db/migrate/20180226123013_alchemy_four_point_zero.rb +0 -29
  105. data/db/migrate/20180519204655_add_fixed_to_alchemy_elements.rb +6 -0
  106. data/lib/alchemy/admin/locale.rb +1 -1
  107. data/lib/alchemy/cache_digests/template_tracker.rb +4 -27
  108. data/lib/alchemy/elements_finder.rb +111 -0
  109. data/lib/alchemy/errors.rb +0 -4
  110. data/lib/alchemy/modules.rb +49 -18
  111. data/lib/alchemy/tasks/tidy.rb +3 -40
  112. data/lib/alchemy/test_support/controller_requests.rb +1 -1
  113. data/lib/alchemy/test_support/essence_shared_examples.rb +1 -1
  114. data/lib/alchemy/test_support/factories/attachment_factory.rb +5 -3
  115. data/lib/alchemy/test_support/factories/content_factory.rb +4 -4
  116. data/lib/alchemy/test_support/factories/dummy_user_factory.rb +5 -5
  117. data/lib/alchemy/test_support/factories/element_factory.rb +12 -7
  118. data/lib/alchemy/test_support/factories/essence_text_factory.rb +1 -1
  119. data/lib/alchemy/test_support/factories/language_factory.rb +13 -13
  120. data/lib/alchemy/test_support/factories/page_factory.rb +18 -17
  121. data/lib/alchemy/test_support/factories/picture_factory.rb +6 -4
  122. data/lib/alchemy/test_support/factories/site_factory.rb +6 -6
  123. data/lib/alchemy/tinymce.rb +1 -1
  124. data/lib/alchemy/upgrader/four_point_two.rb +68 -0
  125. data/lib/alchemy/upgrader/tasks/cells_migration.rb +41 -0
  126. data/lib/alchemy/upgrader/tasks/cells_upgrader.rb +146 -0
  127. data/lib/alchemy/upgrader/tasks/picture_gallery_migration.rb +65 -0
  128. data/lib/alchemy/upgrader/tasks/picture_gallery_upgrader.rb +195 -0
  129. data/lib/alchemy/version.rb +1 -1
  130. data/lib/alchemy_cms.rb +1 -0
  131. data/lib/rails/generators/alchemy/elements/elements_generator.rb +1 -0
  132. data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +0 -3
  133. data/lib/rails/generators/alchemy/elements/templates/editor.html.haml +0 -3
  134. data/lib/rails/generators/alchemy/elements/templates/editor.html.slim +0 -3
  135. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +3 -14
  136. data/lib/rails/generators/alchemy/elements/templates/view.html.haml +3 -10
  137. data/lib/rails/generators/alchemy/elements/templates/view.html.slim +3 -10
  138. data/lib/tasks/alchemy/tidy.rake +1 -23
  139. data/lib/tasks/alchemy/upgrade.rake +44 -1
  140. data/vendor/assets/javascripts/flatpickr/flatpickr.min.js +2 -0
  141. data/vendor/assets/javascripts/tinymce/license.txt +0 -0
  142. data/vendor/assets/javascripts/tinymce/tinymce.min.js +2 -2
  143. metadata +25 -31
  144. data/app/assets/stylesheets/alchemy/jquery.datetimepicker.scss +0 -478
  145. data/app/models/alchemy/cell.rb +0 -95
  146. data/app/models/alchemy/page/page_cells.rb +0 -69
  147. data/app/serializers/alchemy/cell_serializer.rb +0 -19
  148. data/app/views/alchemy/admin/contents/new.html.erb +0 -11
  149. data/app/views/alchemy/admin/contents/order.js.erb +0 -3
  150. data/app/views/alchemy/admin/elements/_add_picture.html.erb +0 -14
  151. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +0 -24
  152. data/bin/spring +0 -16
  153. data/lib/alchemy/test_support/factories/cell_factory.rb +0 -9
  154. data/vendor/assets/javascripts/date-formatter.js +0 -161
  155. data/vendor/assets/javascripts/jquery_plugins/jquery.datetimepicker.full.min.js +0 -2
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class AttachmentSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :name,
9
7
  :file_name,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class ContentSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :name,
9
7
  :ingredient,
@@ -2,13 +2,10 @@
2
2
 
3
3
  module Alchemy
4
4
  class ElementSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :name,
9
7
  :position,
10
8
  :page_id,
11
- :cell_id,
12
9
  :tag_list,
13
10
  :created_at,
14
11
  :updated_at,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceBooleanSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :value,
9
7
  :created_at,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceDateSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :date,
9
7
  :created_at,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceFileSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :title,
9
7
  :css_class
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceHtmlSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :source,
9
7
  :created_at,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceLinkSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :link,
9
7
  :link_title,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssencePictureSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :picture_id,
9
7
  :caption,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceRichtextSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :body,
9
7
  :stripped_body,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceSelectSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :value,
9
7
  :created_at,
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class EssenceTextSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :body,
9
7
  :link,
@@ -2,13 +2,10 @@
2
2
 
3
3
  module Alchemy
4
4
  class LegacyElementSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :name,
9
7
  :position,
10
8
  :page_id,
11
- :cell_id,
12
9
  :tag_list,
13
10
  :created_at,
14
11
  :updated_at
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class PageSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :name,
9
7
  :urlname,
@@ -17,14 +15,10 @@ module Alchemy
17
15
  :updated_at,
18
16
  :status
19
17
 
20
- has_many :elements, :cells
18
+ has_many :elements
21
19
 
22
20
  def elements
23
- if object.has_cells?
24
- object.elements.not_in_cell.published
25
- else
26
- object.elements.published
27
- end
21
+ object.elements.published
28
22
  end
29
23
  end
30
24
  end
@@ -67,7 +67,7 @@ module Alchemy
67
67
  }
68
68
 
69
69
  if opts[:elements]
70
- p_hash.update(elements: ActiveModel::ArraySerializer.new(page_elements(page)))
70
+ p_hash.update(elements: ActiveModel::Serializer::CollectionSerializer.new(page_elements(page)))
71
71
  end
72
72
 
73
73
  if opts[:ability].can?(:index, :alchemy_admin_pages)
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Alchemy
4
4
  class PictureSerializer < ActiveModel::Serializer
5
- self.root = false
6
-
7
5
  attributes :id,
8
6
  :name,
9
7
  :image_file_name,
@@ -10,14 +10,14 @@
10
10
  <li id="clipboard_item_<%= item.id -%>" class="<%= item_class -%>">
11
11
  <% if item_class == 'pages' %>
12
12
  <%= render_icon(:file, style: 'regular') %>
13
- <%= item.name %>
13
+ <%= truncate(item.name, length: 50) %>
14
14
  <% else %>
15
15
  <% if item.public? %>
16
16
  <%= render_icon('window-maximize', style: 'regular', class: 'element') %>
17
17
  <% else %>
18
18
  <%= render_icon('window-close', class: 'element') %>
19
19
  <% end %>
20
- <%= item.display_name_with_preview_text(60) %>
20
+ <%= truncate(item.display_name_with_preview_text(50), length: 50) %>
21
21
  <% end %>
22
22
  <span class="float_right">
23
23
  <%= link_to render_icon(:times, size: 'xs'),
@@ -1,19 +1,16 @@
1
1
  <% if params[:remove] -%>
2
+ $(".element-editor[data-element-id='<%= @item.id %>']").remove();
2
3
 
3
- $(".element-editor[data-element-id='<%= @item.id %>']").remove();
4
+ <% if @item.class.name == 'Alchemy::Element' -%>
5
+ $('#element_area .sortable-elements').sortable('refresh');
4
6
 
5
- <% if @item.class.to_s == 'Element' -%>
6
-
7
- $('#element_area .sortable_cell').sortable('refresh');
8
-
9
- <% end -%>
10
-
11
- Alchemy.growl('<%= j Alchemy.t("item moved to clipboard", name: @item.class.to_s == "Alchemy::Element" ? @item.display_name_with_preview_text : @item.name) %>');
7
+ <% if @item.fixed? -%>
8
+ Alchemy.FixedElements.removeTab(<%= @item.id %>);
9
+ <% end -%>
10
+ <% end -%>
12
11
 
12
+ Alchemy.growl('<%= j Alchemy.t("item moved to clipboard", name: @item.class.name == "Alchemy::Element" ? @item.display_name_with_preview_text : @item.name) %>');
13
13
  <% else -%>
14
-
15
- Alchemy.growl('<%= j Alchemy.t("item copied to clipboard", name: @item.class.to_s == "Alchemy::Element" ? @item.display_name_with_preview_text : @item.name) %>')
16
-
14
+ Alchemy.growl('<%= j Alchemy.t("item copied to clipboard", name: @item.class.name == "Alchemy::Element" ? @item.display_name_with_preview_text : @item.name) %>')
17
15
  <% end -%>
18
-
19
16
  $('#clipboard_button .icon').removeClass('fa-clipboard').addClass('fa-paste');
@@ -2,41 +2,15 @@ var editor_html = '<%= j(render "alchemy/essences/#{@content.essence_partial_nam
2
2
  content: @content, options: options_from_params, html_options: @html_options
3
3
  }) %>';
4
4
 
5
- <% if params[:was_missing] %>
5
+ $("[data-element-<%= @content.element_id %>-missing-content=\"<%= @content.name %>\"]").replaceWith(editor_html);
6
6
 
7
- $("[data-element-<%= @element.id %>-missing-content=\"<%= @content.name %>\"]").replaceWith(editor_html);
7
+ <% if @content.essence_type == "Alchemy::EssencePicture" && @content.ingredient %>
8
8
 
9
- <% else %>
10
-
11
- $("<%= @content_dom_id %>").before(editor_html);
12
- Alchemy.Buttons.enable();
13
- Alchemy.growl('<%= j Alchemy.t("Successfully added content") % {content: @content.name_for_label} %>')
14
-
15
- <% end %>
16
-
17
- <% if @content.essence_type == "Alchemy::EssencePicture" %>
18
-
19
- <% if @content.ingredient %>
20
9
  $('#picture_to_assign_<%= @content.ingredient.id %> a').attr('href', '#').off('click');
21
- <% end %>
22
-
23
- <% if @gallery_pictures %>
24
-
25
- <% if @gallery_pictures.size > 1 %>
26
- $('#element_<%= @element.id %>_contents .essence_picture').addClass('draggable_picture');
27
- <% end %>
28
-
29
- <% if !max_image_count.blank? && @gallery_pictures.size >= max_image_count %>
30
- $("#add_picture_<%= @element.id %>").remove();
31
- <% end %>
32
-
33
- Alchemy.SortableContents('#element_<%= @element.id %>_contents', '<%= form_authenticity_token %>');
34
-
35
- <% end %>
36
10
 
37
11
  <% elsif @content.essence_type == "Alchemy::EssenceDate" %>
38
12
 
39
- Alchemy.Datepicker('#element_<%= @element.id %>');
13
+ Alchemy.Datepicker('#element_<%= @content.element_id %>');
40
14
 
41
15
  <% elsif @content.essence_type == "Alchemy::EssenceRichtext" %>
42
16
 
@@ -46,4 +20,4 @@ Alchemy.Tinymce.initEditor(<%= @content.id %>);
46
20
 
47
21
  Alchemy.reloadPreview();
48
22
  Alchemy.closeCurrentDialog();
49
- Alchemy.SelectBox("#element_<%= @element.id %>");
23
+ Alchemy.SelectBox("#element_<%= @content.element_id %>");
@@ -1,11 +1,13 @@
1
1
  <%= content_tag :div,
2
2
  id: "element_#{element.id}",
3
3
  data: {'element-id' => element.id, 'element-name' => element.name},
4
- class: element_editor_classes(element, local_assigns) do %>
4
+ class: element_editor_classes(element) do %>
5
5
 
6
- <%= render 'alchemy/admin/elements/element_header', element: element %>
6
+ <% unless element.fixed? %>
7
+ <%= render 'alchemy/admin/elements/element_header', element: element %>
8
+ <% end %>
7
9
 
8
- <% if element.expanded? %>
10
+ <% if element.expanded? || element.fixed? %>
9
11
  <%= render 'alchemy/admin/elements/element_toolbar', element: element %>
10
12
 
11
13
  <%= form_for [alchemy, :admin, element], remote: true,
@@ -38,15 +40,28 @@
38
40
  <%= render partial: 'alchemy/admin/elements/element', collection: element.nested_elements %>
39
41
  <% end %>
40
42
 
41
- <% if element.expanded? %>
42
- <%= link_to_dialog render_icon(:plus, size: 'xs') + Alchemy.t("New Element"),
43
- alchemy.new_admin_element_path(
44
- parent_element_id: element.id,
45
- page_id: element.page.id
46
- ), {
47
- size: "320x125",
48
- title: Alchemy.t("New Element")
49
- }, class: "button with_icon add-nestable-element-button" %>
43
+ <% if element.expanded? || element.fixed? %>
44
+ <% if element.nestable_elements.length == 1 %>
45
+ <% nestable_element = element.nestable_elements.first %>
46
+ <%= form_for [:admin, Alchemy::Element.new(name: nestable_element)],
47
+ remote: true, html: { class: 'add-nested-element-form', id: nil } do |f| %>
48
+ <%= f.hidden_field :name %>
49
+ <%= f.hidden_field :page_id, value: element.page_id %>
50
+ <%= f.hidden_field :parent_element_id, value: element.id %>
51
+ <button class="button add-nestable-element-button" data-alchemy-button>
52
+ <%= Alchemy.t(:add_nested_element) % { name: Alchemy.t(nestable_element, scope: 'element_names') } %>
53
+ </button>
54
+ <% end %>
55
+ <% else %>
56
+ <%= link_to_dialog Alchemy.t("New Element"),
57
+ alchemy.new_admin_element_path(
58
+ parent_element_id: element.id,
59
+ page_id: element.page.id
60
+ ), {
61
+ size: "320x125",
62
+ title: Alchemy.t("New Element")
63
+ }, class: "button add-nestable-element-button" %>
64
+ <% end %>
50
65
  <% end %>
51
66
  </div>
52
67
  <% end %>
@@ -33,7 +33,7 @@
33
33
  </div>
34
34
  <div class="button_with_label publish-element-button">
35
35
  <%= link_to(
36
- render_icon('eye-slash'),
36
+ render_icon(element.public? ? 'eye-slash' : 'eye'),
37
37
  alchemy.publish_admin_element_path(id: element.id),
38
38
  remote: true,
39
39
  method: :patch,
@@ -5,21 +5,11 @@
5
5
  <%- else -%>
6
6
  <%= alchemy_form_for [:admin, @element] do |form| %>
7
7
  <%= form.hidden_field :page_id %>
8
- <%- if @page.can_have_cells? && @parent_element.blank? -%>
9
- <%= form.input :name,
10
- label: Alchemy.t(:element_of_type),
11
- collection: grouped_elements_for_select(@elements),
12
- as: :grouped_select,
13
- group_method: :second,
14
- prompt: Alchemy.t(:select_element),
15
- input_html: {class: 'alchemy_selectbox', autofocus: true} %>
16
- <%- else -%>
17
8
  <%= form.input :name,
18
9
  label: Alchemy.t(:element_of_type),
19
10
  collection: elements_for_select(@elements),
20
11
  prompt: Alchemy.t(:select_element),
21
12
  input_html: {class: 'alchemy_selectbox', autofocus: true} %>
22
- <%- end -%>
23
13
  <%= form.hidden_field :parent_element_id, value: @parent_element.try(:id) %>
24
14
  <%= form.submit Alchemy.t(:add) %>
25
15
  <%- end -%>
@@ -3,22 +3,22 @@
3
3
  var $element_area;
4
4
  var element_html = '<%= j render("element", element: @element, draggable: true) %>';
5
5
 
6
- <%- if @cutted_element_id -%>
7
- $('.element-editor[data-element-id="<%= @cutted_element_id %>"]').remove();
6
+ <%- if @cut_element_id -%>
7
+ $('.element-editor[data-element-id="<%= @cut_element_id %>"]').remove();
8
8
  <%- end -%>
9
9
 
10
- <%- if @page.can_have_cells? -%>
11
- if ($('#cells').length == 0) {
12
- Alchemy.buildTabbedCells('<%= Alchemy.t(:main_content) %>');
10
+ <% if @element.fixed? %>
11
+ if ($('#fixed-elements').length == 0) {
12
+ Alchemy.FixedElements.buildTabs('<%= Alchemy.t(:main_content) %>');
13
13
  }
14
- Alchemy.selectOrCreateCellTab('<%= @cell_name %>', '<%= @cell.nil? ? Alchemy.t(:main_content) : @cell.name_for_label %>');
15
- <%- end -%>
16
-
17
- <%- if @element.parent_element -%>
14
+ Alchemy.FixedElements.createTab('<%= @element.id %>', '<%= @element.display_name %>');
15
+ $element_area = $('#fixed-element-<%= @element.id %>');
16
+ <% elsif @element.parent_element %>
18
17
  $element_area = $('#element_<%= @element.parent_element_id %> > .nestable-elements > .nested-elements');
19
- <%- else -%>
20
- $element_area = $('#cell_<%= @cell_name %>');
21
- <%- end -%>
18
+ Alchemy.Buttons.enable('.nestable-elements');
19
+ <% else %>
20
+ $element_area = $('#main-content-elements');
21
+ <% end %>
22
22
 
23
23
  <%- if @insert_at_top -%>
24
24
  $element_area.prepend(element_html);
@@ -10,7 +10,7 @@
10
10
 
11
11
  $el.replaceWith('<%= j render(partial: "element", object: @element) %>');
12
12
  $el = $('#element_<%= @element.id %>');
13
- $('#element_area .sortable_cell').sortable('refresh');
13
+ $('#element_area .sortable-elements').sortable('refresh');
14
14
 
15
15
  <% if @element.folded? -%>
16
16
 
@@ -1,32 +1,33 @@
1
- <% if @cells.any? %>
2
- <div id="cells">
1
+ <% if @fixed_elements.any? %>
2
+ <div id="fixed-elements">
3
3
  <ul>
4
- <li><a href="#cell_for_other_elements"><%= Alchemy.t(:main_content) %></a></li>
5
- <% @elements.each do |cell, elements| %>
4
+ <li>
5
+ <a href="#main-content-elements">
6
+ <%= Alchemy.t(:main_content) %>
7
+ </a>
8
+ </li>
9
+ <% @fixed_elements.each do |element| %>
6
10
  <li>
7
- <a href="#cell_<%= cell.name %>">
8
- <%= Alchemy.t(cell.name, scope: :cell_names) %>
11
+ <a href="#fixed-element-<%= element.id %>">
12
+ <%= element.display_name %>
9
13
  </a>
10
14
  </li>
11
15
  <% end %>
12
16
  </ul>
13
- <div id="cell_for_other_elements"
14
- class="sortable_cell for_other_elements_cell"
15
- data-droppable-elements="<%= @page.element_names_from_definition.join(' ') %>">
16
- <%= render partial: 'alchemy/admin/elements/element',
17
- collection: @page.elements.not_trashed.not_in_cell %>
17
+ <div id="main-content-elements" class="sortable-elements" data-droppable-elements="<%= @page.element_definition_names.join(' ') %>">
18
+ <%= render partial: 'alchemy/admin/elements/element', collection: @elements %>
18
19
  </div>
19
- <% @elements.each do |cell, elements| -%>
20
- <%= content_tag :div,
21
- id: "cell_#{cell.name}",
22
- class: ["sortable_cell", "#{cell.name}_cell"].join(' '),
23
- data: {'cell-id' => cell.id, 'droppable-elements' => cell.element_definitions.join(' ')} do %>
24
- <%= render partial: 'alchemy/admin/elements/element', collection: elements %>
25
- <% end %>
20
+ <% @fixed_elements.each do |element| %>
21
+ <div
22
+ id="fixed-element-<%= element.id %>"
23
+ class="sortable-elements"
24
+ data-droppable-elements="<%= element.nestable_elements.join(' ') %>">
25
+ <%= render 'alchemy/admin/elements/element', element: element %>
26
+ </div>
26
27
  <% end %>
27
28
  </div>
28
29
  <% else %>
29
- <div class="sortable_cell for_other_elements_cell" id="cell_for_other_elements" data-droppable-elements="<%= @page.element_names_from_definition.join(' ') %>">
30
+ <div id="main-content-elements" class="sortable-elements" data-droppable-elements="<%= @page.element_definition_names.join(' ') %>">
30
31
  <%= render partial: 'alchemy/admin/elements/element', collection: @elements %>
31
32
  </div>
32
33
  <% end %>