alchemy_cms 8.1.11 → 8.1.12

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.
@@ -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,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "8.1.11"
4
+ VERSION = "8.1.12"
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.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen