pages_core 3.15.1 → 3.15.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,10 +12,15 @@ function getPosition<T>(draggable: Drag.Draggable<T>) {
12
12
  }
13
13
 
14
14
  function hideDraggable<T>(
15
- draggable: Drag.Draggable<T> | null,
16
- callback: () => Drag.Draggable<T>[]
15
+ draggable: Drag.Item<T> | null,
16
+ callback: () => Drag.Item<T>[]
17
17
  ) {
18
- if (draggable && "ref" in draggable && draggable.ref.current) {
18
+ if (
19
+ draggable &&
20
+ draggable !== "Files" &&
21
+ "ref" in draggable &&
22
+ draggable.ref.current
23
+ ) {
19
24
  const prevDisplay = draggable.ref.current.style.display;
20
25
  draggable.ref.current.style.display = "none";
21
26
  const result = callback();
@@ -42,7 +42,7 @@ function mousePosition(evt: AnyTouchEvent): Drag.Position {
42
42
  if ("touches" in evt && evt.type == "touchmove") {
43
43
  x = evt.touches[0].clientX;
44
44
  y = evt.touches[0].clientY;
45
- } else if (evt instanceof MouseEvent) {
45
+ } else if ("clientX" in evt && "clientY" in evt) {
46
46
  x = evt.clientX;
47
47
  y = evt.clientY;
48
48
  }
@@ -33,6 +33,11 @@ module PagesCore
33
33
  super.in_locale(locale)
34
34
  end
35
35
 
36
+ def page_files_attributes=(attrs)
37
+ ids = page_files.map(&:id)
38
+ super(attrs.reject { |a| a["_destroy"] && ids.exclude?(a["id"]) })
39
+ end
40
+
36
41
  def files
37
42
  page_files
38
43
  end
@@ -19,11 +19,11 @@ module PagesCore
19
19
 
20
20
  after_save :update_primary_image
21
21
 
22
- accepts_nested_attributes_for :page_images,
23
- reject_if: proc { |a|
24
- a["image_id"].blank?
25
- },
26
- allow_destroy: true
22
+ accepts_nested_attributes_for(
23
+ :page_images,
24
+ reject_if: proc { |a| a["image_id"].blank? },
25
+ allow_destroy: true
26
+ )
27
27
  end
28
28
 
29
29
  def image?
@@ -42,6 +42,11 @@ module PagesCore
42
42
  super.in_locale(locale)
43
43
  end
44
44
 
45
+ def page_images_attributes=(attrs)
46
+ ids = page_images.map(&:id)
47
+ super(attrs.reject { |a| a["_destroy"] && ids.exclude?(a["id"]) })
48
+ end
49
+
45
50
  private
46
51
 
47
52
  def update_primary_image
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pages_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.1
4
+ version: 3.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-07 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails