Skip to content

Commit

Permalink
Merge 16b74cd into fcdc80c
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabacman authored Mar 9, 2020
2 parents fcdc80c + 16b74cd commit 7bf5f5b
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 58 deletions.
31 changes: 29 additions & 2 deletions source/Willow-Tests/CombinedWebInteractionInterpreterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,39 @@ CombinedWebInteractionInterpreterTest >> testDisable [
interpreter disable.
canvas
render: okButton;
render: cancelButton ].
render: cancelButton
].
self
assert: html
equals:
'<button id="button-id1" type="button">Ok</button><button id="button-id2" type="button">Cancel</button><script type="text/javascript">$("#button-id1").click(function(event){$(this).prop("disabled",true)});$("#button-id2").click(function(event){$(this).prop("disabled",true)});</script>'
]

{ #category : #'tests-Configuring-DOM' }
CombinedWebInteractionInterpreterTest >> testDisableSpecificComponent [

| interpreter html id |

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.
id := '15'.

html := self
renderUsing: [ :canvas |
| textInput |

textInput := canvas textInput.
textInput id: id.
interpreter disable: textInput.
canvas
render: okButton;
render: cancelButton
].
self
assert: html
equals:
'<input id="15" type="text"/><button id="button-id1" type="button">Ok</button><button id="button-id2" type="button">Cancel</button><script type="text/javascript">$("#button-id1").click(function(event){$("#15").prop("disabled",true)});$("#button-id2").click(function(event){$("#15").prop("disabled",true)});</script>'
]

{ #category : #'tests-Configuring-DOM' }
CombinedWebInteractionInterpreterTest >> testEnable [

Expand All @@ -221,7 +247,8 @@ CombinedWebInteractionInterpreterTest >> testEnable [
interpreter enable: textInput.
canvas
render: okButton;
render: cancelButton ].
render: cancelButton
].
self
assert: html
equals:
Expand Down
55 changes: 29 additions & 26 deletions source/Willow/CombinedWebInteractionInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,22 @@ CombinedWebInteractionInterpreter >> determineBehaviorByEvaluating: aCallbackBlo
interpreter determineBehaviorByEvaluating: aCallbackBlock with: aParameter]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> disable [

self interpretersDo: [:interpreter | interpreter disable]
self interpretersDo: [ :interpreter | interpreter disable ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> disable: aComponent [

self interpretersDo: [ :interpreter | interpreter disable: aComponent ]
]

{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> enable: aComponent [

self interpretersDo: [:interpreter | interpreter enable: aComponent]
self interpretersDo: [ :interpreter | interpreter enable: aComponent ]
]

{ #category : #Configuring }
Expand All @@ -82,13 +88,13 @@ CombinedWebInteractionInterpreter >> executeOnClient: aServerIndependentAction [
self interpretersDo: [:interpreter | interpreter executeOnClient: aServerIndependentAction]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> focus: anIdentifiedWebView [

self interpretersDo: [:interpreter | interpreter focus: anIdentifiedWebView]
self interpretersDo: [ :interpreter | interpreter focus: anIdentifiedWebView ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> focusUsing: aComponentProvider [

self interpretersDo: [ :interpreter | interpreter focusUsing: aComponentProvider ]
Expand Down Expand Up @@ -135,7 +141,7 @@ CombinedWebInteractionInterpreter >> open: aView [
self interpretersDo: [ :interpreter | interpreter open: aView ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> remove: anIdentifiedView [

self interpretersDo: [ :interpreter | interpreter remove: anIdentifiedView ]
Expand All @@ -147,16 +153,16 @@ CombinedWebInteractionInterpreter >> removeCssClass: aCssStyle fromComponentsMat
self interpretersDo: [ :interpreter | interpreter removeCssClass: aCssStyle fromComponentsMatching: aComponentProvider ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> render: anIdentifiedView [

self interpretersDo: [:interpreter | interpreter render: anIdentifiedView]
self interpretersDo: [ :interpreter | interpreter render: anIdentifiedView ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> renderAll: anIdentifiedViewCollection [

self interpretersDo: [:interpreter | interpreter renderAll: anIdentifiedViewCollection]
self interpretersDo: [ :interpreter | interpreter renderAll: anIdentifiedViewCollection ]
]

{ #category : #Configuring }
Expand Down Expand Up @@ -195,24 +201,20 @@ CombinedWebInteractionInterpreter >> serializeWithHiddenInputs [
self interpretersDo: [:interpreter | interpreter serializeWithHiddenInputs]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> setValueTo: aValueProvider thenTriggerChangeOf: anIdentifiedView [

self
interpretersDo: [ :interpreter |
interpreter
setValueTo: aValueProvider
thenTriggerChangeOf: anIdentifiedView ]
interpretersDo:
[ :interpreter | interpreter setValueTo: aValueProvider thenTriggerChangeOf: anIdentifiedView ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> setValueTo: aValueProvider withoutTriggeringChangeOnComponentWithId: identifier [

self
interpretersDo: [ :interpreter |
interpreter
setValueTo: aValueProvider
withoutTriggeringChangeOnComponentWithId: identifier ]
interpretersDo:
[ :interpreter | interpreter setValueTo: aValueProvider withoutTriggeringChangeOnComponentWithId: identifier ]
]

{ #category : #Configuring }
Expand All @@ -233,16 +235,17 @@ CombinedWebInteractionInterpreter >> submitFormStyledAs: aCssStyle [
self interpretersDo: [:interpreter | interpreter submitFormStyledAs: aCssStyle]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> temporarilyDisableAndTransform: anIdentifiedView into: aView [

self interpretersDo: [ :interpreter | interpreter temporarilyDisableAndTransform: anIdentifiedView into: aView ]
self
interpretersDo: [ :interpreter | interpreter temporarilyDisableAndTransform: anIdentifiedView into: aView ]
]

{ #category : #Configuring }
{ #category : #'Configuring - DOM' }
CombinedWebInteractionInterpreter >> temporarilyDisableAndTransformInto: aView [

self interpretersDo: [:interpreter | interpreter temporarilyDisableAndTransformInto: aView]
self interpretersDo: [ :interpreter | interpreter temporarilyDisableAndTransformInto: aView ]
]

{ #category : #'Configuring - CSS' }
Expand Down
10 changes: 10 additions & 0 deletions source/Willow/ComponentEnableStatusChangingCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ Class {
#category : #'Willow-WebInteraction'
}

{ #category : #'Instance Creation' }
ComponentEnableStatusChangingCommand class >> disabling: anIdentifiedComponent [

^ self
obtainingComponentWith: [ :canvas |
anIdentifiedComponent identifyIn: canvas.
canvas jQuery id: anIdentifiedComponent identifier ]
settingStatusTo: true
]

{ #category : #'Instance Creation' }
ComponentEnableStatusChangingCommand class >> disablingCurrentComponent [

Expand Down
31 changes: 15 additions & 16 deletions source/Willow/DelayedViewRenderer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
#instVars : [
'identifiedDelayedView',
'currentView',
'interaction'
'interpreter'
],
#category : #'Willow-WebViews'
}
Expand All @@ -19,33 +19,32 @@ DelayedViewRenderer class >> showing: aThrobber whileEvaluating: aBlock thenRend
]

{ #category : #initialization }
DelayedViewRenderer >> initializeInteractionToEvaluate: aBlock thenRender: aView [

interaction := WebComponentInteraction triggeredOnClick.
interaction
onTriggerExecute:
(DelayedCommand
withBehaviorDeterminedBy: [ :response |
aBlock value.
self setCurrentViewTo: aView ]);
onTriggerExecute: (RenderingCommand for: identifiedDelayedView)
DelayedViewRenderer >> initializeInterpreterToEvaluate: aBlock thenRender: aView [

interpreter := WebInteractionInterpreter forInstantEvaluation.
interpreter
determineBehaviorByEvaluating: [ :response |
aBlock value.
self setCurrentViewTo: aView
];
render: identifiedDelayedView
]

{ #category : #initialization }
DelayedViewRenderer >> initializeShowing: aThrobber whileEvaluating: aBlock thenRendering: aView [

self setCurrentViewTo: aThrobber.
identifiedDelayedView := IdentifiedWebView forDivNamed: 'Delayed' containing: [ :canvas | canvas render: currentView ].
self initializeInteractionToEvaluate: aBlock thenRender: aView
identifiedDelayedView := IdentifiedWebView
forDivNamed: 'Delayed'
containing: [ :canvas | canvas render: currentView ].
self initializeInterpreterToEvaluate: aBlock thenRender: aView
]

{ #category : #rendering }
DelayedViewRenderer >> 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)
interpreter applyTo: self on: aCanvas
]

{ #category : #initialization }
Expand Down
32 changes: 18 additions & 14 deletions source/Willow/WebInteractionInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ WebInteractionInterpreter >> disable [
interaction onTriggerExecute: ComponentEnableStatusChangingCommand disablingCurrentComponent
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> disable: aComponent [

interaction onTriggerExecute: ( ComponentEnableStatusChangingCommand disabling: aComponent )
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> enable: aComponent [

interaction onTriggerExecute: (ComponentEnableStatusChangingCommand enabling: aComponent)
interaction onTriggerExecute: ( ComponentEnableStatusChangingCommand enabling: aComponent )
]

{ #category : #Configuring }
Expand All @@ -150,15 +156,14 @@ WebInteractionInterpreter >> executeOnClient: aServerIndependentAction [
{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> focus: anIdentifiedWebView [

interaction
onTriggerExecute: (ComponentFocusingCommand for: anIdentifiedWebView)
interaction onTriggerExecute: ( ComponentFocusingCommand for: anIdentifiedWebView )
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> focusUsing: aComponentProvider [

interaction
onTriggerExecute: (ComponentFocusingCommand findingComponentUsing: aComponentProvider)
onTriggerExecute: ( ComponentFocusingCommand findingComponentUsing: aComponentProvider )
]

{ #category : #Configuring }
Expand Down Expand Up @@ -199,7 +204,7 @@ WebInteractionInterpreter >> open: aView [
{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> remove: anIdentifiedView [

interaction onTriggerExecute: (ComponentRemovingCommand for: anIdentifiedView)
interaction onTriggerExecute: ( ComponentRemovingCommand for: anIdentifiedView )
]

{ #category : #'Configuring - CSS' }
Expand All @@ -216,13 +221,13 @@ WebInteractionInterpreter >> removeCssClass: aCssStyle fromComponentsMatching: a
{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> render: anIdentifiedView [

interaction onTriggerExecute: (RenderingCommand for: anIdentifiedView)
interaction onTriggerExecute: ( RenderingCommand for: anIdentifiedView )
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> renderAll: anIdentifiedViewCollection [

interaction onTriggerExecute: (RenderingCommand forAll: anIdentifiedViewCollection)
interaction onTriggerExecute: ( RenderingCommand forAll: anIdentifiedViewCollection )
]

{ #category : #Configuring }
Expand Down Expand Up @@ -266,19 +271,17 @@ WebInteractionInterpreter >> setValueTo: aValueProvider thenTriggerChangeOf: anI

interaction
onTriggerExecute:
(ComponentValueSettingCommand
( ComponentValueSettingCommand
triggeringChangesObtainingIdentifierFrom: [ anIdentifiedView identifier ]
valueFrom: aValueProvider)
valueFrom: aValueProvider )
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> setValueTo: aValueProvider withoutTriggeringChangeOnComponentWithId: identifier [

interaction
onTriggerExecute:
(ComponentValueSettingCommand
obtainingIdentifierFrom: [ identifier ]
valueFrom: aValueProvider)
( ComponentValueSettingCommand obtainingIdentifierFrom: [ identifier ] valueFrom: aValueProvider )
]

{ #category : #Configuring }
Expand Down Expand Up @@ -315,13 +318,14 @@ WebInteractionInterpreter >> submitFormStyledAs: aCssStyle [
{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> temporarilyDisableAndTransform: anIdentifiedView into: aView [

interaction onTriggerExecute: (TemporarilyDisablingCommand transforming: anIdentifiedView into: aView)
interaction
onTriggerExecute: ( TemporarilyDisablingCommand transforming: anIdentifiedView into: aView )
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreter >> temporarilyDisableAndTransformInto: aView [

interaction onTriggerExecute: (TemporarilyDisablingCommand transformingCurrentViewInto: aView)
interaction onTriggerExecute: ( TemporarilyDisablingCommand transformingCurrentViewInto: aView )
]

{ #category : #'Configuring - CSS' }
Expand Down
6 changes: 6 additions & 0 deletions source/Willow/WebInteractionInterpreterBehavior.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ WebInteractionInterpreterBehavior >> disable [
self subclassResponsibility
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreterBehavior >> disable: aComponent [

self subclassResponsibility
]

{ #category : #'Configuring - DOM' }
WebInteractionInterpreterBehavior >> enable: aComponent [

Expand Down

0 comments on commit 7bf5f5b

Please sign in to comment.