Skip to content

Commit

Permalink
Merge pull request #121 from ba-st/constants_improvements
Browse files Browse the repository at this point in the history
Constants improvements
  • Loading branch information
gcotelli authored May 29, 2018
2 parents ce4c844 + 65564d9 commit 4ab95e9
Show file tree
Hide file tree
Showing 52 changed files with 299 additions and 340 deletions.
2 changes: 1 addition & 1 deletion source/BaselineOfWillow/BaselineOfWillow.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BaselineOfWillow >> setUpDependencies: spec [
spec
baseline: 'RenoirSt'
with: [ spec
repository: 'github://ba-st/RenoirSt:v5/source';
repository: 'github://ba-st/RenoirSt:v6/source';
loads: #('Deployment-Seaside-Extensions') ].

spec
Expand Down
23 changes: 13 additions & 10 deletions source/Willow-Tests/CombinedWebInteractionInterpreterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Class {
'okButton',
'cancelButton'
],
#category : 'Willow-Tests-WebInteraction'
#pools : [
'Willow'
],
#category : #'Willow-Tests-WebInteraction'
}

{ #category : #initialization }
Expand All @@ -32,7 +35,7 @@ CombinedWebInteractionInterpreterTest >> testAddCssClass [
| interpreter html |

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.
interpreter addCssClass: WillowCssStyles willow.
interpreter addCssClass: Classification >> #willow.
html := self
renderUsing: [ :canvas |
canvas
Expand All @@ -49,7 +52,7 @@ CombinedWebInteractionInterpreterTest >> testAddCssClassToComponentsMatching [
| interpreter html |

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.
interpreter addCssClass: WillowCssStyles willow toComponentsMatching: [ :canvas | canvas jQuery this ].
interpreter addCssClass: Classification >> #willow toComponentsMatching: [ :canvas | canvas jQuery this ].
html := self
renderUsing: [ :canvas |
canvas
Expand All @@ -68,7 +71,7 @@ CombinedWebInteractionInterpreterTest >> testChangeCssClassTo [

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter changeCssClass: WillowCssStyles loading to: WillowCssStyles willow.
interpreter changeCssClass: Classification >> #loading to: Classification >> #willow.

html := self
renderUsing: [ :canvas |
Expand Down Expand Up @@ -438,7 +441,7 @@ CombinedWebInteractionInterpreterTest >> testRemoveCssClassFromComponentsMatchin

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter removeCssClass: WillowCssStyles loading fromComponentsMatching: [ :canvas | canvas jQuery this ].
interpreter removeCssClass: Classification >> #loading fromComponentsMatching: [ :canvas | canvas jQuery this ].

html := self
renderUsing: [ :canvas |
Expand All @@ -458,7 +461,7 @@ CombinedWebInteractionInterpreterTest >> testRemoveCssClassFromComponentsWithCla

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter removeCssClass: WillowCssStyles loading fromComponentsWithClass: WillowCssStyles willow.
interpreter removeCssClass: Classification >> #loading fromComponentsWithClass: Classification >> #willow.

html := self
renderUsing: [ :canvas |
Expand Down Expand Up @@ -766,7 +769,7 @@ CombinedWebInteractionInterpreterTest >> testSubmitFormStyledAs [

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter submitFormStyledAs: WillowCssStyles willow.
interpreter submitFormStyledAs: Classification >> #willow.
html := self
renderUsing: [ :canvas |
canvas
Expand Down Expand Up @@ -828,7 +831,7 @@ CombinedWebInteractionInterpreterTest >> testToggleCssClass [

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter toggleCssClass: WillowCssStyles loading.
interpreter toggleCssClass: Classification >> #loading.

html := self
renderUsing: [ :canvas |
Expand All @@ -848,7 +851,7 @@ CombinedWebInteractionInterpreterTest >> testToggleCssClassOn [

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter toggleCssClass: WillowCssStyles willow on: (IdentifiedWebView forDivNamed: 'example' containing: [ ]).
interpreter toggleCssClass: Classification >> #willow on: (IdentifiedWebView forDivNamed: 'example' containing: [ ]).


html := self
Expand All @@ -869,7 +872,7 @@ CombinedWebInteractionInterpreterTest >> testToggleCssClassOnComponentsMatching

interpreter := CombinedWebInteractionInterpreter combiningInterpretersOf: self buttons.

interpreter toggleCssClass: WillowCssStyles loading onComponentsMatching: [ :canvas | canvas jQuery this ].
interpreter toggleCssClass: Classification >> #loading onComponentsMatching: [ :canvas | canvas jQuery this ].

html := self
renderUsing: [ :canvas |
Expand Down
7 changes: 5 additions & 2 deletions source/Willow-Tests/FormSubmitCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Class {
#instVars : [
'command'
],
#category : 'Willow-Tests-WebInteraction'
#pools : [
'Willow'
],
#category : #'Willow-Tests-WebInteraction'
}

{ #category : #'tests-accessing' }
Expand Down Expand Up @@ -36,7 +39,7 @@ FormSubmitCommandTest >> testModelLoadingActions [
anchor := canvas anchor.
canvas ensureIdFor: anchor.

(FormSubmitCommand forFormStyledAs: WillowCssStyles willow) modelLoadingActions do: [ :action | action value: script value: canvas ].
(FormSubmitCommand forFormStyledAs: Classification >> #willow) modelLoadingActions do: [ :action | action value: script value: canvas ].
anchor script: (canvas jQuery this onClick: script) ].

self assert: html equals: '<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("form.willow").submit()});</script>'
Expand Down
6 changes: 2 additions & 4 deletions source/Willow-Tests/TemporarilyDisablingCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ TemporarilyDisablingCommandTest >> testPriorityActions [

| command html |

command := TemporarilyDisablingCommand
transformingCurrentViewInto: [ :canvas | canvas span class: WillowCssStyles loading ].
command := TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | canvas span apply: [ :span | span addClass loading ] ].
html := self
renderUsing: [ :canvas |
| asynchronousCall anchor |
Expand Down Expand Up @@ -53,8 +52,7 @@ TemporarilyDisablingCommandTest >> testServerIndependentActions [

| command html |

command := TemporarilyDisablingCommand
transformingCurrentViewInto: [ :canvas | canvas span class: WillowCssStyles loading ].
command := TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | canvas span apply: [ :span | span addClass loading ] ].
html := self
renderUsing: [ :canvas |
| script anchor |
Expand Down
4 changes: 1 addition & 3 deletions source/Willow-Tests/WebComponentCommandBuilderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ WebComponentCommandBuilderTest >> testSetComponentStyleCommands [

| html |

html := self
apply: (self commandBuilder setStyleTo: [ :style | style background: CssSVGColors blue ])
toComponentDefinedBy: [ :canvas | canvas div ].
html := self apply: (self commandBuilder setStyleTo: [ :style :constants | style background: constants >> #colors >> #blue ]) toComponentDefinedBy: [ :canvas | canvas div ].

self assert: html equals: '<div style="background: blue;"></div>'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,13 @@ WebComponentCommandToTableRowCommandAdapterTest >> testApplyToForOn [

| html command |

command := (ComponentClassificationCommand toStyleWith: WillowCssStyles fadingNotification) asTableRowCommand.
command := [ :tableRow | tableRow addClass fadingNotification ] asTableRowCommand.
html := self
renderUsing: [ :canvas |
| component |

component := canvas tableRow.
command applyTo: component for: 33 on: canvas ].

self
assert: html
equals:
(String
streamContents: [ :stream |
stream
nextPutAll: '<tr class="';
nextPutAll: WillowCssStyles fadingNotification;
nextPutAll: '"></tr>' ])
self assert: html equals: '<tr class="willow-fading-notification"></tr>'
]
52 changes: 22 additions & 30 deletions source/Willow-Tests/WebInteractionInterpreterTest.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Class {
#name : #WebInteractionInterpreterTest,
#superclass : #WARenderingTest,
#category : 'Willow-Tests-WebInteraction'
#pools : [
'Willow'
],
#category : #'Willow-Tests-WebInteraction'
}

{ #category : #'test support' }
Expand All @@ -21,7 +24,7 @@ WebInteractionInterpreterTest >> testAddCssClass [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter addCssClass: WillowCssStyles willow.
interpreter addCssClass: Classification >> #willow.
html := self configureTextInputWith: interpreter.
self
assert: html
Expand All @@ -34,7 +37,7 @@ WebInteractionInterpreterTest >> testAddCssClassToComponentsMatching [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter addCssClass: WillowCssStyles willow toComponentsMatching: [ :canvas | canvas jQuery class: 'aComponentByStyleName' ].
interpreter addCssClass: Classification >> #willow toComponentsMatching: [ :canvas | canvas jQuery class: 'aComponentByStyleName' ].
html := self configureTextInputWith: interpreter.
self
assert: html
Expand All @@ -48,8 +51,8 @@ WebInteractionInterpreterTest >> testChangeCssClassTo [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter changeCssClass: WillowCssStyles loading to: WillowCssStyles willow.
html := self apply: interpreter toComponentDefinedBy: [ :canvas | canvas textInput class: WillowCssStyles loading ].
interpreter changeCssClass: Classification >> #loading to: Classification >> #willow.
html := self apply: interpreter toComponentDefinedBy: [ :canvas | canvas textInput apply: [ :input | input addClass loading ] ].
self
assert: html
equals:
Expand Down Expand Up @@ -456,7 +459,7 @@ WebInteractionInterpreterTest >> testRemoveCssClassFromComponentsMatching [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter removeCssClass: WillowCssStyles willow fromComponentsMatching: [ :canvas | canvas jQuery class: 'aComponentByStyleName' ].
interpreter removeCssClass: Classification >> #willow fromComponentsMatching: [ :canvas | canvas jQuery class: 'aComponentByStyleName' ].
html := self configureTextInputWith: interpreter.
self
assert: html
Expand All @@ -470,17 +473,11 @@ WebInteractionInterpreterTest >> testRemoveCssClassFromComponentsWithClass [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter removeCssClass: WillowCssStyles loading fromComponentsWithClass: WillowCssStyles willow.
html := self
apply: interpreter
toComponentDefinedBy: [ :canvas |
canvas textInput
class: WillowCssStyles loading;
class: WillowCssStyles willow ].
interpreter removeCssClass: Classification >> #loading fromComponentsWithClass: Classification >> #willow.
html := self apply: interpreter toComponentDefinedBy: [ :canvas | canvas textInput apply: [ :input | input addClass loading + input addClass willow ] ].
self
assert: html
equals:
'<input class="willow-loading willow" id="input-id1" type="text"/><script type="text/javascript">$("#input-id1").click(function(event){$(".willow").removeClass("willow-loading")});</script>'
equals: '<input class="willow-loading willow" id="input-id1" type="text"/><script type="text/javascript">$("#input-id1").click(function(event){$(".willow").removeClass("willow-loading")});</script>'
]

{ #category : #'tests - Configuring - DOM' }
Expand Down Expand Up @@ -787,19 +784,17 @@ WebInteractionInterpreterTest >> testSubmitFormStyledAs [

html := self
renderUsing: [ :canvas |
| form anchor |
| anchor |

form := canvas form.
form class: WillowCssStyles willow.
canvas form apply: [ :form | form addClass willow ].
anchor := canvas anchor.
anchor id: '16'.
interpreter submitFormStyledAs: WillowCssStyles willow.
interpreter applyTo: anchor on: canvas ].
interpreter submitFormStyledAs: Classification >> #willow.
anchor interactUsing: interpreter ].

self
assert: html
equals:
'<form accept-charset="utf-8" method="post" action="/" class="willow"></form><a id="16"></a><script type="text/javascript">$("#16").click(function(event){Willow.callServer({"url":"/","data":"1"})});</script>'
equals: '<form accept-charset="utf-8" method="post" action="/" class="willow"></form><a id="16"></a><script type="text/javascript">$("#16").click(function(event){Willow.callServer({"url":"/","data":"1"})});</script>'
]

{ #category : #'tests - Configuring - DOM' }
Expand Down Expand Up @@ -852,12 +847,9 @@ WebInteractionInterpreterTest >> testToggleCssClass [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter toggleCssClass: WillowCssStyles loading.
html := self apply: interpreter toComponentDefinedBy: [ :canvas | canvas textInput class: WillowCssStyles loading ].
self
assert: html
equals:
'<input class="willow-loading" id="input-id1" type="text"/><script type="text/javascript">$("#input-id1").click(function(event){$(this).toggleClass("willow-loading")});</script>'
interpreter toggleCssClass: Classification >> #loading.
html := self apply: interpreter toComponentDefinedBy: [ :canvas | canvas textInput apply: [ :input | input addClass loading ] ].
self assert: html equals: '<input class="willow-loading" id="input-id1" type="text"/><script type="text/javascript">$("#input-id1").click(function(event){$(this).toggleClass("willow-loading")});</script>'
]

{ #category : #'tests - Configuring - CSS' }
Expand All @@ -866,7 +858,7 @@ WebInteractionInterpreterTest >> testToggleCssClassOn [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter toggleCssClass: WillowCssStyles willow on: (IdentifiedWebView forDivNamed: 'example' containing: [ ]).
interpreter toggleCssClass: Classification >> #willow on: (IdentifiedWebView forDivNamed: 'example' containing: [ ]).
html := self configureTextInputWith: interpreter.
self
assert: html
Expand All @@ -880,7 +872,7 @@ WebInteractionInterpreterTest >> testToggleCssClassOnComponentsMatching [
| interpreter html |

interpreter := WebInteractionInterpreter forClickOnComponent.
interpreter toggleCssClass: WillowCssStyles willow onComponentsMatching: [ :canvas | canvas jQuery class: 'aComponentByStyleName' ].
interpreter toggleCssClass: Classification >> #willow onComponentsMatching: [ :canvas | canvas jQuery class: 'aComponentByStyleName' ].
html := self configureTextInputWith: interpreter.
self
assert: html
Expand Down
7 changes: 3 additions & 4 deletions source/Willow-Tests/WillowConstantsProviderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WillowConstantsProviderTest >> testBlockExtension [
| html |

html := self
apply: [ :anchor :constants | anchor addScript js: [ :canvas | canvas jQuery this onClick: (canvas jQuery id: constants willow dialogSectionName) clone ] ] asWebComponentCommand
apply: [ :anchor :constants | anchor addScript js: [ :canvas | canvas jQuery this onClick: (canvas jQuery id: constants >> #willow >> #dialogSectionName) clone ] ] asWebComponentCommand
toComponentDefinedBy: [ :canvas | canvas anchor ].

self assert: html equals: '<a id="id1"></a><script type="text/javascript">$("#id1").click(function(){$("#willow-dialog-section").clone()});</script>'
Expand All @@ -24,7 +24,6 @@ WillowConstantsProviderTest >> testCssConstants [

[ :command :constants |
self
assert: constants css inherit equals: CssConstants inherit;
assert: constants cssFonts allPetiteCaps equals: CssFontConstants allPetiteCaps;
assert: constants cssMediaQuery landscape equals: CssMediaQueryConstants landscape ] asWebComponentCommand
assert: constants >> #css >> #inherit equals: 'inherit';
assert: constants >> #css >> #allPetiteCaps equals: 'all-petite-caps' ] asWebComponentCommand
]
12 changes: 12 additions & 0 deletions source/Willow-Tests/WillowJavascriptNamespaceTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ WillowJavascriptNamespaceTest >> testCallServerFunction [
equals: 'Willow.callServer'
]

{ #category : #'tests-printing' }
WillowJavascriptNamespaceTest >> testClassificationAccess [

self assert: Willow classification >> #loading equals: 'willow-loading'
]

{ #category : #'tests-printing' }
WillowJavascriptNamespaceTest >> testConstantsAccess [

self assert: WillowJavascriptNamespace new constants >> #css >> #auto equals: 'auto'
]

{ #category : #'tests-Accessing' }
WillowJavascriptNamespaceTest >> testHandleAjaxErrorCallFunction [

Expand Down
7 changes: 3 additions & 4 deletions source/Willow/AsynchronicButtonWebView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ AsynchronicButtonWebView >> renderContentOn: aCanvas [
identifierAssigner withAssignedIdentifierDo: [ :id | pushButton id: id ].
pushButton
value: label;
bePush.

interactionInterpreter applyTo: pushButton on: aCanvas.
commandToComponent applyTo: pushButton on: aCanvas
bePush;
interactUsing: interactionInterpreter;
apply: commandToComponent
]
2 changes: 1 addition & 1 deletion source/Willow/BlockClosure.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ BlockClosure >> asTableRowCommand [
{ #category : #'*Willow' }
BlockClosure >> asWebComponentCommand [

^ (self cull: WebComponentCommandBuilder new cull: WillowConstantsProvider new) ifNil: [ CompositeComponentCommand empty ]
^ (self cull: WebComponentCommandBuilder new cull: Willow constants) ifNil: [ CompositeComponentCommand empty ]
]
Loading

0 comments on commit 4ab95e9

Please sign in to comment.