alchemy_cms 7.1.10 → 7.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b6e517fac0fc0ca7046a00d674d1d11c77bcbaf29a7000ea19a2d124c48fe20
4
- data.tar.gz: 3632b9ff0f939eab1222461620ab417a4dac1aed75e56886ae048085d59769ef
3
+ metadata.gz: 702711d3c433b8ebd8622cb94198dd6ca4d7ff094fb2fb7993ea8ce17ff4d3a5
4
+ data.tar.gz: cb45c9e7bbf2e9df285dea8e555aa90d96c330159f2604113fbf25389cdf6597
5
5
  SHA512:
6
- metadata.gz: 377a11eb888da3c77610a5a2f69d5beabca2dfa18a948d1040c2237355a33ab5e83735bf4768bdcae3af804b02c4982fa62542587f4e925f60283efd39cee804
7
- data.tar.gz: df98f064d45904b6ef2dcb3cb47e39c8e0fc9487f531e843a8428de6b2387ec2375805814abbb3485c476cdc49a32958cdf104b9b2343b7be707b8a834758566
6
+ metadata.gz: 574b3bb7e42ce0fdeff179dd37bc19dab1b40038c7514701fe9ae425e8f48972f455030bf8aa735515a5d33fafe91ccbbe80919b751168857646b37745dbee88
7
+ data.tar.gz: 0dd7baa8ef36719a7b738083741ac81cd498a7826c5464207704e355471448142473409e5f219c7d1490a0018d7f00faa00db6724c4be60d7c99904c3fcab5a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.1.11 (2024-08-10)
4
+
5
+ - [7.1-stable] fix PictureEditor defaultCropSize [#2991](https://github.com/AlchemyCMS/alchemy_cms/pull/2991) ([alchemycms-bot](https://github.com/alchemycms-bot))
6
+ - [7.1-stable] Fix combining search filters and pagination [#2981](https://github.com/AlchemyCMS/alchemy_cms/pull/2981) ([alchemycms-bot](https://github.com/alchemycms-bot))
7
+ - [7.1-stable] Clear current language when switching sites [#2973](https://github.com/AlchemyCMS/alchemy_cms/pull/2973) ([alchemycms-bot](https://github.com/alchemycms-bot))
8
+ - [7.1-stable] Remove call to missing content_positions task [#2962](https://github.com/AlchemyCMS/alchemy_cms/pull/2962) ([alchemycms-bot](https://github.com/alchemycms-bot))
9
+ - [7.1-stable] Fix re-render of layoutpages form if validation fails [#2953](https://github.com/AlchemyCMS/alchemy_cms/pull/2953) ([alchemycms-bot](https://github.com/alchemycms-bot))
10
+
3
11
  ## 7.1.10 (2024-06-27)
4
12
 
5
13
  - [7.1-stable] Prevent Javascript error if the page will be unlocked [#2945](https://github.com/AlchemyCMS/alchemy_cms/pull/2945) ([alchemycms-bot](https://github.com/alchemycms-bot))
@@ -17,6 +17,25 @@ module Alchemy
17
17
  def edit
18
18
  @page = Page.find(params[:id])
19
19
  end
20
+
21
+ def update
22
+ @page = Page.find(params[:id])
23
+ if @page.update(page_params)
24
+ @notice = Alchemy.t("Page saved", name: @page.name)
25
+ render "alchemy/admin/pages/update"
26
+ else
27
+ render :edit, status: :unprocessable_entity
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def page_params
34
+ params.require(:page).permit(
35
+ :name,
36
+ :tag_list
37
+ )
38
+ end
20
39
  end
21
40
  end
22
41
  end
@@ -6,11 +6,21 @@ module Alchemy
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
+ # This needs to happen before BaseController#current_alchemy_site sets the session value.
10
+ prepend_before_action :clear_current_language_from_session, if: :switching_site?, only: :index
9
11
  before_action :load_current_language
10
12
  end
11
13
 
12
14
  private
13
15
 
16
+ def switching_site?
17
+ params[:site_id].present? && (params[:site_id] != session[:alchemy_site_id]&.to_s)
18
+ end
19
+
20
+ def clear_current_language_from_session
21
+ session.delete(:alchemy_language_id)
22
+ end
23
+
14
24
  def load_current_language
15
25
  @current_language = if session[:alchemy_language_id].present?
16
26
  set_alchemy_language(session[:alchemy_language_id])
@@ -7,7 +7,7 @@ const UPDATE_DELAY = 125
7
7
  const IMAGE_PLACEHOLDER = '<i class="icon ri-image-line ri-fw"></i>'
8
8
  const THUMBNAIL_SIZE = "160x120"
9
9
 
10
- class PictureEditor {
10
+ export class PictureEditor {
11
11
  constructor(container) {
12
12
  this.container = container
13
13
  this.cropFromField = container.querySelector("[data-crop-from]")
@@ -131,10 +131,10 @@ class PictureEditor {
131
131
  if (!this.imageCropperEnabled) return []
132
132
 
133
133
  const mask = this.targetSize.split("x").map((n) => parseInt(n))
134
- const zoom = max([
134
+ const zoom = max(
135
135
  mask[0] / this.imageFileWidth,
136
136
  mask[1] / this.imageFileHeight
137
- ])
137
+ )
138
138
 
139
139
  return [Math.round(mask[0] / zoom), Math.round(mask[1] / zoom)]
140
140
  }
@@ -1,4 +1,4 @@
1
- <%= alchemy_form_for [:admin, @page], class: 'edit_page' do |f| %>
1
+ <%= alchemy_form_for [:admin, @page], url: alchemy.admin_layoutpage_path(@page), class: 'edit_page' do |f| %>
2
2
  <%= f.input :name, autofocus: true %>
3
3
  <div class="input string">
4
4
  <%= f.label :tag_list %>
@@ -1,6 +1,6 @@
1
1
  <%= form_tag url_for, method: :get, class: 'per-page-select-form' do |f| %>
2
2
  <% search_filter_params.reject { |k, _| k == 'page' || k == 'per_page' }.each do |key, value| %>
3
- <% if value.is_a? ActionController::Parameters %>
3
+ <% if value.respond_to?(:keys) %>
4
4
  <% value.each do |k, v| %>
5
5
  <%= hidden_field_tag "#{key}[#{k}]", v, id: nil %>
6
6
  <% end %>
data/config/routes.rb CHANGED
@@ -50,7 +50,7 @@ Alchemy::Engine.routes.draw do
50
50
  end
51
51
  end
52
52
 
53
- resources :layoutpages, only: [:index, :edit]
53
+ resources :layoutpages, only: [:index, :edit, :update]
54
54
 
55
55
  resources :pictures, except: [:new] do
56
56
  collection do
@@ -96,7 +96,7 @@ module Alchemy
96
96
  can :leave, :alchemy_admin
97
97
  can [:info, :help], :alchemy_admin_dashboard
98
98
  can :manage, :alchemy_admin_clipboard
99
- can :edit, :alchemy_admin_layoutpages
99
+ can :update, :alchemy_admin_layoutpages
100
100
  can :tree, :alchemy_admin_pages
101
101
 
102
102
  # Resources
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples_for "a controller that loads current language" do |args|
4
+ context "when session has current language id key" do
5
+ let!(:site_1) { create(:alchemy_site) }
6
+ let!(:site_1_default_language) { create :alchemy_language, site: site_1, default: true }
7
+ let!(:another_site_1_language) { create :alchemy_language, site: site_1, code: :de }
8
+ let(:site_2) { create :alchemy_site, host: "another.host", languages: [build(:alchemy_language, code: :en), build(:alchemy_language, code: :de)] }
9
+
10
+ context "on index action" do
11
+ context "when switching the current site" do
12
+ before do
13
+ session[:alchemy_site_id] = site_1.id
14
+ session[:alchemy_language_id] = another_site_1_language.id
15
+ end
16
+
17
+ it "sets @current_language to the new site default language" do
18
+ get :index, params: {site_id: site_2.id}
19
+ expect(assigns(:current_language)).to eq site_2.default_language
20
+ end
21
+ end
22
+
23
+ context "when no language to set" do
24
+ it "shows flash warning with redirect" do
25
+ Alchemy::Language.destroy_all
26
+ get :index, params: {site_id: site_1.id}
27
+ expect(flash[:warning]).to eq Alchemy.t("Please create a language first.")
28
+ expect(response).to redirect_to admin_languages_path
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "7.1.10"
4
+ VERSION = "7.1.11"
5
5
 
6
6
  def self.version
7
7
  VERSION
@@ -7,7 +7,6 @@ namespace :alchemy do
7
7
  desc "Tidy up Alchemy database."
8
8
  task :up do
9
9
  Rake::Task["alchemy:tidy:element_positions"].invoke
10
- Rake::Task["alchemy:tidy:content_positions"].invoke
11
10
  Rake::Task["alchemy:tidy:remove_orphaned_records"].invoke
12
11
  Rake::Task["alchemy:tidy:remove_trashed_elements"].invoke
13
12
  Rake::Task["alchemy:tidy:remove_duplicate_legacy_urls"].invoke
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.10
4
+ version: 7.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2024-06-27 00:00:00.000000000 Z
16
+ date: 2024-08-10 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionmailer
@@ -1304,6 +1304,7 @@ files:
1304
1304
  - lib/alchemy/test_support.rb
1305
1305
  - lib/alchemy/test_support/capybara_helpers.rb
1306
1306
  - lib/alchemy/test_support/config_stubbing.rb
1307
+ - lib/alchemy/test_support/current_language_shared_examples.rb
1307
1308
  - lib/alchemy/test_support/factories/attachment_factory.rb
1308
1309
  - lib/alchemy/test_support/factories/dummy_user_factory.rb
1309
1310
  - lib/alchemy/test_support/factories/element_factory.rb