Skip to content

Commit

Permalink
add convenience method to the turbostreambuilder to remove a componen…
Browse files Browse the repository at this point in the history
…t such that you do not need to care about the id
  • Loading branch information
jbrichau committed Aug 26, 2023
1 parent bdcb561 commit 334aa15
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
after: anId with: aRenderable

self turboStreamAction: 'after' target: anId with: aRenderable
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
append: anId with: aRenderable

self turboStreamAction: 'append' target: anId with: aRenderable
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
before: anId with: aRenderable

self turboStreamAction: 'before' target: anId with: aRenderable
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
prepend: anId with: aRenderable

self turboStreamAction: 'prepend' target: anId with: aRenderable
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
remove: anId

self turboStreamAction: 'remove' target: anId with: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
convenience
removeComponent: aComponent

self remove: aComponent turboframeDecoration id
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
replace: anId with: aRenderable

self turboStreamAction: 'replace' target: anId with: aRenderable
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
private
turboStreamAction: aName target: anId with: aRenderable

(canvas tag: 'turbo-stream')
attributeAt: 'action' put: aName;
attributeAt: 'target' put: anId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
actions
update: anId with: aRenderable

self turboStreamAction: 'update' target: anId with: aRenderable
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
processing
processRendering: aResponse

self requestContext request isTurboFrameRequest
ifTrue: [
aResponse
doNotCache;
contentType: self application contentType.
self renderTurboFrameResponseOn: aResponse stream ]
ifFalse: [ super processRendering: aResponse ]

Check warning on line 10 in repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/processRendering..st

View check run for this annotation

Codecov / codecov/patch

repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/processRendering..st#L1-L10

Added lines #L1 - L10 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
renderContext: anObject

renderContext := anObject

Check warning on line 4 in repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderContext..st

View check run for this annotation

Codecov / codecov/patch

repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderContext..st#L1-L4

Added lines #L1 - L4 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rendering
renderTurboFrameResponseOn: aStream
"Render aRenderable on aStream."

| document turboframeId |
turboframeId := self requestContext request headerAt: 'turbo-frame'.
document := (WAHtmlDocument on: aStream codec: self requestContext codec)
scriptGenerator: self requestContext handler scriptGeneratorClass new;
yourself.
renderContext
document: document
during: [
renderContext
visitor: ((WATurboFramePresenterGuide client: (WARenderVisitor context: renderContext)) id: turboframeId)
during: [
self presenter renderWithContext: renderContext ]
"self presenter allPresentersDo: [ :p | ((p isKindOf: WATurboFrame) and: [ turboframeId = p id ]) ifTrue:[ self halt. p renderWithContext: renderContext ] ]" ].
document scriptGenerator closeOn: document

Check warning on line 18 in repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderTurboFrameResponseOn..st

View check run for this annotation

Codecov / codecov/patch

repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderTurboFrameResponseOn..st#L1-L18

Added lines #L1 - L18 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "WARenderPhaseContinuation",
"category" : "Seaside-RenderLoop-Continuations",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"renderContext"
],
"name" : "WATurboRenderPhaseContinuation",
"type" : "normal"
}

0 comments on commit 334aa15

Please sign in to comment.