alchemy_cms 6.0.0.pre.rc5 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +16 -8
  3. data/.github/workflows/stale.yml +21 -7
  4. data/.gitignore +0 -1
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +89 -0
  7. data/Gemfile +10 -7
  8. data/Rakefile +5 -1
  9. data/alchemy_cms.gemspec +3 -3
  10. data/app/assets/javascripts/alchemy/admin.js +0 -2
  11. data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +6 -1
  12. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +2 -0
  13. data/app/assets/javascripts/alchemy/page_select.js +13 -8
  14. data/app/assets/javascripts/alchemy/templates/index.js +1 -0
  15. data/app/assets/javascripts/alchemy/templates/page.hbs +17 -7
  16. data/app/assets/javascripts/alchemy/templates/page_folder.hbs +3 -0
  17. data/app/assets/stylesheets/alchemy/archive.scss +9 -0
  18. data/app/assets/stylesheets/alchemy/elements.scss +4 -0
  19. data/app/assets/stylesheets/alchemy/page-select.scss +29 -4
  20. data/app/assets/stylesheets/alchemy/sitemap.scss +9 -7
  21. data/app/controllers/alchemy/admin/elements_controller.rb +2 -6
  22. data/app/controllers/alchemy/admin/pages_controller.rb +16 -18
  23. data/app/controllers/alchemy/api/contents_controller.rb +1 -5
  24. data/app/controllers/alchemy/api/elements_controller.rb +2 -6
  25. data/app/controllers/alchemy/api/pages_controller.rb +16 -10
  26. data/app/helpers/alchemy/elements_helper.rb +2 -2
  27. data/app/models/alchemy/ingredient.rb +6 -1
  28. data/app/models/alchemy/page.rb +3 -2
  29. data/app/models/alchemy/picture.rb +1 -1
  30. data/app/serializers/alchemy/page_serializer.rb +7 -1
  31. data/app/serializers/alchemy/page_tree_serializer.rb +3 -3
  32. data/app/views/alchemy/admin/pages/_form.html.erb +19 -0
  33. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +16 -5
  34. data/app/views/alchemy/admin/pages/_page.html.erb +111 -133
  35. data/app/views/alchemy/admin/pages/_sitemap.html.erb +10 -16
  36. data/app/views/alchemy/admin/pages/_toolbar.html.erb +0 -12
  37. data/app/views/alchemy/admin/pages/edit.html.erb +1 -1
  38. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  39. data/app/views/alchemy/admin/pages/update.js.erb +7 -5
  40. data/app/views/alchemy/admin/partials/_routes.html.erb +12 -1
  41. data/app/views/alchemy/admin/resources/_form.html.erb +5 -0
  42. data/app/views/alchemy/essences/_essence_page_editor.html.erb +1 -1
  43. data/config/alchemy/config.yml +1 -0
  44. data/config/locales/alchemy.en.yml +0 -4
  45. data/config/routes.rb +4 -2
  46. data/lib/alchemy/engine.rb +12 -1
  47. data/lib/alchemy/essence.rb +0 -26
  48. data/lib/alchemy/permissions.rb +0 -1
  49. data/lib/alchemy/resource.rb +16 -1
  50. data/lib/alchemy/test_support/essence_shared_examples.rb +0 -12
  51. data/lib/alchemy/test_support/shared_ingredient_examples.rb +4 -2
  52. data/lib/alchemy/upgrader/tasks/ingredients_migrator.rb +1 -1
  53. data/lib/alchemy/version.rb +1 -1
  54. data/lib/generators/alchemy/install/install_generator.rb +6 -1
  55. data/package/admin.js +5 -1
  56. data/package/src/image_loader.js +4 -2
  57. data/package/src/node_tree.js +13 -6
  58. data/package/src/page_publication_fields.js +28 -0
  59. data/package/src/page_sorter.js +62 -0
  60. data/package/src/picture_editors.js +8 -8
  61. data/package/src/sitemap.js +148 -0
  62. data/package/src/utils/__tests__/ajax.spec.js +52 -16
  63. data/package/src/utils/ajax.js +12 -0
  64. data/package.json +1 -1
  65. metadata +43 -43
  66. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +0 -24
  67. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +0 -119
  68. data/app/views/alchemy/admin/pages/fold.js.erb +0 -2
  69. data/app/views/alchemy/admin/pages/sort.html.erb +0 -19
  70. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +0 -434
