File tree Expand file tree Collapse file tree 5 files changed +19
-7
lines changed
javascript/controllers/snippets
views/share/snippet_screenshots Expand file tree Collapse file tree 5 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 9
9
10
10
def new
11
11
@snippet = Snippet . find ( params [ :snippet_id ] )
12
+ @auto = params [ :auto ] == "true"
12
13
end
13
14
14
15
def create
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ def destroy
67
67
def share_snippet_redirect_url ( snippet )
68
68
case params [ :commit ]
69
69
when "Share"
70
- new_share_snippet_screenshot_url ( snippet )
70
+ new_share_snippet_screenshot_url ( snippet , auto : true )
71
71
else
72
72
edit_share_snippet_url ( snippet )
73
73
end
Original file line number Diff line number Diff line change @@ -6,10 +6,15 @@ import debug from '../../utils/debug';
6
6
const console = debug ( 'app:javascript:controllers:snippets:screenshot' ) ;
7
7
8
8
export default class extends Controller < HTMLFormElement > {
9
+ static values = {
10
+ auto : Boolean ,
11
+ } ;
12
+
9
13
static targets = [ 'snippet' , 'submitButton' ] ;
10
14
11
15
declare readonly snippetTarget : HTMLInputElement ;
12
16
declare readonly submitButtonTarget : HTMLInputElement ;
17
+ declare readonly autoValue : boolean ;
13
18
14
19
connect ( ) : void {
15
20
console . log ( 'Connect!' ) ;
@@ -19,9 +24,11 @@ export default class extends Controller<HTMLFormElement> {
19
24
this . prepareScreenshot ,
20
25
) ;
21
26
22
- // submit immediately
23
- this . submitButtonTarget . click ( ) ;
24
- this . submitButtonTarget . disabled = true ;
27
+ if ( this . autoValue ) {
28
+ // submit immediately
29
+ this . submitButtonTarget . click ( ) ;
30
+ this . submitButtonTarget . disabled = true ;
31
+ }
25
32
}
26
33
27
34
prepareScreenshot = async ( event ) => {
Original file line number Diff line number Diff line change @@ -6,8 +6,9 @@ class Share::SnippetScreenshots::Form < ApplicationComponent
6
6
7
7
attr_accessor :snippet
8
8
9
- def initialize ( snippet )
9
+ def initialize ( snippet , auto : false )
10
10
@snippet = snippet
11
+ @auto = auto
11
12
end
12
13
13
14
def view_template
@@ -17,7 +18,8 @@ def view_template
17
18
method : :post ,
18
19
class : "grid-content" ,
19
20
data : {
20
- controller : "snippet-screenshot"
21
+ controller : "snippet-screenshot" ,
22
+ snippet_screenshot_auto_value : auto? . to_s
21
23
}
22
24
) do |form |
23
25
errors
@@ -48,4 +50,6 @@ def errors
48
50
end
49
51
end
50
52
end
53
+
54
+ def auto? = !!@auto
51
55
end
Original file line number Diff line number Diff line change 1
1
<%= render Pages::Header.new(title: "Share Snippet: Screenshot") %>
2
2
<div class ="section-content container py-gap mb-3xl ">
3
3
<%= turbo_frame_tag :snippet_form , data : { turbo_action : "advance" } do %>
4
- <%= render Share ::SnippetScreenshots ::Form . new ( @snippet ) %>
4
+ <%= render Share ::SnippetScreenshots ::Form . new ( @snippet , auto : @auto ) %>
5
5
<% end %>
6
6
7
7
< br >
You can’t perform that action at this time.
0 commit comments