alchemy_cms 8.0.12 → 8.0.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.
- checksums.yaml +4 -4
- data/app/assets/builds/alchemy/admin.css +1 -1
- data/app/assets/builds/alchemy/preview.min.js +1 -1
- data/app/models/alchemy/attachment.rb +9 -17
- data/app/stylesheets/alchemy/admin/notices.scss +9 -0
- data/app/views/alchemy/admin/pages/_table.html.erb +1 -1
- data/lib/alchemy/version.rb +1 -1
- metadata +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
window.Alchemy=Alchemy||{},Object.assign(Alchemy,{ElementSelector:{styles:{reset:{outline:"","outline-offset":"",cursor:""},hover:{outline:"2px dashed #f0b437","outline-offset":"4px",cursor:"pointer"},selected:{outline:"2px dashed #90b9d0","outline-offset":"4px"}},init(){window.addEventListener("message",(e=>{switch(e.data.message){case"Alchemy.blurElements":this.blurElements();break;case"Alchemy.focusElement":this.focusElement(e.data);break;default:console.info("Received unknown message!",e.data)}})),this.elements=Array.from(document.querySelectorAll("[data-alchemy-element]")),this.elements.forEach((e=>{e.addEventListener("mouseover",(()=>{e.classList.contains("selected")||Object.assign(e.style,this.getStyle("hover"))})),e.addEventListener("mouseout",(()=>{e.classList.contains("selected")||Object.assign(e.style,this.getStyle("reset"))})),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault(),this.selectElement(e),this.focusElementEditor(e)}))}))},selectElement(e){this.blurElements(e),e.classList.add("selected"),Object.assign(e.style,this.getStyle("selected")),e.scrollIntoView({behavior:"smooth",block:"start"})},blurElements(e){this.elements.forEach((t=>{t!==e&&(t.classList.remove("selected"),Object.assign(t.style,this.getStyle("reset")))}))},focusElement(e){const t=this.getElement(e.element_id);return t?this.selectElement(t):console.warn("Could not focus element with id",e.element_id)},getElement(e){return this.elements.find((t=>t.dataset.alchemyElement===e.toString()))},focusElementEditor(e){const t=e.dataset.alchemyElement;window.parent.postMessage({message:"Alchemy.focusElementEditor",element_id:t},window.location.origin)},getStyle(e){return"reset"===e?this.styles.reset:this.styles[e]}}}),Alchemy.ElementSelector.init();
|
|
1
|
+
window.Alchemy=Alchemy||{},Object.assign(Alchemy,{ElementSelector:{styles:{reset:{outline:"","outline-offset":"",cursor:""},hover:{outline:"2px dashed #f0b437","outline-offset":"4px",cursor:"pointer"},selected:{outline:"2px dashed #90b9d0","outline-offset":"4px"}},init(){window.addEventListener("message",(e=>{switch(e.data.message){case"Alchemy.blurElements":this.blurElements();break;case"Alchemy.focusElement":this.focusElement(e.data);break;default:console.info("Received unknown message!",e.data)}})),this.elements=Array.from(document.querySelectorAll("[data-alchemy-element]")),this.elements.forEach((e=>{e.addEventListener("mouseover",(()=>{e.classList.contains("selected")||Object.assign(e.style,this.getStyle("hover"))})),e.addEventListener("mouseout",(()=>{e.classList.contains("selected")||Object.assign(e.style,this.getStyle("reset"))})),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault(),this.selectElement(e),this.focusElementEditor(e)}))}))},selectElement(e){this.blurElements(e),e.classList.add("selected"),Object.assign(e.style,this.getStyle("selected")),e.scrollIntoView({behavior:"smooth",block:"start"})},blurElements(e){this.elements.forEach((t=>{t!==e&&(t.classList.remove("selected"),Object.assign(t.style,this.getStyle("reset")))}))},focusElement(e){const t=this.getElement(e.element_id);return t?this.selectElement(t):console.warn("Could not focus element with id",e.element_id)},getElement(e){return this.elements.find((t=>t.dataset.alchemyElement===e.toString()))},focusElementEditor(e){const t=e.dataset.alchemyElement;window.parent.postMessage({message:"Alchemy.focusElementEditor",element_id:t},window.location.origin)},getStyle(e){return"reset"===e?this.styles.reset:this.styles[e]}}}),Alchemy.ElementSelector.init(),window.parent.postMessage({message:"Alchemy.previewReady"},window.location.origin);
|
|
@@ -47,24 +47,16 @@ module Alchemy
|
|
|
47
47
|
# not tracked via the polymorphic +related_object+ association, so the
|
|
48
48
|
# base scope cannot see them.
|
|
49
49
|
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
# SQLite/PostgreSQL and +CONCAT()+ on MySQL.
|
|
50
|
+
# Extracts referenced attachment IDs from ingredient values via Ruby
|
|
51
|
+
# regex to stay database-agnostic.
|
|
53
52
|
scope :deletable, -> do
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
referenced = ingredients
|
|
63
|
-
.project(1)
|
|
64
|
-
.where(ingredients[:value].matches(pattern))
|
|
65
|
-
|
|
66
|
-
where("#{table_name}.id NOT IN (#{RelatableResource::RELATED_INGREDIENTS_SUBQUERY})", type: name)
|
|
67
|
-
.where.not(referenced.exists)
|
|
53
|
+
referenced_ids = Alchemy::Ingredient
|
|
54
|
+
.where("value LIKE '%/attachment/%/download%'")
|
|
55
|
+
.pluck(:value)
|
|
56
|
+
.flat_map { |v| v.scan(%r{/attachment/(\d+)/download}).flatten.map(&:to_i) }
|
|
57
|
+
|
|
58
|
+
scope = where("#{table_name}.id NOT IN (#{RelatableResource::RELATED_INGREDIENTS_SUBQUERY})", type: name)
|
|
59
|
+
referenced_ids.any? ? scope.where.not(id: referenced_ids) : scope
|
|
68
60
|
end
|
|
69
61
|
|
|
70
62
|
# We need to define this method here to have it available in the validations below.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<%= render_icon "file-edit", size: "xl" %>
|
|
7
7
|
</sl-tooltip>
|
|
8
8
|
<% else %>
|
|
9
|
-
<%= render_icon "file
|
|
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">
|
data/lib/alchemy/version.rb
CHANGED