plutonium 0.24.7 → 0.25.1

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.
@@ -22,6 +22,7 @@ module Plutonium
22
22
  options[:label] ||= interaction.label
23
23
  options[:description] ||= interaction.description
24
24
  options[:icon] ||= interaction.icon
25
+ options[:turbo_frame] = "remote_modal" unless options.key?(:turbo_frame)
25
26
 
26
27
  super(name, **options)
27
28
  end
@@ -5,8 +5,8 @@ module Plutonium
5
5
  request.headers["Turbo-Frame"]
6
6
  end
7
7
 
8
- def modal_frame_tag(&)
9
- turbo_frame_tag("modal", &)
8
+ def remote_modal_frame_tag(&)
9
+ turbo_frame_tag("remote_modal", &)
10
10
  end
11
11
  end
12
12
  end
@@ -1,7 +1,7 @@
1
1
  module Plutonium
2
2
  module Helpers
3
3
  module TurboStreamActionsHelper
4
- def redirect(url)
4
+ def turbo_stream_redirect(url)
5
5
  turbo_stream_action_tag :redirect, url:
6
6
  end
7
7
  end
@@ -27,7 +27,7 @@ module Plutonium
27
27
  def interactive_record_action
28
28
  build_interactive_record_action_interaction
29
29
 
30
- if helpers.current_turbo_frame == "modal"
30
+ if helpers.current_turbo_frame == "remote_modal"
31
31
  render layout: false
32
32
  else
33
33
  render :interactive_record_action
@@ -56,10 +56,10 @@ module Plutonium
56
56
 
57
57
  format.any { redirect_to return_url, status: :see_other }
58
58
 
59
- if helpers.current_turbo_frame == "modal"
59
+ if helpers.current_turbo_frame == "remote_modal"
60
60
  format.turbo_stream do
61
61
  render turbo_stream: [
62
- turbo_stream.redirect(return_url)
62
+ helpers.turbo_stream_redirect(return_url)
63
63
  ]
64
64
  end
65
65
  end
@@ -73,13 +73,6 @@ module Plutonium
73
73
  render "errors", status: :unprocessable_entity
74
74
  end
75
75
 
76
- if helpers.current_turbo_frame == "modal"
77
- format.turbo_stream do
78
- render turbo_stream: [
79
- turbo_stream.replace(:modal, partial: "interactive_action_form")
80
- ]
81
- end
82
- end
83
76
  end
84
77
  end
85
78
  end
@@ -90,7 +83,7 @@ module Plutonium
90
83
  skip_verify_current_authorized_scope!
91
84
  build_interactive_resource_action_interaction
92
85
 
93
- if helpers.current_turbo_frame == "modal"
86
+ if helpers.current_turbo_frame == "remote_modal"
94
87
  render layout: false
95
88
  else
96
89
  render :interactive_resource_action
@@ -120,10 +113,10 @@ module Plutonium
120
113
 
121
114
  format.any { redirect_to return_url, status: :see_other }
122
115
 
123
- if helpers.current_turbo_frame == "modal"
116
+ if helpers.current_turbo_frame == "remote_modal"
124
117
  format.turbo_stream do
125
118
  render turbo_stream: [
126
- turbo_stream.redirect(return_url)
119
+ helpers.turbo_stream_redirect(return_url)
127
120
  ]
128
121
  end
129
122
  end
@@ -137,13 +130,6 @@ module Plutonium
137
130
  render "errors", status: :unprocessable_entity
138
131
  end
139
132
 
140
- if helpers.current_turbo_frame == "modal"
141
- format.turbo_stream do
142
- render turbo_stream: [
143
- turbo_stream.replace(:modal, partial: "interactive_action_form")
144
- ]
145
- end
146
- end
147
133
  end
148
134
  end
149
135
  end
@@ -156,7 +142,7 @@ module Plutonium
156
142
  # interactive_bulk
157
143
  # @interaction = current_interactive_action.interaction.new((params[:interaction] || {}).except(:resources))
158
144
 
159
- # if helpers.current_turbo_frame == "modal"
145
+ # if helpers.current_turbo_frame == "remote_modal"
160
146
  # render layout: false
161
147
  # else
162
148
  # render :interactive_bulk_action
@@ -176,10 +162,10 @@ module Plutonium
176
162
  # flash[:notice] = "TODO:#{current_interactive_action} #{collection_count} #{resource_class.model_name.human.pluralize(collection_count)} successfully updated."
177
163
 
178
164
  # format.html { redirect_to resource_url_for(resource_class) }
179
- # if helpers.current_turbo_frame == "modal"
165
+ # if helpers.current_turbo_frame == "remote_modal"
180
166
  # format.turbo_stream do
181
167
  # render turbo_stream: [
182
- # turbo_stream.redirect(resource_url_for(resource_class))
168
+ # helpers.turbo_stream_redirect(resource_url_for(resource_class))
183
169
  # ]
184
170
  # end
185
171
  # end
@@ -191,12 +177,6 @@ module Plutonium
191
177
  # @errors = @interaction.errors
192
178
  # render "errors", status: :unprocessable_entity
193
179
  # end
