Skip to content

Commit

Permalink
Add DelayedViewRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Aug 8, 2017
1 parent 5a56a80 commit a9c9d4f
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 1 deletion.
@@ -0,0 +1,14 @@
tests-Supplying
testDelayedViewShowingWhileEvaluatingThenRendering

| supplier delayedView html |

supplier := Html5ComponentSupplier new.

delayedView := supplier delayedViewShowing: 'Loading...' whileEvaluating: [ ] thenRendering: 'Done!'.

html := self render: delayedView.

self
assert: html
equals: '<div id="Delayed-id1">Loading...</div><script type="text/javascript">Willow.callServer({"url":"/","data":"2"});</script>'
Expand Up @@ -6,6 +6,7 @@
"testTableBuilderWithRowCommand" : "GabrielOmarCotelli 6/8/2017 18:12",
"testTableBuilderForHeadlessTable" : "GabrielOmarCotelli 6/8/2017 18:14",
"testSingleLineTextFieldApplying" : "GabrielOmarCotelli 4/25/2017 11:10",
"testDelayedViewShowingWhileEvaluatingThenRendering" : "GabrielOmarCotelli 8/8/2017 17:48",
"testUnorderedListApplyingListingApplyingToEach" : "GabrielOmarCotelli 5/2/2017 17:51",
"testAsynchronicButtonLabeledApplying" : "GabrielOmarCotelli 4/11/2017 18:05",
"testTableBuilderWithSimpleColumns" : "GabrielOmarCotelli 6/8/2017 18:02",
Expand Down
2 changes: 1 addition & 1 deletion source/Willow-Tests.package/monticello.meta/version

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions source/Willow.package/DelayedViewRenderer.class/README.md
@@ -0,0 +1 @@
I'm a web view showing a throbber while evaluating an action block and then rendering another view
@@ -0,0 +1,4 @@
as yet unclassified
showing: aThrobber whileEvaluating: aBlock thenRendering: aView

^ self new initializeShowing: aThrobber whileEvaluating: aBlock thenRendering: aView
@@ -0,0 +1,10 @@
initialization
initializeInteractionToEvaluate: aBlock thenRender: aView

interaction := WebComponentInteraction triggeredOnClick.
interaction
onTriggerExecute:
(EvaluatingCommand
for: [ aBlock value.
self setCurrentViewTo: aView ]);
onTriggerExecute: (RenderingCommand for: identifiedDelayedView)
@@ -0,0 +1,6 @@
initialization
initializeShowing: aThrobber whileEvaluating: aBlock thenRendering: aView

self setCurrentViewTo: aThrobber.
identifiedDelayedView := IdentifiedWebView forDivNamed: 'Delayed' containing: [ :canvas | canvas render: currentView ].
self initializeInteractionToEvaluate: aBlock thenRender: aView
@@ -0,0 +1,7 @@
rendering
renderContentOn: aCanvas

aCanvas render: identifiedDelayedView.
"This is way too hacky, but for now is the way to go"
interaction prepareActions.
aCanvas document addLoadScript: (interaction commandToExecuteOn: aCanvas)
@@ -0,0 +1,4 @@
initialization
setCurrentViewTo: aView

currentView := aView
@@ -0,0 +1,11 @@
{
"instance" : {
"renderContentOn:" : "GabrielOmarCotelli 8/8/2017 17:45",
"setCurrentViewTo:" : "GabrielOmarCotelli 8/8/2017 17:45",
"initializeInteractionToEvaluate:thenRender:" : "GabrielOmarCotelli 8/8/2017 17:45",
"initializeShowing:whileEvaluating:thenRendering:" : "GabrielOmarCotelli 8/8/2017 17:50"
},
"class" : {
"showing:whileEvaluating:thenRendering:" : "GabrielOmarCotelli 8/8/2017 17:45"
}
}
15 changes: 15 additions & 0 deletions source/Willow.package/DelayedViewRenderer.class/properties.json
@@ -0,0 +1,15 @@
{
"commentStamp" : "GabrielOmarCotelli 8/8/2017 17:46",
"super" : "WAPresenter",
"category" : "Willow-WebViews",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"identifiedDelayedView",
"currentView",
"interaction"
],
"name" : "DelayedViewRenderer",
"type" : "normal"
}
@@ -0,0 +1,4 @@
Supplying
delayedViewShowing: aThrobber whileEvaluating: aBlock thenRendering: aRenderable

^ DelayedViewRenderer showing: aThrobber whileEvaluating: aBlock thenRendering: aRenderable
@@ -1,5 +1,6 @@
{
"instance" : {
"delayedViewShowing:whileEvaluating:thenRendering:" : "GabrielOmarCotelli 8/8/2017 17:45",
"synchronicButtonLabeled:applying:evaluating:" : "GabrielOmarCotelli 4/25/2017 10:33",
"updateRoot:" : "GabrielOmarCotelli 4/3/2017 09:51",
"tableBuilder" : "GabrielOmarCotelli 6/8/2017 17:53",
Expand Down
Binary file modified source/Willow.package/monticello.meta/version
Binary file not shown.

0 comments on commit a9c9d4f

Please sign in to comment.