You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2013/06/12 21:15:07 UTC
[4/4] git commit: Pass the selected options, not the values,
in the Palette willChange/didChange event memo
Pass the selected options, not the values, in the Palette willChange/didChange event memo
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/f40f4f7e
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/f40f4f7e
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/f40f4f7e
Branch: refs/heads/master
Commit: f40f4f7eb29e9c6b9e6197893a7e39bfef6e5dcb
Parents: d30479a
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Jun 11 12:11:47 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Jun 11 12:11:47 2013 -0700
----------------------------------------------------------------------
.../META-INF/modules/t5/core/events.coffee | 26 +++++++++++---------
.../META-INF/modules/t5/core/palette.coffee | 9 +++----
tapestry-core/src/test/app1/PaletteDemo.tml | 2 ++
.../META-INF/modules/palette-demo.coffee | 10 +++++---
4 files changed, 28 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f40f4f7e/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
index 8d0efd3..5c9d9c8 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
@@ -126,15 +126,19 @@ define
# Events triggered by the Palette component.
palette:
- # Event triggered when the selection is about to change. The memo object has these properties:
- # * selectedValues - list of selected values (if change is allowed)
- # * reorder - if true, then the event represents changing the ordrer of the selections only
- # * cancel - function to invoke to prevent the change to the Palette from occurring
- # * defer - like cancel, but returns a no-arguments function that will perform the update at a later date (e.g.,
+ # Event triggered when the selection is about to change.
+ #
+ # * memo.selectedOptions - array of selected options (e.g., HTMLOptionElement) representing which options
+ # will be selected in the Palette, should the change be allowed.
+ # * memo.reorder - if true, then the event represents changing the order of the selections only
+ # * memo.cancel - function to invoke to prevent the change to the Palette from occurring
+ # * memo.defer - like cancel, but returns a no-arguments function that will perform the update at a later date (e.g.,
# after a confirmation panel)
willChange: "t5:palette:willChange"
- # Event triggered after the selection has changed. The memo object has one property:
- # * selectedValues - list of selected values
+ # Event triggered after the Palette selection has changed.
+ #
+ # * memo.selectedOptions - array of selected options (e.g., HTMLOptionElement)
+ # * memo.reorder - if true, the event represents a change in the order of selections only
didChange: "t5:palette:didChange"
# Defines a number of event names specific to Tapestry Zones. Zones are Tapestry components that are structured
@@ -148,12 +152,12 @@ define
# content.
update: "t5:zone:update"
- # Triggered (by the standard handler) just before the content in a Zone will be updated.
+ # Triggered (by the standard `events.zone.update` event handler) just before the content in a Zone will be updated.
willUpdate: "t5:zone:will-update"
- # Triggered (by the standard handler) just after the content in a Zone has updated. If the zone was not visible, it
- # is made visible after its content is changed, and before this event is triggered. Some number of other components that
- # also perform Ajax updates of the page also trigger this event.
+ # Triggered (by the standard `events.zone.update` event handle) just after the content in a Zone has updated.
+ # If the zone was not visible, it is made visible after its content is changed, and before this event is triggered.
+ # Some number of other components that also perform Ajax updates of the page also trigger this event.
#
# Certain components bind this event to scan new additions to the page to see if certain structures exist and
# create client-side support in the form of controllers and event handlers. DateField is one such example
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f40f4f7e/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
index 5c112f3..b578dfb 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
@@ -184,21 +184,20 @@ define ["./dom", "underscore", "./events"],
@selected.element.add o, null
# Performs the update, which includes the willChange and didChange events.
- performUpdate: (isReorder, selectedOptions, updateCallback) ->
+ performUpdate: (reorder, selectedOptions, updateCallback) ->
canceled = false
- selectedValues = _.pluck selectedOptions, "value"
doUpdate = =>
updateCallback()
- @selected.trigger events.palette.didChange, { selectedValues }
+ @selected.trigger events.palette.didChange, { selectedOptions, reorder }
@updateAfterChange()
memo =
- selectedValues: selectedValues
- reorder: isReorder
+ selectedOptions: selectedOptions
+ reorder: reorder
cancel: -> canceled = true
defer: ->
canceled = true
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f40f4f7e/tapestry-core/src/test/app1/PaletteDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/PaletteDemo.tml b/tapestry-core/src/test/app1/PaletteDemo.tml
index 7e516ce..4d06d78 100644
--- a/tapestry-core/src/test/app1/PaletteDemo.tml
+++ b/tapestry-core/src/test/app1/PaletteDemo.tml
@@ -44,6 +44,8 @@
<dd id="selected-languages">${languages}</dd>
<dt>Selected Values</dt>
<dd id="event-selection"/>
+ <dt>Reorder</dt>
+ <dd id="event-reorder"></dd>
</dl>
</html>
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f40f4f7e/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.coffee b/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.coffee
index 226e062..d75c9ba 100644
--- a/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.coffee
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.coffee
@@ -1,5 +1,9 @@
-define ["t5/core/dom", "t5/core/events"],
- (dom, events) ->
+define ["t5/core/dom", "t5/core/events", "underscore"],
+ (dom, events, _) ->
dom.onDocument events.palette.willChange, (event, memo) ->
- (dom "event-selection").update JSON.stringify memo.selectedValues
\ No newline at end of file
+
+ values = _.map memo.selectedOptions, (o) -> o.value
+
+ (dom "event-selection").update JSON.stringify values
+ (dom "event-reorder").update memo.reorder.toString()
\ No newline at end of file