194
-
195
- # if helpers.current_turbo_frame == "modal"
196
- # format.turbo_stream do
197
- # render turbo_stream: turbo_stream.replace(:modal, partial: "interactive_bulk_action_form")
198
- # end
199
- # end
200
180
  # end
201
181
  # end
202
182
  end
@@ -8,6 +8,7 @@ module Plutonium
8
8
  include Phlex::Rails::Helpers::FaviconLinkTag
9
9
  include Phlex::Rails::Helpers::StylesheetLinkTag
10
10
  include Phlex::Rails::Helpers::JavascriptIncludeTag
11
+ include Phlex::Rails::Helpers::TurboFrameTag
11
12
 
12
13
  def view_template(&)
13
14
  doctype
@@ -66,6 +67,7 @@ module Plutonium
66
67
  end
67
68
 
68
69
  def render_after_main
70
+ turbo_frame_tag("remote_modal")
69
71
  end
70
72
 
71
73
  def render_content(&)
@@ -4,6 +4,8 @@ module Plutonium
4
4
  module UI
5
5
  module Page
6
6
  class InteractiveAction < Base
7
+ include Phlex::Rails::Helpers::TurboFrameTag
8
+
7
9
  private
8
10
 
9
11
  def page_title
@@ -15,7 +17,27 @@ module Plutonium
15
17
  end
16
18
 
17
19
  def render_default_content
18
- render partial("interactive_action_form")
20
+ if helpers.current_turbo_frame == "remote_modal"
21
+ dialog(
22
+ closedby: "any",
23
+ class: "rounded-md w-full max-w-3xl
24
+ bg-white dark:bg-gray-800
25
+ border border-gray-200 dark:border-gray-700
26
+ shadow-lg dark:shadow-gray-900/20
27
+ backdrop:bg-black/60 backdrop:backdrop-blur-sm
28
+ top-auto md:top-1/2 md:-translate-y-1/2 left-1/2 -translate-x-1/2
29
+ max-h-[80%] p-6
30
+ hidden open:flex flex-col
31
+ relative opacity-0 open:opacity-100
32
+ transition-opacity duration-300 ease-in-out",
33
+ data: {controller: "remote-modal"}
34
+ ) do
35
+ render_page_header
36
+ render partial("interactive_action_form")
37
+ end
38
+ else
39
+ render partial("interactive_action_form")
40
+ end
19
41
  end
20
42
 
21
43
  def page_type = :interactive_action_page
@@ -1,5 +1,5 @@
1
1
  module Plutonium
2
- VERSION = "0.24.7"
2
+ VERSION = "0.25.1"
3
3
  NEXT_MAJOR_VERSION = VERSION.split(".").tap { |v|
4
4
  v[1] = v[1].to_i + 1
5
5
  v[2] = 0
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radioactive-labs/plutonium",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Core assets for the Plutonium gem",
5
5
  "type": "module",
6
6
  "main": "src/js/core.js",
@@ -18,6 +18,7 @@ import AttachmentPreviewController from "./attachment_preview_controller.js"
18
18
  import AttachmentPreviewContainerController from "./attachment_preview_container_controller.js"
19
19
  import SidebarController from "./sidebar_controller.js"
20
20
  import PasswordVisibilityController from "./password_visibility_controller.js"
21
+ import RemoteModalController from "./remote_modal_controller.js"
21
22
 
22
23
  export default function (application) {
23
24
  // Register controllers here
@@ -40,4 +41,5 @@ export default function (application) {
40
41
  application.register("attachment-input", AttachmentInputController)
41
42
  application.register("attachment-preview", AttachmentPreviewController)
42
43
  application.register("attachment-preview-container", AttachmentPreviewContainerController)
44
+ application.register("remote-modal", RemoteModalController)
43
45
  }
@@ -0,0 +1,24 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ // Connects to data-controller="remote-modal"
4
+ export default class extends Controller {
5
+ connect() {
6
+ // Store original scroll position
7
+ this.originalScrollPosition = window.scrollY;
8
+
9
+ // Show the modal
10
+ this.element.showModal();
11
+ // Add close event listener
12
+ this.element.addEventListener('close', this.handleClose.bind(this));
13
+ }
14
+
15
+ disconnect() {
16
+ // Clean up event listener when controller is disconnected
17
+ this.element.removeEventListener('close', this.handleClose);
18
+ }
19
+
20
+ handleClose() {
21
+ // Restore the original scroll position after dialog closes
22
+ window.scrollTo(0, this.originalScrollPosition);
23
+ }
24
+ }
@@ -1,5 +1,3 @@
1
- import * as Turbo from "@hotwired/turbo"
2
-
3
- import "./turbo_debug"
4
- // import "./turbo_actions"
1
+ import "./turbo_actions"
2
+ // import "./turbo_debug"
5
3
  // import "./turbo_frame_monkey_patch"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.7
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
@@ -911,6 +911,7 @@ files:
911
911
  - src/js/controllers/nested_resource_form_fields_controller.js
912
912
  - src/js/controllers/password_visibility_controller.js
913
913
  - src/js/controllers/register_controllers.js
914
+ - src/js/controllers/remote_modal_controller.js
914
915
  - src/js/controllers/resource_collapse_controller.js
915
916
  - src/js/controllers/resource_dismiss_controller.js
916
917
  - src/js/controllers/resource_drop_down_controller.js