Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(140)

Issue 10760046: Allow data dependencies in data binding

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 10 months ago by bcsaller
Modified:
10 years, 10 months ago
Reviewers:
jeff.pihach, mp+172661, gary.poster
Visibility:
Public.

Description

Allow data dependencies in data binding Binding elements can indicate they depend on the values of other model fields. An include test shows how this works. In viewlets you can extend the bindings section of its configuration to include 'depends'. A list of model attribute key names on which this fields depends. bindings: { full: { depends: ['first', 'last'] } } In this case we might indicate the computed value 'full' (name) depends on first and last name stored in the model. Full Name would be an attribute with a getter but doesn't fire change events itself to trigger model updates. The attribute definition for 'full' might be as follows: full: { getter: function() {return this.get('first') + ' ' + this.get('last');} } https://code.launchpad.net/~bcsaller/juju-gui/databinding-deps/+merge/172661 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 10

Patch Set 2 : Allow data dependencies in data binding #

Unified diffs Side-by-side diffs Delta from patch set Stats (+118 lines, -10 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M app/views/databinding.js View 1 8 chunks +60 lines, -7 lines 0 comments Download
M test/test_databinding.js View 1 4 chunks +56 lines, -3 lines 0 comments Download

Messages

Total messages: 6
bcsaller
Please take a look.
10 years, 10 months ago (2013-07-02 20:15:46 UTC) #1
jeff.pihach
LGTM - good work! I'd like to see one extra assertion as mentioned in the ...
10 years, 10 months ago (2013-07-02 20:39:10 UTC) #2
benjamin.saller
Thanks for the review, correctly locally as they are minors. https://codereview.appspot.com/10760046/diff/1/test/test_databinding.js File test/test_databinding.js (right): https://codereview.appspot.com/10760046/diff/1/test/test_databinding.js#newcode281 ...
10 years, 10 months ago (2013-07-02 21:26:49 UTC) #3
gary.poster
LGTM with trivials. Thank you! Gary https://codereview.appspot.com/10760046/diff/1/app/views/databinding.js File app/views/databinding.js (right): https://codereview.appspot.com/10760046/diff/1/app/views/databinding.js#newcode69 app/views/databinding.js:69: // XXX: Too ...
10 years, 10 months ago (2013-07-02 22:13:54 UTC) #4
benjamin.saller
Thanks for the reviews https://codereview.appspot.com/10760046/diff/1/app/views/databinding.js File app/views/databinding.js (right): https://codereview.appspot.com/10760046/diff/1/app/views/databinding.js#newcode69 app/views/databinding.js:69: // XXX: Too many copies, ...
10 years, 10 months ago (2013-07-02 22:18:45 UTC) #5
bcsaller
10 years, 10 months ago (2013-07-02 22:24:37 UTC) #6
*** Submitted:

Allow data dependencies in data binding

Binding elements can indicate they depend on the values of 
other model fields. An include test shows how this works.

In viewlets you can extend the bindings section of its configuration
to include 'depends'. A list of model attribute key names on which
this fields depends.

bindings: {
  full: {
     depends: ['first', 'last']
		}
}

In this case we might indicate the computed value 'full' (name)
depends on first and last name stored in the model. Full Name
would be an attribute with a getter but doesn't fire change events
itself to trigger model updates. The attribute definition for 'full'
might be as follows:

 full: {
   getter: function() {return this.get('first') +
              ' '  + this.get('last');}
 }

R=jeff.pihach, benjamin.saller, gary.poster
CC=
https://codereview.appspot.com/10760046
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b