alchemy_cms 8.1.11 → 8.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,12 @@ export class RemoteSelect extends AlchemyHTMLElement {
14
14
  url: { default: "" }
15
15
  }
16
16
 
17
+ // Select2 manages its own DOM after initialization, so attribute changes
18
+ // must not trigger the default re-render which would destroy the widget.
19
+ static get observedAttributes() {
20
+ return []
21
+ }
22
+
17
23
  async connected() {
18
24
  await setupSelectLocale()
19
25
 
@@ -34,6 +40,11 @@ export class RemoteSelect extends AlchemyHTMLElement {
34
40
  * @param {Event} event
35
41
  */
36
42
  onChange(event) {
43
+ // Update selection attribute so re-attaching the select2 component to
44
+ // the same input (e.g. after dragndrop) does not reset the selection.
45
+ if (event.added) {
46
+ this.setAttribute("selection", JSON.stringify(event.added))
47
+ }
37
48
  this.dispatchCustomEvent("RemoteSelect.Change", {
38
49
  removed: event.removed,
39
50
  added: event.added
@@ -49,24 +49,16 @@ module Alchemy
49
49
  # not tracked via the polymorphic +related_object+ association, so the
50
50
  # base scope cannot see them.
51
51
  #
52
- # Uses a correlated +NOT EXISTS+ subquery that builds the per-row LIKE
53
- # pattern with +Arel::Nodes::Concat+, which compiles to +||+ on
54
- # SQLite/PostgreSQL and +CONCAT()+ on MySQL.
52
+ # Extracts referenced attachment IDs from ingredient values via Ruby
53
+ # regex to stay database-agnostic.
55
54
  scope :deletable, -> do
56
- ingredients = Alchemy::Ingredient.arel_table
57
- pattern = Arel::Nodes::Concat.new(
58
- Arel::Nodes::Concat.new(
59
- Arel::Nodes.build_quoted("%/attachment/"),
60
- arel_table[:id]
61
- ),
62
- Arel::Nodes.build_quoted("/download%")
63
- )
64
- referenced = ingredients
65
- .project(1)
66
- .where(ingredients[:value].matches(pattern))
67
-
68
- where("#{table_name}.id NOT IN (#{RelatableResource::RELATED_INGREDIENTS_SUBQUERY})", type: name)
69
- .where.not(referenced.exists)
55
+ referenced_ids = Alchemy::Ingredient
56
+ .where("value LIKE '%/attachment/%/download%'")
57
+ .pluck(:value)
58
+ .flat_map { |v| v.scan(%r{/attachment/(\d+)/download}).flatten.map(&:to_i) }
59
+
60
+ scope = where("#{table_name}.id NOT IN (#{RelatableResource::RELATED_INGREDIENTS_SUBQUERY})", type: name)
61
+ referenced_ids.any? ? scope.where.not(id: referenced_ids) : scope
70
62
  end
71
63
 
72
64
  # We need to define this method here to have it available in the validations below.
@@ -73,6 +73,15 @@ alchemy-message {
73
73
  margin-top: 0;
74
74
  }
75
75
 
76
+ h1,
77
+ h2,
78
+ h3,
79
+ p {
80
+ &:last-child {
81
+ margin-bottom: 0;
82
+ }
83
+ }
84
+
76
85
  a[href] {
77
86
  text-decoration-color: inherit;
78
87
  text-decoration-thickness: 1px;
@@ -6,7 +6,7 @@
6
6
  <%= render_icon "file-edit", size: "xl" %>
7
7
  </sl-tooltip>
8
8
  <% else %>
9
- <%= render_icon "file-edit", size: "xl" %>
9
+ <%= render_icon "file", size: "xl" %>
10
10
  <% end %>
11
11
  <% else %>
12
12
  <sl-tooltip class="like-hint-tooltip" content="<%= Alchemy.t("Your user role does not allow you to edit this page") %>" placement="bottom-start">
@@ -1,11 +1,18 @@
1
1
  class ConvertSelectValueForMultiple < ActiveRecord::Migration[7.1]
2
2
  def up
3
3
  say_with_time "Converting Alchemy::Ingredients::Select values to multiple" do
4
- update <<-SQL.squish
5
- UPDATE alchemy_ingredients
6
- SET value = '["' || value || '"]'
7
- WHERE type = 'Alchemy::Ingredients::Select' AND value NOT LIKE '["%"]';
8
- SQL
4
+ Alchemy::Ingredients::Select
5
+ .where.not("value LIKE ?", '["%')
6
+ .update_all(
7
+ Arel.sql(
8
+ case ActiveRecord::Base.connection.adapter_name
9
+ when /mysql|mariadb/i
10
+ "value = CONCAT('[\"', value, '\"]')"
11
+ else
12
+ "value = '[\"' || value || '\"]'"
13
+ end
14
+ )
15
+ )
9
16
  end
10
17
  end
11
18
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "8.1.11"
4
+ VERSION = "8.1.13"
5
5
 
6
6
  def self.version
7
7
  VERSION
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: 8.1.11
4
+ version: 8.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -1458,7 +1458,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1458
1458
  version: '0'
1459
1459
  requirements:
1460
1460
  - ImageMagick (libmagick), v6.6 or greater.
1461
- rubygems_version: 4.0.6
1461
+ rubygems_version: 4.0.10
1462
1462
  specification_version: 4
1463
1463
  summary: A powerful, userfriendly and flexible CMS for Rails
1464
1464
  test_files: []