-
Notifications
You must be signed in to change notification settings - Fork 950
Default values for widget model attributes #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default values for widget model attributes #304
Conversation
From the sample you have here, I think this is great. |
Test failures seem unrelated. |
}); | ||
|
||
var CheckboxModel = BoolModel.extend({ | ||
defaults: _.extend(BoolModel.prototype.defaults, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the line that is causing the tests to fail. You need to import underscore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank the new karma tests ;)
They are related, missing import, see above |
c2a0a0e
to
f5e3648
Compare
Thanks. I will iterate on this PR to cover the other models. |
|
5b5cff5
to
dcb2d24
Compare
Sure |
Ping @lbustelo |
5251eba
to
ec80035
Compare
2e1c78c
to
7e01697
Compare
Done |
I have to figure out how to define a default for the instance of layout widget from the js, the default being to instantiate a new one... |
Great work so far! Looking forward to this one |
02e636e
to
39cbdf3
Compare
c5ca4e7
to
29aa633
Compare
6b70dc4
to
2a422ec
Compare
I would love to have your opinion on the |
The issue was that the state from I just changed the code in the following fashion: only buffer state diff after the initial state has been set. |
var DOMWidgetModel = WidgetModel.extend({}, { | ||
var DOMWidgetModel = WidgetModel.extend({ | ||
defaults: _.extend({}, WidgetModel.prototype.defaults, { | ||
layout: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to be null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I don't know. We don't allow None
for the layout widget.
In fact, even when building it from JavaScript, we should instantiate a layout widget. Not sure what is the best way to do it. That is why I used undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's okay for now, note to self: test edge cases of this.
@SylvainCorlay one small comment |
508fa4d
to
f50cd48
Compare
Default values for widget model attributes
@jdfreder @parente here is the approach I am proposing for specifying default values for widget attributes on the javascript side.
I started with the base widget classes and the
_Bool
widgets.TODO:
This is an API change from the perspective of custom widget authors who need custom models.