@@ -46,11 +46,7 @@ module Alchemy
46
46
  private
47
47
 
48
48
  def content_includes
49
- [
50
- {
51
- essence: :ingredient_association,
52
- },
53
- ]
49
+ %i[essence]
54
50
  end
55
51
  end
56
52
  end
@@ -47,18 +47,14 @@ module Alchemy
47
47
  {
48
48
  nested_elements: [
49
49
  {
50
- contents: {
51
- essence: :ingredient_association,
52
- },
50
+ contents: :essence,
53
51
  ingredients: :related_object,
54
52
  },
55
53
  :tags,
56
54
  ],
57
55
  },
58
56
  {
59
- contents: {
60
- essence: :ingredient_association,
61
- },
57
+ contents: :essence,
62
58
  ingredients: :related_object,
63
59
  },
64
60
  :tags,
@@ -2,17 +2,19 @@
2
2
 
3
3
  module Alchemy
4
4
  class Api::PagesController < Api::BaseController
5
+ serialization_scope :current_ability
5
6
  before_action :load_page, only: [:show]
6
7
 
7
8
  # Returns all pages as json object
8
9
  #
9
10
  def index
10
11
  # Fix for cancancan not able to merge multiple AR scopes for logged in users
11
- if cannot? :edit_content, Alchemy::Page
12
- @pages = Alchemy::Page.accessible_by(current_ability, :index)
13
- @pages = @pages.where(language: Language.current)
12
+ if can? :edit_content, Alchemy::Page
13
+ @pages = Alchemy::Page.all
14
14
  else
15
- @pages = Language.current&.pages.presence || Alchemy::Page.none
15
+ language = Alchemy::Language.find_by(id: params[:language_id]) || Alchemy::Language.current
16
+ @pages = Alchemy::Page.accessible_by(current_ability, :index)
17
+ @pages = @pages.where(language: language)
16
18
  end
17
19
  @pages = @pages.includes(*page_includes)
18
20
  @pages = @pages.ransack(params[:q]).result
@@ -49,6 +51,14 @@ module Alchemy
49
51
  respond_with @page
50
52
  end
51
53
 
54
+ def move
55
+ @page = Page.find(params[:id])
56
+ authorize! :update, @page
57
+ target_parent_page = Page.find(params[:target_parent_id])
58
+ @page.move_to_child_with_index(target_parent_page, params[:new_position])
59
+ render json: @page, serializer: PageSerializer
60
+ end
61
+
52
62
  private
53
63
 
54
64
  def load_page
@@ -102,17 +112,13 @@ module Alchemy
102
112
  {
103
113
  nested_elements: [
104
114
  {
105
- contents: {
106
- essence: :ingredient_association,
107
- },
115
+ contents: :essence,
108
116
  },
109
117
  :tags,
110
118
  ],
111
119
  },
112
120
  {
113
- contents: {
114
- essence: :ingredient_association,
115
- },
121
+ contents: :essence,
116
122
  },
117
123
  :tags,
118
124
  ],
@@ -149,8 +149,8 @@ module Alchemy
149
149
  render element, {
150
150
  element: element,
151
151
  counter: counter,
152
- options: options,
153
- }.merge(options.delete(:locals) || {})
152
+ options: options.except(:locals),
153
+ }.merge(options[:locals] || {})
154
154
  rescue ActionView::MissingTemplate => e
