alchemy_cms 5.2.6 → 5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +19 -0
- data/Rakefile +18 -0
- data/alchemy_cms.gemspec +1 -1
- data/app/assets/javascripts/alchemy/admin.js +0 -2
- data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +6 -1
- data/app/assets/javascripts/alchemy/page_select.js +13 -8
- data/app/assets/javascripts/alchemy/templates/index.js +1 -0
- data/app/assets/javascripts/alchemy/templates/page.hbs +17 -7
- data/app/assets/javascripts/alchemy/templates/page_folder.hbs +3 -0
- data/app/assets/stylesheets/alchemy/page-select.scss +29 -4
- data/app/assets/stylesheets/alchemy/sitemap.scss +9 -7
- data/app/controllers/alchemy/admin/pages_controller.rb +10 -13
- data/app/controllers/alchemy/api/pages_controller.rb +14 -4
- data/app/models/alchemy/page.rb +3 -2
- data/app/serializers/alchemy/page_serializer.rb +7 -1
- data/app/serializers/alchemy/page_tree_serializer.rb +3 -3
- data/app/views/alchemy/admin/pages/_form.html.erb +19 -0
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +16 -5
- data/app/views/alchemy/admin/pages/_page.html.erb +111 -133
- data/app/views/alchemy/admin/pages/_sitemap.html.erb +10 -16
- data/app/views/alchemy/admin/pages/_toolbar.html.erb +0 -12
- data/app/views/alchemy/admin/pages/edit.html.erb +1 -1
- data/app/views/alchemy/admin/pages/index.html.erb +1 -1
- data/app/views/alchemy/admin/pages/update.js.erb +7 -0
- data/app/views/alchemy/admin/partials/_routes.html.erb +8 -1
- data/app/views/alchemy/essences/_essence_page_editor.html.erb +1 -1
- data/config/locales/alchemy.en.yml +0 -3
- data/config/routes.rb +4 -2
- data/lib/alchemy/permissions.rb +0 -1
- data/lib/alchemy/version.rb +1 -1
- data/package/admin.js +5 -1
- data/package/src/page_publication_fields.js +27 -0
- data/package/src/page_sorter.js +68 -0
- data/package/src/sitemap.js +152 -0
- data/package.json +1 -1
- metadata +9 -9
- data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +0 -24
- data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +0 -119
- data/app/views/alchemy/admin/pages/fold.js.erb +0 -2
- data/app/views/alchemy/admin/pages/sort.html.erb +0 -19
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +0 -434
@@ -1,24 +1,7 @@
|
|
1
|
-
<li id="page_{{id}}" class="
|
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
|
4
|
-
|
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(
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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"
|
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
|
-
<%=
|
164
|
-
|
165
|
-
|
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
|
-
)
|
151
|
+
) -%>
|
170
152
|
{{else}}
|
171
|
-
<%= content_tag(
|
153
|
+
<%= content_tag("span", "{{name}}", class: "sitemap_pagename_link") %>
|
172
154
|
{{/if}}
|
173
155
|
</div>
|
174
156
|
</div>
|
175
|
-
{{
|
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
|
-
<
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
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
|
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
|
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),
|
@@ -133,7 +133,7 @@
|
|
133
133
|
if (!not_dirty) Alchemy.pleaseWaitOverlay(false);
|
134
134
|
return not_dirty;
|
135
135
|
});
|
136
|
-
Alchemy.
|
136
|
+
Alchemy.PagePublicationFields();
|
137
137
|
Alchemy.PageLeaveObserver();
|
138
138
|
Alchemy.ElementsWindow.init('<%= alchemy.admin_elements_path(page_id: @page.id) %>', {
|
139
139
|
texts: {
|
@@ -37,7 +37,7 @@
|
|
37
37
|
<% else %>
|
38
38
|
<% if @page_root %>
|
39
39
|
<h2 id="page_filter_result"></h2>
|
40
|
-
<%= render "sitemap", page_partial: "page"
|
40
|
+
<%= render "sitemap", page_partial: "page" %>
|
41
41
|
<% elsif can?(:create, Alchemy::Page) %>
|
42
42
|
<%= render partial: "create_language_form" %>
|
43
43
|
<% else %>
|
@@ -13,6 +13,13 @@
|
|
13
13
|
Alchemy.growl("<%= j @notice %>");
|
14
14
|
Alchemy.closeCurrentDialog();
|
15
15
|
|
16
|
+
<% elsif @page.parent_id != @old_parent_id -%>
|
17
|
+
|
18
|
+
Alchemy.closeCurrentDialog(function() {
|
19
|
+
Alchemy.growl("<%= j @notice %>");
|
20
|
+
Alchemy.currentSitemap.load(<%= @page.get_language_root.id %>);
|
21
|
+
});
|
22
|
+
|
16
23
|
<% else -%>
|
17
24
|
|
18
25
|
if (page) {
|
@@ -23,8 +23,15 @@
|
|
23
23
|
return '<%= alchemy.move_api_node_path(id: 1) %>'.replace(/1/, id);
|
24
24
|
},
|
25
25
|
|
26
|
+
move_admin_page_path: function(id) {
|
27
|
+
return '<%= alchemy.move_api_page_path(id: 1) %>'.replace(/1/, id);
|
28
|
+
},
|
29
|
+
|
30
|
+
fold_admin_page_path: function(id) {
|
31
|
+
return '<%= alchemy.fold_admin_page_path(id: 1) %>'.replace(/1/, id);
|
32
|
+
},
|
33
|
+
|
26
34
|
order_admin_elements_path: '<%= alchemy.order_admin_elements_path %>',
|
27
|
-
order_admin_pages_path: '<%= alchemy.order_admin_pages_path %>',
|
28
35
|
link_admin_pages_path: '<%= alchemy.link_admin_pages_path %>',
|
29
36
|
api_pages_path: '<%= alchemy.api_pages_path %>',
|
30
37
|
api_elements_path: '<%= alchemy.api_elements_path %>'
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<script>
|
15
15
|
$('#<%= essence_page_editor.form_field_id %>').alchemyPageSelect({
|
16
16
|
placeholder: "<%= Alchemy.t(:search_page) %>",
|
17
|
-
url: "<%= alchemy.api_pages_path %>",
|
17
|
+
url: "<%= alchemy.api_pages_path language_id: essence_page_editor.page&.language_id %>",
|
18
18
|
query_params: <%== essence_page_editor.settings[:query_params].to_json %>,
|
19
19
|
<% if essence_page_editor.essence.page %>
|
20
20
|
initialSelection: {
|
@@ -292,7 +292,6 @@ en:
|
|
292
292
|
"Site successfully removed": "Website successfully removed."
|
293
293
|
"Site successfully updated": "Website successfully updated."
|
294
294
|
"Size": "Size"
|
295
|
-
"Sort pages": "Reorder pages"
|
296
295
|
"Successfully added content": "Successfully added %{content}"
|
297
296
|
"Successfully deleted content": "Successfully deleted %{content}"
|
298
297
|
"Tags": "Tags"
|
@@ -394,7 +393,6 @@ en:
|
|
394
393
|
enter_external_link: "Please enter the URL you want to link with"
|
395
394
|
explain_cropping: "<p>Move the frame and change its size with the mouse or arrow keys to adjust the image mask. Click on \"apply\" when you are satisfied with your selection.</p><p>If you want to return to the original centered image mask like it was defined in the layout, click \"reset\" and \"apply\" afterwards.</p>"
|
396
395
|
explain_publishing: "Publish the page and remove the cached version from the server."
|
397
|
-
explain_sitemap_dragndrop_sorting: "Tip: Drag the pages at the icon in order to sort them."
|
398
396
|
explain_unlocking: "Leave page and unlock it for other users."
|
399
397
|
external_link_notice_1: "Please enter the complete url with http:// or a similar protocol."
|
400
398
|
external_link_notice_2: "To refer a path from your website url, start with a /."
|
@@ -553,7 +551,6 @@ en:
|
|
553
551
|
robot_follow: "robot may follow links."
|
554
552
|
robot_index: "allow robot to index."
|
555
553
|
save: "Save"
|
556
|
-
"save order": "Save order"
|
557
554
|
saved_link: "Link saved."
|
558
555
|
search: "search"
|
559
556
|
search_engines: "Search engines"
|
data/config/routes.rb
CHANGED
@@ -28,13 +28,12 @@ Alchemy::Engine.routes.draw do
|
|
28
28
|
post :copy_language_tree
|
29
29
|
get :create_language
|
30
30
|
get :link
|
31
|
-
get :sort
|
32
31
|
get :tree
|
33
32
|
end
|
34
33
|
member do
|
35
34
|
post :unlock
|
36
35
|
post :publish
|
37
|
-
|
36
|
+
patch :fold
|
38
37
|
post :visit
|
39
38
|
get :configure
|
40
39
|
get :preview
|
@@ -145,6 +144,9 @@ Alchemy::Engine.routes.draw do
|
|
145
144
|
collection do
|
146
145
|
get :nested
|
147
146
|
end
|
147
|
+
member do
|
148
|
+
patch :move
|
149
|
+
end
|
148
150
|
end
|
149
151
|
|
150
152
|
get "/pages/*urlname(.:format)" => "pages#show", as: "page"
|
data/lib/alchemy/permissions.rb
CHANGED
data/lib/alchemy/version.rb
CHANGED
data/package/admin.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import translate from "./src/i18n"
|
2
2
|
import translationData from "./src/translations"
|
3
3
|
import NodeTree from "./src/node_tree"
|
4
|
+
import Sitemap from "./src/sitemap"
|
5
|
+
import PagePublicationFields from "./src/page_publication_fields.js"
|
4
6
|
|
5
7
|
// Global Alchemy object
|
6
8
|
if (typeof window.Alchemy === "undefined") {
|
@@ -12,5 +14,7 @@ Object.assign(Alchemy, {
|
|
12
14
|
// Global utility method for translating a given string
|
13
15
|
t: translate,
|
14
16
|
translations: Object.assign(Alchemy.translations || {}, translationData),
|
15
|
-
NodeTree
|
17
|
+
NodeTree,
|
18
|
+
Sitemap,
|
19
|
+
PagePublicationFields
|
16
20
|
})
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// Handles the page publication date fields
|
2
|
+
export default function () {
|
3
|
+
document.addEventListener("DialogReady.Alchemy", function (evt) {
|
4
|
+
const dialog = evt.detail.body
|
5
|
+
const public_on_field = dialog.querySelector("#page_public_on")
|
6
|
+
const public_until_field = dialog.querySelector("#page_public_until")
|
7
|
+
const publication_date_fields = dialog.querySelector(
|
8
|
+
".page-publication-date-fields"
|
9
|
+
)
|
10
|
+
|
11
|
+
dialog
|
12
|
+
.querySelector("#page_public")
|
13
|
+
.addEventListener("click", function (evt) {
|
14
|
+
const checkbox = evt.target
|
15
|
+
const now = new Date()
|
16
|
+
|
17
|
+
if (checkbox.checked) {
|
18
|
+
publication_date_fields.classList.remove("hidden")
|
19
|
+
public_on_field._flatpickr.setDate(now)
|
20
|
+
} else {
|
21
|
+
publication_date_fields.classList.add("hidden")
|
22
|
+
public_on_field.value = ""
|
23
|
+
}
|
24
|
+
public_until_field.value = ""
|
25
|
+
})
|
26
|
+
})
|
27
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import Sortable from "sortablejs"
|
2
|
+
|
3
|
+
function onFinishDragging(evt) {
|
4
|
+
const pageId = evt.item.dataset.pageId
|
5
|
+
const url = Alchemy.routes.move_admin_page_path(pageId)
|
6
|
+
const data = {
|
7
|
+
target_parent_id: evt.to.dataset.parentId,
|
8
|
+
new_position: evt.newIndex
|
9
|
+
}
|
10
|
+
|
11
|
+
fetch(url, {
|
12
|
+
method: "PATCH",
|
13
|
+
headers: {
|
14
|
+
"Content-Type": "application/json",
|
15
|
+
Accept: "application/json"
|
16
|
+
},
|
17
|
+
body: JSON.stringify(data)
|
18
|
+
})
|
19
|
+
.then(async (response) => {
|
20
|
+
const pageData = await response.json()
|
21
|
+
const pageEl = document.getElementById(`page_${pageId}`)
|
22
|
+
const urlPathEl = pageEl.querySelector(".sitemap_url")
|
23
|
+
|
24
|
+
Alchemy.growl(Alchemy.t("Successfully moved page"))
|
25
|
+
urlPathEl.textContent = pageData.url_path
|
26
|
+
displayPageFolders()
|
27
|
+
})
|
28
|
+
.catch((error) => {
|
29
|
+
Alchemy.growl(error.message || error, "error")
|
30
|
+
})
|
31
|
+
}
|
32
|
+
|
33
|
+
export function displayPageFolders() {
|
34
|
+
document.querySelectorAll("li.sitemap-item").forEach((el) => {
|
35
|
+
const pageFolderEl = el.querySelector(".page_folder")
|
36
|
+
const list = el.querySelector(".children")
|
37
|
+
const page = {
|
38
|
+
folded: el.dataset.folded === "true",
|
39
|
+
id: el.dataset.pageId,
|
40
|
+
type: el.dataset.type
|
41
|
+
}
|
42
|
+
|
43
|
+
if (list.children.length > 0 || page.folded) {
|
44
|
+
pageFolderEl.outerHTML = HandlebarsTemplates.page_folder({ page })
|
45
|
+
} else {
|
46
|
+
pageFolderEl.innerHTML = ""
|
47
|
+
}
|
48
|
+
})
|
49
|
+
}
|
50
|
+
|
51
|
+
export function createSortables(sortables) {
|
52
|
+
sortables.forEach((el) => {
|
53
|
+
new Sortable(el, {
|
54
|
+
group: "pages",
|
55
|
+
animation: 150,
|
56
|
+
fallbackOnBody: true,
|
57
|
+
swapThreshold: 0.65,
|
58
|
+
handle: ".handle",
|
59
|
+
onEnd: onFinishDragging
|
60
|
+
})
|
61
|
+
})
|
62
|
+
}
|
63
|
+
|
64
|
+
export default function () {
|
65
|
+
const sortables = document.querySelectorAll("ul.children")
|
66
|
+
displayPageFolders()
|
67
|
+
createSortables(sortables)
|
68
|
+
}
|