spina 2.12.0 → 2.13.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spina might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Rakefile +17 -17
- data/app/assets/builds/spina/tailwind.css +79 -47
- data/app/components/spina/application_component.rb +1 -1
- data/app/components/spina/forms/group_component.rb +2 -3
- data/app/components/spina/forms/label_component.rb +2 -3
- data/app/components/spina/forms/password_field_component.rb +1 -1
- data/app/components/spina/forms/switch_component.rb +2 -3
- data/app/components/spina/forms/text_field_component.rb +8 -9
- data/app/components/spina/forms/trix_toolbar_component.rb +1 -3
- data/app/components/spina/hooks/hook_component.rb +3 -5
- data/app/components/spina/hooks/partial_component.rb +4 -5
- data/app/components/spina/main_navigation/link_component.rb +1 -3
- data/app/components/spina/main_navigation/sub_nav_component.rb +6 -7
- data/app/components/spina/media_picker/image_component.rb +1 -3
- data/app/components/spina/media_picker/modal_component.rb +4 -6
- data/app/components/spina/pages/actions_component.rb +1 -3
- data/app/components/spina/pages/list_component.rb +3 -4
- data/app/components/spina/pages/location_component.rb +10 -11
- data/app/components/spina/pages/new_page_button_component.rb +4 -5
- data/app/components/spina/pages/page_component.rb +8 -9
- data/app/components/spina/pages/page_select_component.rb +3 -4
- data/app/components/spina/pages/tab_button_component.rb +1 -3
- data/app/components/spina/pages/translations_component.rb +9 -11
- data/app/components/spina/user_interface/dropdown_button_component.rb +4 -4
- data/app/components/spina/user_interface/dropdown_component.rb +8 -9
- data/app/components/spina/user_interface/flash_message_component.rb +3 -5
- data/app/components/spina/user_interface/header_component.rb +2 -2
- data/app/components/spina/user_interface/modal_component.rb +1 -3
- data/app/components/spina/user_interface/tab_link_component.rb +1 -3
- data/app/components/spina/user_interface/translations_component.rb +8 -10
- data/app/controllers/concerns/spina/api/paginable.rb +36 -37
- data/app/controllers/concerns/spina/current_spina_account.rb +1 -1
- data/app/controllers/concerns/spina/current_theme.rb +6 -7
- data/app/controllers/concerns/spina/frontend.rb +58 -44
- data/app/controllers/spina/admin/accounts_controller.rb +9 -10
- data/app/controllers/spina/admin/admin_controller.rb +18 -18
- data/app/controllers/spina/admin/attachments_controller.rb +15 -10
- data/app/controllers/spina/admin/embeds_controller.rb +17 -19
- data/app/controllers/spina/admin/images_controller.rb +24 -25
- data/app/controllers/spina/admin/layout_controller.rb +19 -20
- data/app/controllers/spina/admin/media_folders_controller.rb +4 -5
- data/app/controllers/spina/admin/media_picker_controller.rb +2 -4
- data/app/controllers/spina/admin/move_pages_controller.rb +8 -10
- data/app/controllers/spina/admin/navigation_items_controller.rb +13 -14
- data/app/controllers/spina/admin/navigations_controller.rb +26 -26
- data/app/controllers/spina/admin/page_translations_controller.rb +1 -3
- data/app/controllers/spina/admin/pages_controller.rb +34 -34
- data/app/controllers/spina/admin/parent_pages_controller.rb +1 -3
- data/app/controllers/spina/admin/password_resets_controller.rb +8 -9
- data/app/controllers/spina/admin/resources_controller.rb +14 -15
- data/app/controllers/spina/admin/sessions_controller.rb +2 -2
- data/app/controllers/spina/admin/settings_controller.rb +28 -29
- data/app/controllers/spina/admin/theme_controller.rb +10 -11
- data/app/controllers/spina/admin/users_controller.rb +28 -29
- data/app/controllers/spina/api/api_controller.rb +17 -17
- data/app/controllers/spina/api/images_controller.rb +1 -3
- data/app/controllers/spina/api/navigations_controller.rb +2 -4
- data/app/controllers/spina/api/pages_controller.rb +8 -9
- data/app/controllers/spina/api/resources_controller.rb +2 -4
- data/app/controllers/spina/application_controller.rb +4 -3
- data/app/controllers/spina/pages_controller.rb +4 -5
- data/app/controllers/spina/sitemaps_controller.rb +0 -2
- data/app/helpers/spina/admin/icons_helper.rb +151 -153
- data/app/helpers/spina/admin/images_helper.rb +0 -2
- data/app/helpers/spina/admin/pages_helper.rb +3 -5
- data/app/helpers/spina/attachments_helper.rb +1 -3
- data/app/helpers/spina/images_helper.rb +5 -7
- data/app/helpers/spina/pages_helper.rb +0 -2
- data/app/helpers/spina/spina_helper.rb +1 -3
- data/app/jobs/spina/replace_signed_id_job.rb +10 -11
- data/app/jobs/spina/resource_pages_update_job.rb +1 -1
- data/app/mailers/spina/application_mailer.rb +2 -2
- data/app/mailers/spina/user_mailer.rb +4 -6
- data/app/models/concerns/spina/gravatar.rb +11 -12
- data/app/models/concerns/spina/partable.rb +4 -6
- data/app/models/concerns/spina/translated_content.rb +5 -5
- data/app/models/spina/account.rb +9 -10
- data/app/models/spina/application_record.rb +2 -3
- data/app/models/spina/attachment.rb +3 -4
- data/app/models/spina/current.rb +1 -1
- data/app/models/spina/embeds/base.rb +2 -2
- data/app/models/spina/embeds/button.rb +4 -4
- data/app/models/spina/embeds/vimeo.rb +17 -18
- data/app/models/spina/embeds/youtube.rb +18 -19
- data/app/models/spina/image.rb +4 -4
- data/app/models/spina/media_folder.rb +1 -1
- data/app/models/spina/navigation.rb +1 -2
- data/app/models/spina/navigation_item.rb +2 -2
- data/app/models/spina/page.rb +32 -38
- data/app/models/spina/parts/attachment.rb +1 -2
- data/app/models/spina/parts/base.rb +5 -4
- data/app/models/spina/parts/image.rb +3 -4
- data/app/models/spina/parts/image_collection.rb +2 -3
- data/app/models/spina/parts/image_variant.rb +3 -4
- data/app/models/spina/parts/repeater_content.rb +2 -2
- data/app/models/spina/resource.rb +3 -4
- data/app/models/spina/rewrite_rule.rb +1 -1
- data/app/models/spina/setting.rb +0 -2
- data/app/models/spina/user.rb +3 -4
- data/app/presenters/spina/content_presenter.rb +11 -12
- data/app/presenters/spina/menu_presenter.rb +55 -55
- data/app/presenters/spina/rich_text_presenter.rb +28 -29
- data/app/serializers/spina/api/base_serializer.rb +1 -1
- data/app/serializers/spina/api/image_serializer.rb +6 -6
- data/app/serializers/spina/api/navigation_serializer.rb +4 -7
- data/app/serializers/spina/api/page_serializer.rb +9 -12
- data/app/serializers/spina/api/resource_serializer.rb +5 -5
- data/app/views/layouts/spina/admin/application.html.erb +1 -0
- data/app/views/spina/admin/parts/attachments/_attachment.html.erb +3 -0
- data/app/views/spina/admin/parts/attachments/_form.html.erb +22 -1
- data/app/views/spina/admin/parts/repeaters/_fields.html.erb +2 -2
- data/app/views/spina/admin/parts/repeaters/_form.html.erb +4 -4
- data/app/views/spina/admin/shared/_navigation.html.erb +3 -1
- data/app/views/spina/admin/shared/_version.html.erb +18 -0
- data/app/views/spina/sitemaps/show.xml.builder +1 -1
- data/config/initializers/importmap.rb +3 -3
- data/config/initializers/yaml_column_permitted_classes.rb +3 -3
- data/config/locales/de.yml +1 -0
- data/config/locales/en.yml +3 -0
- data/config/locales/nl.yml +4 -1
- data/config/routes.rb +10 -17
- data/db/migrate/1_create_spina_tables.rb +57 -57
- data/db/migrate/3_create_spina_navigations.rb +1 -1
- data/db/seeds.rb +0 -1
- data/lib/generators/spina/embed_generator.rb +5 -6
- data/lib/generators/spina/install_generator.rb +48 -41
- data/lib/generators/spina/tailwind_config_generator.rb +3 -4
- data/lib/generators/spina/templates/app/models/spina/embeds/embed.rb.tt +20 -18
- data/lib/generators/spina/templates/config/initializers/spina.rb +11 -11
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +17 -17
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +22 -22
- data/lib/spina/admin_sectionable.rb +5 -8
- data/lib/spina/attr_json_monkeypatch.rb +4 -7
- data/lib/spina/attr_json_spina_parts_model.rb +1 -3
- data/lib/spina/authentication/basic.rb +9 -10
- data/lib/spina/authentication/sessions.rb +10 -11
- data/lib/spina/embeddable.rb +14 -17
- data/lib/spina/embeds/trix_conversion.rb +25 -26
- data/lib/spina/embeds.rb +1 -3
- data/lib/spina/engine.rb +18 -19
- data/lib/spina/part.rb +1 -6
- data/lib/spina/plugin.rb +9 -13
- data/lib/spina/railtie.rb +5 -7
- data/lib/spina/theme.rb +13 -17
- data/lib/spina/theme_reloader.rb +12 -13
- data/lib/spina/version.rb +1 -1
- data/lib/spina.rb +40 -40
- data/lib/tasks/install.rake +8 -14
- data/lib/tasks/tailwind.rake +10 -8
- metadata +18 -2
@@ -2,35 +2,35 @@ module Spina
|
|
2
2
|
module Admin
|
3
3
|
class AdminController < ActionController::Base
|
4
4
|
include Spina.config.authentication.constantize
|
5
|
-
include Spina::
|
6
|
-
|
5
|
+
include Spina::CurrentTheme
|
6
|
+
include Spina::CurrentSpinaAccount
|
7
|
+
|
7
8
|
helper Spina::Engine.helpers
|
8
|
-
|
9
|
+
|
9
10
|
before_action :add_view_path
|
10
11
|
before_action :set_admin_locale
|
11
12
|
before_action :authenticate
|
12
|
-
|
13
|
+
|
13
14
|
admin_section :content
|
14
|
-
|
15
|
+
|
15
16
|
def current_admin_path
|
16
|
-
request.fullpath[%r{/#{
|
17
|
+
request.fullpath[%r{/#{Spina.config.backend_path}(.*)}, 1]
|
17
18
|
end
|
18
19
|
helper_method :current_admin_path
|
19
20
|
|
20
21
|
private
|
21
|
-
|
22
|
-
def render_flash
|
23
|
-
render turbo_stream: turbo_stream.update("flash", partial: "spina/admin/shared/flash")
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_admin_locale
|
27
|
-
I18n.locale = I18n.default_locale
|
28
|
-
end
|
29
|
-
|
30
|
-
def add_view_path
|
31
|
-
prepend_view_path Spina::Engine.root.join('app/views/spina/admin')
|
32
|
-
end
|
33
22
|
|
23
|
+
def render_flash
|
24
|
+
render turbo_stream: turbo_stream.update("flash", partial: "spina/admin/shared/flash")
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_admin_locale
|
28
|
+
I18n.locale = I18n.default_locale
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_view_path
|
32
|
+
prepend_view_path Spina::Engine.root.join("app/views/spina/admin")
|
33
|
+
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -6,11 +6,11 @@ module Spina
|
|
6
6
|
def index
|
7
7
|
@attachments = Attachment.sorted.with_attached_file.page(params[:page]).per(25)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def show
|
11
11
|
@attachment = Attachment.find(params[:id])
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def edit
|
15
15
|
@attachment = Attachment.find(params[:id])
|
16
16
|
end
|
@@ -18,18 +18,23 @@ module Spina
|
|
18
18
|
def create
|
19
19
|
@attachments = params[:attachment][:files].map do |file|
|
20
20
|
next if file.blank? # Skip the blank string posted by the hidden files[] field
|
21
|
-
|
21
|
+
|
22
22
|
attachment = Attachment.create(attachment_params)
|
23
23
|
attachment.file.attach(file)
|
24
24
|
attachment
|
25
25
|
end.compact
|
26
|
-
|
26
|
+
|
27
27
|
respond_to do |format|
|
28
|
-
format.turbo_stream { render turbo_stream: turbo_stream.prepend("attachments", partial: "attachment", collection: @attachments)}
|
28
|
+
format.turbo_stream { render turbo_stream: turbo_stream.prepend("attachments", partial: "attachment", collection: @attachments) }
|
29
29
|
format.html { redirect_to spina.admin_attachments_url }
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
def inline_upload
|
34
|
+
@attachment = Attachment.create(attachment_params)
|
35
|
+
render turbo_stream: turbo_stream.append(params[:select_id], partial: "parts/attachments/attachment", object: @attachment)
|
36
|
+
end
|
37
|
+
|
33
38
|
def update
|
34
39
|
@attachment = Attachment.find(params[:id])
|
35
40
|
old_signed_id = @attachment.file&.blob&.signed_id
|
@@ -40,12 +45,12 @@ module Spina
|
|
40
45
|
@attachment.file.blob.update(filename: filename)
|
41
46
|
end
|
42
47
|
|
43
|
-
# Replace all occurrences of the old signed blob ID
|
48
|
+
# Replace all occurrences of the old signed blob ID
|
44
49
|
# with the new ID in a background job
|
45
50
|
if @attachment.reload.file&.blob&.signed_id != old_signed_id
|
46
51
|
Spina::ReplaceSignedIdJob.perform_later(old_signed_id, @attachment.file&.blob&.signed_id)
|
47
52
|
end
|
48
|
-
|
53
|
+
|
49
54
|
render @attachment
|
50
55
|
end
|
51
56
|
|
@@ -58,11 +63,11 @@ module Spina
|
|
58
63
|
private
|
59
64
|
|
60
65
|
def set_breadcrumbs
|
61
|
-
add_breadcrumb I18n.t(
|
66
|
+
add_breadcrumb I18n.t("spina.website.media_library")
|
62
67
|
end
|
63
68
|
|
64
69
|
def attachment_params
|
65
|
-
params.require(:attachment).permit(:file, :
|
70
|
+
params.require(:attachment).permit(:file, :_destroy)
|
66
71
|
end
|
67
72
|
end
|
68
73
|
end
|
@@ -1,36 +1,34 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class EmbedsController < AdminController
|
4
|
-
|
5
4
|
def new
|
6
5
|
@embeddable = (Spina::Embeds.constantize(embed_type) || embeddables.first).new
|
7
6
|
end
|
8
|
-
|
7
|
+
|
9
8
|
def create
|
10
9
|
@embeddable = Spina::Embeds.constantize(embed_type).new(embed_params)
|
11
|
-
|
10
|
+
|
12
11
|
if @embeddable.valid?
|
13
12
|
render turbo_stream: turbo_stream.update(:trix_attachment_html, @embeddable.to_trix_attachment)
|
14
13
|
else
|
15
14
|
render :new, status: :unprocessable_entity
|
16
15
|
end
|
17
16
|
end
|
18
|
-
|
17
|
+
|
19
18
|
private
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
19
|
+
|
20
|
+
def embeddables
|
21
|
+
@embeddables ||= current_theme.embeddables
|
22
|
+
end
|
23
|
+
helper_method :embeddables
|
24
|
+
|
25
|
+
def embed_type
|
26
|
+
params[:embed_type]
|
27
|
+
end
|
28
|
+
|
29
|
+
def embed_params
|
30
|
+
params.require(:embeddable).permit!
|
31
|
+
end
|
34
32
|
end
|
35
33
|
end
|
36
|
-
end
|
34
|
+
end
|
@@ -8,11 +8,11 @@ module Spina
|
|
8
8
|
@media_folders = MediaFolder.order(:name).includes(:images)
|
9
9
|
@images = Image.sorted.where(media_folder: @media_folder).with_attached_file.page(params[:page]).per(25)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def show
|
13
13
|
@image = Image.find(params[:id])
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def edit
|
17
17
|
@image = Image.find(params[:id])
|
18
18
|
end
|
@@ -24,7 +24,7 @@ module Spina
|
|
24
24
|
def create
|
25
25
|
@images = params[:image][:files].map do |file|
|
26
26
|
next if file.blank? # Skip the blank string posted by the hidden files[] field
|
27
|
-
|
27
|
+
|
28
28
|
# Create the image and attach the file
|
29
29
|
image = Image.create(media_folder_id: image_params[:media_folder_id])
|
30
30
|
image.file.attach(file)
|
@@ -34,14 +34,14 @@ module Spina
|
|
34
34
|
|
35
35
|
image
|
36
36
|
end.compact
|
37
|
-
|
37
|
+
|
38
38
|
if params[:modal]
|
39
39
|
redirect_to spina.admin_media_picker_path(media_folder_id: image_params[:media_folder_id])
|
40
40
|
else
|
41
41
|
render turbo_stream: turbo_stream.prepend("images", partial: "image", collection: @images)
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def update
|
46
46
|
@image = Image.find(params[:id])
|
47
47
|
old_signed_id = @image.file&.blob&.signed_id
|
@@ -51,16 +51,16 @@ module Spina
|
|
51
51
|
filename = "#{params[:filename]}.#{extension}"
|
52
52
|
@image.file.blob.update(filename: filename)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
if @image.saved_change_to_media_folder_id?
|
56
56
|
render :update
|
57
57
|
else
|
58
|
-
# Replace all occurrences of the old signed blob ID
|
58
|
+
# Replace all occurrences of the old signed blob ID
|
59
59
|
# with the new ID in a background job
|
60
60
|
if @image.reload.file&.blob&.signed_id != old_signed_id
|
61
61
|
Spina::ReplaceSignedIdJob.perform_later(old_signed_id, @image.file&.blob&.signed_id)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
@media_folders = MediaFolder.order(:name)
|
65
65
|
render @image
|
66
66
|
end
|
@@ -74,25 +74,24 @@ module Spina
|
|
74
74
|
|
75
75
|
private
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def set_media_folder
|
87
|
-
if params[:media_folder_id].present?
|
88
|
-
@media_folder = MediaFolder.find(params[:media_folder_id])
|
89
|
-
end
|
77
|
+
def set_breadcrumbs
|
78
|
+
if @media_folder.present?
|
79
|
+
add_breadcrumb I18n.t("spina.website.media_library"), admin_images_path, class: "text-gray-400"
|
80
|
+
add_breadcrumb @media_folder.name
|
81
|
+
else
|
82
|
+
add_breadcrumb I18n.t("spina.website.media_library")
|
90
83
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_media_folder
|
87
|
+
if params[:media_folder_id].present?
|
88
|
+
@media_folder = MediaFolder.find(params[:media_folder_id])
|
94
89
|
end
|
90
|
+
end
|
95
91
|
|
92
|
+
def image_params
|
93
|
+
params.require(:image).permit(:media_folder_id, :file)
|
94
|
+
end
|
96
95
|
end
|
97
96
|
end
|
98
|
-
end
|
97
|
+
end
|
@@ -3,7 +3,7 @@ module Spina::Admin
|
|
3
3
|
before_action :set_account
|
4
4
|
before_action :set_locale
|
5
5
|
before_action :set_breadcrumb
|
6
|
-
|
6
|
+
|
7
7
|
admin_section :content
|
8
8
|
|
9
9
|
def edit
|
@@ -11,31 +11,30 @@ module Spina::Admin
|
|
11
11
|
|
12
12
|
def update
|
13
13
|
if @account.update(layout_params)
|
14
|
-
redirect_to spina.edit_admin_layout_path(locale: @locale), flash: {success: t(
|
14
|
+
redirect_to spina.edit_admin_layout_path(locale: @locale), flash: {success: t("spina.layout.saved")}
|
15
15
|
else
|
16
|
-
flash.now[:error] = t(
|
17
|
-
render partial:
|
16
|
+
flash.now[:error] = t("spina.layout.couldnt_be_saved")
|
17
|
+
render partial: "error", status: :unprocessable_entity
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
|
-
|
23
|
-
# Permit all attributes when editing your layout
|
24
|
-
def layout_params
|
25
|
-
params.require(:account).permit!
|
26
|
-
end
|
27
|
-
|
28
|
-
def set_breadcrumb
|
29
|
-
add_breadcrumb t('spina.layout.layout')
|
30
|
-
end
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
# Permit all attributes when editing your layout
|
24
|
+
def layout_params
|
25
|
+
params.require(:account).permit!
|
26
|
+
end
|
35
27
|
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
def set_breadcrumb
|
29
|
+
add_breadcrumb t("spina.layout.layout")
|
30
|
+
end
|
39
31
|
|
32
|
+
def set_account
|
33
|
+
@account = current_spina_account
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_locale
|
37
|
+
@locale = params[:locale] || I18n.default_locale
|
38
|
+
end
|
40
39
|
end
|
41
|
-
end
|
40
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class MediaFoldersController < AdminController
|
4
|
-
|
5
4
|
def new
|
6
5
|
@media_folder = MediaFolder.new
|
7
6
|
end
|
@@ -36,9 +35,9 @@ module Spina
|
|
36
35
|
|
37
36
|
private
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
def media_folder_params
|
39
|
+
params.require(:media_folder).permit(:name)
|
40
|
+
end
|
42
41
|
end
|
43
42
|
end
|
44
|
-
end
|
43
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class MediaPickerController < AdminController
|
4
|
-
|
5
4
|
def show
|
6
5
|
@images = Spina::Image.sorted.with_attached_file.page(params[:page]).per(16)
|
7
|
-
|
8
|
-
if @media_folder = Spina::MediaFolder.find_by(id: params[:media_folder_id])
|
6
|
+
|
7
|
+
if (@media_folder = Spina::MediaFolder.find_by(id: params[:media_folder_id]))
|
9
8
|
@images = @images.where(media_folder: @media_folder)
|
10
9
|
end
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -1,24 +1,22 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class MovePagesController < AdminController
|
4
|
-
|
5
4
|
def new
|
6
5
|
@page = Page.find(params[:page_id])
|
7
6
|
end
|
8
|
-
|
7
|
+
|
9
8
|
def update
|
10
9
|
@page = Page.find(params[:page_id])
|
11
10
|
@page.update(page_params)
|
12
|
-
flash[:success] = t(
|
11
|
+
flash[:success] = t("spina.pages.moved")
|
13
12
|
redirect_back fallback_location: spina.edit_admin_page_url(@page)
|
14
13
|
end
|
15
|
-
|
14
|
+
|
16
15
|
private
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
|
17
|
+
def page_params
|
18
|
+
params.require(:page).permit(:parent_id, :resource_id)
|
19
|
+
end
|
22
20
|
end
|
23
21
|
end
|
24
|
-
end
|
22
|
+
end
|
@@ -2,35 +2,34 @@ module Spina
|
|
2
2
|
module Admin
|
3
3
|
class NavigationItemsController < AdminController
|
4
4
|
before_action :set_navigation
|
5
|
-
|
5
|
+
|
6
6
|
def new
|
7
7
|
@navigation_item = @navigation.navigation_items.new(parent_id: params[:parent_id])
|
8
8
|
@pages = Page.sorted.main.includes(:translations)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def create
|
12
12
|
@navigation_item = NavigationItem.new(navigation_item_params)
|
13
13
|
if @navigation_item.save
|
14
14
|
render turbo_stream: turbo_stream.append(@navigation_item.parent || @navigation, @navigation_item)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def destroy
|
19
19
|
@navigation_item = @navigation.navigation_items.find(params[:id])
|
20
20
|
@navigation_item.destroy
|
21
21
|
render turbo_stream: turbo_stream.remove(view_context.dom_id(@navigation_item, :container))
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
private
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
|
26
|
+
def navigation_item_params
|
27
|
+
params.require(:navigation_item).permit(:page_id, :parent_id).merge(navigation_id: @navigation.id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_navigation
|
31
|
+
@navigation = Navigation.find(params[:navigation_id])
|
32
|
+
end
|
34
33
|
end
|
35
34
|
end
|
36
|
-
end
|
35
|
+
end
|
@@ -2,10 +2,10 @@ module Spina
|
|
2
2
|
module Admin
|
3
3
|
class NavigationsController < AdminController
|
4
4
|
before_action :set_breadcrumb
|
5
|
-
before_action :set_navigation, only: [:
|
6
|
-
|
5
|
+
before_action :set_navigation, only: [:edit, :update]
|
6
|
+
|
7
7
|
admin_section :content
|
8
|
-
|
8
|
+
|
9
9
|
def index
|
10
10
|
navigation = Spina::Navigation.order(:position).first
|
11
11
|
if navigation
|
@@ -15,10 +15,10 @@ module Spina
|
|
15
15
|
|
16
16
|
def edit
|
17
17
|
@navigations = Spina::Navigation.order(:position)
|
18
|
-
render layout:
|
18
|
+
render layout: "spina/admin/admin"
|
19
19
|
end
|
20
20
|
|
21
|
-
def update
|
21
|
+
def update
|
22
22
|
if @navigation.update(navigation_params)
|
23
23
|
redirect_to spina.edit_admin_navigation_path(@navigation)
|
24
24
|
else
|
@@ -27,40 +27,40 @@ module Spina
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def sort
|
30
|
-
params[:ids].each.with_index do |id, index|
|
30
|
+
params[:ids].each.with_index do |id, index|
|
31
31
|
NavigationItem.where(id: id).update_all(position: index + 1)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
flash.now[:info] = t("spina.navigations.sorting_saved")
|
35
35
|
render_flash
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
def update_navigation_item_position(navigation_item_id, position, parent_id = nil)
|
41
|
+
Spina::NavigationItem.update(navigation_item_id, position: position.to_i + 1, parent_id: parent_id)
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
44
|
+
def update_child_pages_position(node)
|
45
|
+
if node[:children].present?
|
46
|
+
node[:children].each_pair do |child_pos, child_node|
|
47
|
+
update_child_pages_position(child_node) if child_node[:children].present?
|
48
|
+
update_navigation_item_position(child_node[:id], child_pos, node[:id])
|
50
49
|
end
|
51
50
|
end
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def set_breadcrumb
|
54
|
+
add_breadcrumb t("spina.navigations.navigations")
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
def navigation_params
|
58
|
+
params.require(:navigation).permit(:label, :auto_add_pages, page_ids: [])
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
def set_navigation
|
62
|
+
@navigation = Navigation.find(params[:id])
|
63
|
+
end
|
64
64
|
end
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class PageTranslationsController < AdminController
|
4
|
-
|
5
4
|
def destroy
|
6
5
|
@translation = Spina::Page::Translation.find(params[:id])
|
7
6
|
@translation.destroy
|
8
7
|
flash[:info] = t("spina.page_translations.deleted")
|
9
8
|
redirect_to spina.edit_admin_page_path(@translation.translated_model), status: :see_other
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
|
-
end
|
12
|
+
end
|