diff --git a/source/Willow-Bootstrap-Tests/BootstrapTypeaheadCommandTest.class.st b/source/Willow-Bootstrap-Tests/BootstrapTypeaheadCommandTest.class.st
index facb7f76..e00acd02 100644
--- a/source/Willow-Bootstrap-Tests/BootstrapTypeaheadCommandTest.class.st
+++ b/source/Willow-Bootstrap-Tests/BootstrapTypeaheadCommandTest.class.st
@@ -58,3 +58,25 @@ BootstrapTypeaheadCommandTest >> testEvaluateWithUsing [
assert: (lastResult at: 'name') equals: 'ab';
assert: (lastResult at: 'index') equals: 2
]
+
+{ #category : #tests }
+BootstrapTypeaheadCommandTest >> testRefreshingAnotherView [
+
+ | html identifiedView |
+
+ identifiedView := IdentifiedWebView forDivNamed: 'to-refresh' containing: 'Hi!'.
+
+ html := self
+ apply:
+ ( BootstrapTypeaheadCommand
+ searchingWith: [ :searchTerm | #(1 2 3 4) ]
+ withSelectionDo: [ :selectedNumber | ]
+ thenRefresh: identifiedView
+ configuredBy: [ :typeahead | typeahead minLength: 5 ] )
+ toComponentDefinedBy: [ :canvas | canvas textInput ].
+
+ self
+ assert: html
+ equals:
+ ''
+]
diff --git a/source/Willow-Bootstrap/BootstrapTypeaheadCommand.class.st b/source/Willow-Bootstrap/BootstrapTypeaheadCommand.class.st
index 30c31fd5..20d2cd3b 100644
--- a/source/Willow-Bootstrap/BootstrapTypeaheadCommand.class.st
+++ b/source/Willow-Bootstrap/BootstrapTypeaheadCommand.class.st
@@ -11,6 +11,16 @@ Class {
#category : #'Willow-Bootstrap-Frontend'
}
+{ #category : #private }
+BootstrapTypeaheadCommand class >> actionToRefresh: anIdentifiedWebView [
+
+ ^ [ :ajax :canvas |
+ anIdentifiedWebView identifyIn: canvas.
+ ajax
+ onComplete: ( ( canvas jQuery id: anIdentifiedWebView identifier ) load html: anIdentifiedWebView view )
+ ]
+]
+
{ #category : #private }
BootstrapTypeaheadCommand class >> defaultConfigurationBlock [
@@ -36,10 +46,22 @@ BootstrapTypeaheadCommand class >> searchingWith: aSearchAction labeledBy: aLabe
{ #category : #'Instance Creation' }
BootstrapTypeaheadCommand class >> searchingWith: aSearchAction labeledBy: aLabelsBlock withSelectionDo: aSelectionCallback configuredBy: aConfigurationBlock [
+ ^ self
+ searchingWith: aSearchAction
+ labeledBy: aLabelsBlock
+ withSelectionDo: aSelectionCallback
+ thenDo: [ :ajax :canvas | ]
+ configuredBy: aConfigurationBlock
+]
+
+{ #category : #'Instance Creation' }
+BootstrapTypeaheadCommand class >> searchingWith: aSearchAction labeledBy: aLabelsBlock withSelectionDo: aSelectionCallback thenDo: aPostProcessingCallback configuredBy: aConfigurationBlock [
+
^ self new
initializeSearchingWith: aSearchAction
labeledBy: aLabelsBlock
withSelectionDo: aSelectionCallback
+ thenDo: aPostProcessingCallback
configuredBy: aConfigurationBlock
]
@@ -59,16 +81,31 @@ BootstrapTypeaheadCommand class >> searchingWith: aSearchAction withSelectionDo:
configuredBy: aConfigurationBlock
]
+{ #category : #'Instance Creation' }
+BootstrapTypeaheadCommand class >> searchingWith: aSearchAction withSelectionDo: aSelectionCallback thenRefresh: anIdentifiedWebView configuredBy: aConfigurationBlock [
+
+ ^ self
+ searchingWith: aSearchAction
+ labeledBy: self defaultLabelBlock
+ withSelectionDo: aSelectionCallback
+ thenDo: ( self actionToRefresh: anIdentifiedWebView )
+ configuredBy: aConfigurationBlock
+]
+
{ #category : #private }
-BootstrapTypeaheadCommand >> afterSelectFunctionEvaluate: aSelectionCallback on: aCanvas [
+BootstrapTypeaheadCommand >> afterSelectFunctionEvaluate: aSelectionCallback thenDo: aPostProcessingCallback on: aCanvas [
| selectedIndexHolder ajax |
selectedIndexHolder := WAValueHolder new.
ajax := aCanvas jQuery ajax.
ajax
- callback: [ :activeItemIndex | selectedIndexHolder contents: activeItemIndex greaseInteger ] value: ((aCanvas jQuery alias: 'activeItem') access: self indexProperty);
- script: [ :script | aSelectionCallback value: (searchResults at: selectedIndexHolder contents) ].
+ callback: [ :activeItemIndex | selectedIndexHolder contents: activeItemIndex greaseInteger ]
+ value: ( ( aCanvas jQuery alias: 'activeItem' ) access: self indexProperty );
+ script: [ :script | aSelectionCallback value: ( searchResults at: selectedIndexHolder contents ) ].
+
+ aPostProcessingCallback value: ajax value: aCanvas.
+
^ ajax asFunction: #('activeItem')
]
@@ -104,7 +141,7 @@ BootstrapTypeaheadCommand >> indexProperty [
]
{ #category : #initialization }
-BootstrapTypeaheadCommand >> initializeSearchingWith: aSearchAction labeledBy: aLabelsBlock withSelectionDo: aSelectionCallback configuredBy: aConfigurationBlock [
+BootstrapTypeaheadCommand >> initializeSearchingWith: aSearchAction labeledBy: aLabelsBlock withSelectionDo: aSelectionCallback thenDo: aPostProcessingCallback configuredBy: aConfigurationBlock [
searchResults := #().
scriptCommand := ComponentScriptCommand
@@ -113,11 +150,12 @@ BootstrapTypeaheadCommand >> initializeSearchingWith: aSearchAction labeledBy: a
typeahead := canvas jQuery this bootstrapTypeahead.
typeahead
- source: (self searchWith: aSearchAction labels: aLabelsBlock on: canvas);
+ source: ( self searchWith: aSearchAction labels: aLabelsBlock on: canvas );
updater: self updaterFunction;
- afterSelect: (self afterSelectFunctionEvaluate: aSelectionCallback on: canvas).
+ afterSelect: ( self afterSelectFunctionEvaluate: aSelectionCallback thenDo: aPostProcessingCallback on: canvas ).
aConfigurationBlock cull: typeahead cull: canvas.
- typeahead ]
+ typeahead
+ ]
]
{ #category : #private }