155
155
  warning(%(
156
156
  Element view partial not found for #{element.name}.\n
@@ -11,7 +11,8 @@ module Alchemy
11
11
  belongs_to :element, touch: true, class_name: "Alchemy::Element", inverse_of: :ingredients
12
12
  belongs_to :related_object, polymorphic: true, optional: true
13
13
 
14
- before_validation(on: :create) { self.value ||= default_value }
14
+ after_initialize :set_default_value,
15
+ if: -> { definition.key?(:default) && value.nil? }
15
16
 
16
17
  validates :type, presence: true
17
18
  validates :role, presence: true
@@ -161,6 +162,10 @@ module Alchemy
161
162
  role
162
163
  end
163
164
 
165
+ def set_default_value
166
+ self.value = default_value
167
+ end
168
+
164
169
  # Returns the default value from ingredient definition
165
170
  #
166
171
  # If the value is a symbol it gets passed through i18n
@@ -245,8 +245,8 @@ module Alchemy
245
245
 
246
246
  def copy_and_paste(source, new_parent, new_name)
247
247
  page = copy(source, {
248
- parent_id: new_parent.id,
249
- language: new_parent.language,
248
+ parent: new_parent,
249
+ language: new_parent&.language,
250
250
  name: new_name,
251
251
  title: new_name,
252
252
  })
@@ -448,6 +448,7 @@ module Alchemy
448
448
  next if child == new_parent
449
449
 
450
450
  new_child = Page.copy(child, {
451
+ parent_id: new_parent.id,
451
452
  language_id: new_parent.language_id,
452
453
  language_code: new_parent.language_code,
453
454
  })
@@ -28,7 +28,7 @@ module Alchemy
28
28
  large: "240x180",
29
29
  }.with_indifferent_access.freeze
30
30
 
31
- CONVERTIBLE_FILE_FORMATS = %w(gif jpg jpeg png).freeze
31
+ CONVERTIBLE_FILE_FORMATS = %w[gif jpg jpeg png webp].freeze
32
32
 
33
33
  TRANSFORMATION_OPTIONS = [
34
34
  :crop,
@@ -14,8 +14,14 @@ module Alchemy
14
14
  :created_at,
15
15
  :updated_at,
16
16
  :status,
17
- :url_path
17
+ :url_path,
18
+ :parent_id
18
19
 
19
20
  has_many :elements
21
+
22
+ with_options if: -> { scope.can?(:edit_content, object) } do
23
+ belongs_to :site
24
+ belongs_to :language
25
+ end
20
26
  end
21
27
  end
@@ -3,13 +3,13 @@
3
3
  module Alchemy
4
4
  class PageTreeSerializer < BaseSerializer
5
5
  def attributes
6
- {"pages" => nil}
6
+ { "pages" => nil }
7
7
  end
8
8
 
9
9
  def pages
10
10
  tree = []
11
- path = [{id: object.parent_id, children: tree}]
12
- page_list = object.self_and_descendants
11
+ path = [{ id: object.parent_id, children: tree }]
12
+ page_list = object.self_and_descendants.includes(:public_version, { language: :site })
13
13
  base_level = object.level - 1
14
14
  # Load folded pages in advance
15
15
  folded_user_pages = FoldedPage.folded_for_user(opts[:user]).pluck(:page_id)
@@ -1,4 +1,8 @@
1
1
  <%= alchemy_form_for [:admin, @page], class: 'edit_page' do |f| %>
2
+ <% unless @page.language_root? || @page.layoutpage %>
3
+ <%= f.input :parent_id, required: true, input_html: { class: 'alchemy_selectbox' } %>
4
+ <% end %>
5
+
2
6
  <div class="input check_boxes">
3
7
  <label class="control-label"><%= Alchemy.t(:page_status) %></label>
4
8
  <div class="control_group">
@@ -37,3 +41,18 @@
37
41
 
38
42
  <%= f.submit Alchemy.t(:save) %>
39
43
  <% end %>
44
+
45
+ <script>
46
+ $('#page_parent_id').alchemyPageSelect({
47
+ placeholder: "<%= Alchemy.t(:search_page) %>",
48
+ url: "<%= alchemy.api_pages_path %>",
49
+ allowClear: false,
50
+ <% if @page.parent %>
51
+ initialSelection: {
52
+ id: <%= @page.parent.id %>,
53
+ text: "<%= @page.parent.name %>",
54
+ url_path: "<%= @page.parent.url_path %>"
55
+ }
56
+ <% end %>
57
+ })
58
+ </script>
@@ -3,11 +3,7 @@
3
3
  <%= f.hidden_field(:parent_id) %>
4
4
  <% else %>
5
5
  <% @page.parent = @current_language.root_page %>
6
- <%= f.input :parent_id,
7
- collection: @current_language.pages.contentpages,
8
- label_method: :name,
9
- value_method: :id,
10
- input_html: { class: "alchemy_selectbox" } %>
6
+ <%= f.input :parent_id, as: :string, input_html: { class: 'alchemy_selectbox' } %>
11
7
  <% end %>
12
8
  <%= f.hidden_field(:language_id) %>
13
9
  <%= f.hidden_field(:layoutpage) %>
@@ -21,3 +17,18 @@
21
17
  <%= f.input :name %>
22
18
  <%= f.submit Alchemy.t(:create) %>
23
19
  <% end %>
20
+
21
+ <script>
22
+ $('input[type="text"]#page_parent_id').alchemyPageSelect({
23
+ placeholder: "<%= Alchemy.t(:search_page) %>",
24
+ url: "<%= alchemy.api_pages_path %>",
25
+ allowClear: false,
26
+ <% if @page.parent %>
27
+ initialSelection: {
28
+ id: <%= @page.parent.id %>,
29
+ text: "<%= @page.parent.name %>",
30
+ url_path: "<%= @page.parent.url_path %>"
31
+ }
32
+ <% end %>
33
+ })
34
+ </script>
@@ -1,24 +1,7 @@
1
- <li id="page_{{id}}" class="page_level_{{level}} {{page_layout}}" data-slug="{{slug}}" data-restricted="{{restricted}}">
1
+ <li id="page_{{id}}" class="sitemap-item {{page_layout}}" data-slug="{{slug}}" data-restricted="{{restricted}}" data-page-id="{{id}}" data-folded="{{folded}}">
2
2
  <div class="sitemap_page{{#if locked}} locked{{/if}}" name="{{name}}">
3
- <div class="sitemap_left_images<% if @sorting %>{{#unless root}} handle{{/unless}}<% end %>">
4
- <% unless @sorting %>
5
- {{#unless root_or_leaf}}
6
- <%= link_to(
7
- alchemy.fold_admin_page_path(page),
8
- remote: true,
9
- method: :post,
10
- class: "page_folder",
11
- title: "{{#if folded}}#{Alchemy.t('Show childpages')}{{else}}#{Alchemy.t('Hide childpages')}{{/if}}",
12
- id: "fold_button_{{id}}"
13
- ) do %>
14
- {{#if folded}}
15
- <i class="far fa-plus-square fa-fw"></i>
16
- {{else}}
17
- <i class="far fa-minus-square fa-fw"></i>
18
- {{/if}}
19
- <% end %>
20
- {{/unless}}
21
- <% end %>
3
+ <div class="sitemap_left_images">
4
+ <span class="page_folder"></span>
22
5
  {{#if definition_missing}}
23
6
  <%= page_layout_missing_warning %>
24
7
  {{else}}
@@ -31,121 +14,121 @@
31
14
  </span>
32
15
  </span>
33
16
  {{else}}
17
+ <span class="{{#unless root}}handle{{/unless}}">
34
18
  <i class="icon far fa-file fa-lg"></i>
19
+ </span>
35
20
  {{/if}}
36
21
  {{else}}
37
22
  <span class="with-hint">
38
23
  <i class="icon fas fa-ban fa-fw"></i>
39
24
  <span class="hint-bubble">
40
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
25
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
41
26
  </span>
42
27
  </span>
43
28
  {{/if}}
44
29
  {{/if}}
45
30
  </div>
46
31
  <div class="sitemap_right_tools">
47
- <%- unless @sorting -%>
48
- {{#if permissions.info}}
49
- <div class="button_with_label sitemap_tool">
50
- <%= link_to_dialog(
51
- render_icon('info-circle'),
52
- alchemy.info_admin_page_path(page),
53
- {
54
- title: Alchemy.t(:page_infos),
55
- size: '520x290'
56
- }
57
- ) %>
58
- <label class="center"><%= Alchemy.t(:page_infos) %></label>
59
- {{else}}
60
- <div class="sitemap_tool disabled with-hint">
61
- <%= render_icon('info-circle') %>
62
- <span class="hint-bubble">
63
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
64
- </span>
65
- {{/if}}
66
- </div>
67
- {{#if permissions.configure}}
68
- <div class="button_with_label sitemap_tool">
69
- <%= link_to_dialog(
70
- render_icon(:cog),
71
- alchemy.configure_admin_page_path(page),
72
- {
73
- title: Alchemy.t(:edit_page_properties),
74
- size: '450x680'
75
- }
76
- ) -%>
77
- <label class="center"><%= Alchemy.t(:edit_page_properties) %></label>
78
- {{else}}
79
- <div class="sitemap_tool disabled with-hint">
80
- <%= render_icon(:cog) %>
81
- <span class="hint-bubble">
82
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
83
- </span>
84
- {{/if}}
85
- </div>
86
- {{#if permissions.copy}}
87
- <div class="button_with_label sitemap_tool">
88
- <%= link_to(
89
- render_icon(:copy),
90
- alchemy.insert_admin_clipboard_path(
91
- remarkable_type: page.class.name.demodulize.underscore.pluralize,
92
- remarkable_id: '__ID__',
93
- ).gsub('__ID__', '{{id}}'),
94
- remote: true,
95
- method: 'post'
96
- ) %>
97
- <label class="center"><%= Alchemy.t(:copy_page) %></label>
98
- {{else}}
99
- <div class="sitemap_tool disabled with-hint">
100
- <%= render_icon(:copy) %>
101
- <span class="hint-bubble">
102
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
103
- </span>
104
- {{/if}}
105
- </div>
106
- {{#if permissions.destroy}}
107
- <div class="button_with_label sitemap_tool">
108
- <%= link_to_confirm_dialog(
109
- render_icon(:minus),
110
- Alchemy.t(:confirm_to_delete_page),
111
- url_for(
112
- controller: 'pages',
113
- action: 'destroy',
114
- id: '__ID__'
115
- ).gsub('__ID__', '{{id}}')
116
- ) -%>
117
- <label class="center"><%= Alchemy.t(:delete_page) %></label>
118
- {{else}}
119
- <div class="sitemap_tool disabled with-hint">
120
- <%= render_icon(:minus) %>
121
- <span class="hint-bubble">
122
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
123
- </span>
124
- {{/if}}
125
- </div>
126
- {{#if permissions.create}}
127
- <div class="button_with_label sitemap_tool">
128
- <%= link_to_dialog(
129
- render_icon(:plus),
130
- alchemy.new_admin_page_path(parent_id: '__ID__').gsub('__ID__', '{{id}}'),
131
- {
132
- title: Alchemy.t(:create_page),
133
- size: '340x165',
134
- overflow: true
135
- }
136
- ) -%>
137
- <label class="left"><%= Alchemy.t(:create_page) %></label>
138
- {{else}}
139
- <div class="sitemap_tool disabled with-hint">
140
- <%= render_icon(:plus) %>
141
- <span class="hint-bubble">
142
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
143
- </span>
144
- {{/if}}
145
- </div>
146
- <%- end -%>
32
+ {{#if permissions.info}}
33
+ <div class="button_with_label sitemap_tool">
34
+ <%= link_to_dialog(
35
+ render_icon("info-circle"),
36
+ alchemy.info_admin_page_path(id: "__ID__"),
37
+ {
38
+ title: Alchemy.t(:page_infos),
39
+ size: "520x290"
40
+ }
41
+ ) %>
42
+ <label class="center"><%= Alchemy.t(:page_infos) %></label>
43
+ {{else}}
44
+ <div class="sitemap_tool disabled with-hint">
45
+ <%= render_icon("info-circle") %>
46
+ <span class="hint-bubble">
47
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
48
+ </span>
49
+ {{/if}}
50
+ </div>
51
+ {{#if permissions.configure}}
52
+ <div class="button_with_label sitemap_tool">
53
+ <%= link_to_dialog(
54
+ render_icon(:cog),
55
+ alchemy.configure_admin_page_path(id: "__ID__"),
56
+ {
57
+ title: Alchemy.t(:edit_page_properties),
58
+ size: "450x680"
59
+ }
60
+ ) -%>
61
+ <label class="center"><%= Alchemy.t(:edit_page_properties) %></label>
62
+ {{else}}
63
+ <div class="sitemap_tool disabled with-hint">
64
+ <%= render_icon(:cog) %>
65
+ <span class="hint-bubble">
66
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
67
+ </span>
68
+ {{/if}}
69
+ </div>
70
+ {{#if permissions.copy}}
71
+ <div class="button_with_label sitemap_tool">
72
+ <%= link_to(
73
+ render_icon(:copy),
74
+ alchemy.insert_admin_clipboard_path(
75
+ remarkable_type: :pages,
76
+ remarkable_id: "__ID__",
77
+ ),
78
+ remote: true,
79
+ method: :post
80
+ ) %>
81
+ <label class="center"><%= Alchemy.t(:copy_page) %></label>
82
+ {{else}}
83
+ <div class="sitemap_tool disabled with-hint">
84
+ <%= render_icon(:copy) %>
85
+ <span class="hint-bubble">
86
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
87
+ </span>
88
+ {{/if}}
89
+ </div>
90
+ {{#if permissions.destroy}}
91
+ <div class="button_with_label sitemap_tool">
92
+ <%= link_to_confirm_dialog(
93
+ render_icon(:minus),
94
+ Alchemy.t(:confirm_to_delete_page),
95
+ url_for(
96
+ controller: "pages",
97
+ action: "destroy",
98
+ id: "__ID__"
99
+ )
100
+ ) -%>
101
+ <label class="center"><%= Alchemy.t(:delete_page) %></label>
102
+ {{else}}
103
+ <div class="sitemap_tool disabled with-hint">
104
+ <%= render_icon(:minus) %>
105
+ <span class="hint-bubble">
106
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
107
+ </span>
108
+ {{/if}}
109
+ </div>
110
+ {{#if permissions.create}}
111
+ <div class="button_with_label sitemap_tool">
112
+ <%= link_to_dialog(
113
+ render_icon(:plus),
114
+ alchemy.new_admin_page_path(parent_id: "__ID__"),
115
+ {
116
+ title: Alchemy.t(:create_page),
117
+ size: "340x165",
118
+ overflow: true
119
+ }
120
+ ) -%>
121
+ <label class="left"><%= Alchemy.t(:create_page) %></label>
122
+ {{else}}
123
+ <div class="sitemap_tool disabled with-hint">
124
+ <%= render_icon(:plus) %>
125
+ <span class="hint-bubble">
126
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
127
+ </span>
128
+ {{/if}}
129
+ </div>
147
130
  </div>
148
- <div class="page_infos" id="page_<%= page.id %>_infos">
131
+ <div class="page_infos">
149
132
  <span class="page_status with-hint">
150
133
  <i class="icon fas fa-fw fa-compass {{#unless public}}disabled{{/unless}}" data-fa-transform="shrink-2"></i>
151
134
  <span class="hint-bubble">{{status_titles.public}}</span>
@@ -160,23 +143,18 @@
160
143
  </div>
161
144
  <div class="sitemap_sitename">
162
145
  {{#if permissions.edit_content}}
163
- <%= link_to_unless(
164
- @sorting,
165
- '{{name}}',
166
- alchemy.edit_admin_page_path(page),
146
+ <%= link_to(
147
+ "{{name}}",
148
+ alchemy.edit_admin_page_path(id: "__ID__"),
167
149
  title: Alchemy.t(:edit_page),
168
150
  class: "sitemap_pagename_link"
169
- ) { content_tag('span', '{{name}}', class: "sitemap_pagename_link") } -%>
151
+ ) -%>
170
152
  {{else}}
171
- <%= content_tag('span', '{{name}}', class: "sitemap_pagename_link") %>
153
+ <%= content_tag("span", "{{name}}", class: "sitemap_pagename_link") %>
172
154
  {{/if}}
173
155
  </div>
174
156
  </div>
175
- {{#if children}}
176
- <% unless @sorting %>{{#unless folded}}<% end %>
177
- <ul id="page_{{id}}_children" class="level_{{level}}_children">
157
+ <ul id="page_{{id}}_children" class="children" data-parent-id="{{id}}">
178
158
  {{> list}}
179
159
  </ul>
180
- <% unless @sorting %>{{/unless}}<% end %>
181
- {{/if}}
182
160
  </li>
@@ -1,15 +1,14 @@
1
- <div id="sitemap-wrapper">
2
- <h4 id="sitemap_heading">
3
- <span class="page_name"><%= Alchemy::Page.human_attribute_name(:name) %></span>
4
- <span class="page_urlname"><%= Alchemy::Page.human_attribute_name(:urlname) %></span>
5
- <span class="page_status"><%= Alchemy.t(:page_status) %></span>
6
- </h4>
1
+ <h4 id="sitemap_heading">
2
+ <span class="page_name"><%= Alchemy::Page.human_attribute_name(:name) %></span>
3
+ <span class="page_urlname"><%= Alchemy::Page.human_attribute_name(:urlname) %></span>
4
+ <span class="page_status"><%= Alchemy.t(:page_status) %></span>
5
+ </h4>
7
6
 
8
- <p class="loading"></p>
7
+ <div id="sitemap-wrapper">
9
8
  </div>
10
9
 
11
10
  <script id="sitemap-template" type="text/x-handlebars-template">
12
- <ul id="sitemap" class="list<%= @sorting ? ' sorting' : nil %>">
11
+ <ul id="sitemap" class="list">
13
12
  {{> list}}
14
13
  </ul>
15
14
  </script>
@@ -22,15 +21,10 @@
22
21
 
23
22
  <script type="text/javascript">
24
23
  $(function() {
25
- Alchemy.Sitemap.init({
24
+ Alchemy.currentSitemap = new Alchemy.Sitemap({
26
25
  url: '<%= alchemy.tree_admin_pages_path %>',
27
- page_root_id: <%= @page_root.id %>,
28
- full: <%= full %>
29
- <% if @sorting %>
30
- ,ready: function () {
31
- Alchemy.PageSorter();
32
- }
33
- <% end %>
26
+ page_root_id: <%= @page_root.id %>
34
27
  });
28
+ Alchemy.PagePublicationFields();
35
29
  });
36
30
  </script>
@@ -28,18 +28,6 @@
28
28
  <label><%= Alchemy.t("Flush page cache") %></label>
29
29
  </div>
30
30
  <% end %>
31
- <% if can?(:sort, Alchemy::Page) %>
32
- <div class="button_with_label">
33
- <%= link_to(
34
- render_icon(:random),
35
- alchemy.sort_admin_pages_path,
36
- method: :get,
37
- class: "icon_button",
38
- title: Alchemy.t("Sort pages")
39
- ) %>
40
- <label><%= Alchemy.t("Sort pages") %></label>
41
- </div>
42
- <% end %>
43
31
  <div class="button_with_label" id="clipboard_button">
44
32
  <%= link_to_dialog(
45
33
  render_icon(clipboard_empty?("pages") ? :clipboard : :paste),
@@ -154,7 +154,7 @@
154
154
  if (!not_dirty) Alchemy.pleaseWaitOverlay(false);
155
155
  return not_dirty;
156
156
  });
157
- Alchemy.Sitemap.watchPagePublicationState();
157
+ Alchemy.PagePublicationFields();
158
158
  Alchemy.PageLeaveObserver();
159
159
  Alchemy.ElementsWindow.init('<%= alchemy.admin_elements_path(page_version_id: @page_version.id) %>', {
160
160
  texts: {
@@ -30,7 +30,7 @@
30
30
  <% else %>
31
31
  <% if @page_root %>
32
32
  <h2 id="page_filter_result"></h2>
33
- <%= render "sitemap", page_partial: "page", full: !!@sorting %>
33
+ <%= render "sitemap", page_partial: "page" %>
34
34
  <% elsif can?(:create, Alchemy::Page) %>
35
35
  <%= render partial: "create_language_form" %>
36
36
  <% else %>
@@ -1,11 +1,6 @@
1
1
  (function() {
2
2
  var page = document.querySelector('#page_<%= @page.id %>');
3
3
 
4
- <% if @old_page_layout != @page.page_layout -%>
5
- Alchemy.ElementsWindow.reload();
6
- Alchemy.growl('<%= j Alchemy.t(:page_layout_changed_notice) %>');
7
- <% end -%>
8
-
9
4
  <% if @while_page_edit -%>
10
5
 
11
6
  Alchemy.reloadPreview();
@@ -13,6 +8,13 @@
13
8
  Alchemy.growl("<%= j @notice %>");
14
9
  Alchemy.closeCurrentDialog();
15
10
 
11
+ <% elsif @page.parent_id != @old_parent_id -%>
12
+
13
+ Alchemy.closeCurrentDialog(function() {
14
+ Alchemy.growl("<%= j @notice %>");
15
+ Alchemy.currentSitemap.load(<%= @page.get_language_root.id %>);
16
+ });
17
+
16
18
  <% else -%>
17
19
 
18
20
  if (page) {