HTML RadioButton widget #567

Closed
wants to merge 3 commits into
from

2 participants

@MatthieuDadou

the Radio button HTML widget.
3 properties:
-'name': Radio buttons with the same name will be in the same radio group.
-'value': representing the data behing the widget
bindable property: 'selecteValue', representing the radioButton to select.

@MatthieuDadou MatthieuDadou feat #567 @html:RadioButton
The Radio button HTML widget with 3 properties
-'name': Radio buttons with the same name will be in the same radio group.
-'value': representing the data behing the widget
bindable property: 'selectedValue', representing the radioButton to select.

US 1984. Close #567.
60917c2
@jakub-g jakub-g commented on an outdated diff Jun 18, 2013
src/aria/html/RadioButton.js
+ var bind = this._bindingListeners.selectedValue;
+ var newValue = this._transform(bind.transform, this._cfg.value, "fromWidget");
+ aria.utils.Json.setValue(bind.inside, bind.to, newValue, bind.cb);
+ }
+
+ /**
+ * RadioButton widget. Bindable widget providing bi-directional bind of 'selectedValue'.
+ */
+ Aria.classDefinition({
+ $classpath : "aria.html.RadioButton",
+ $extends : "aria.html.Element",
+ $dependencies : ["aria.html.beans.RadioButtonCfg"],
+ $statics : {
+ INVALID_USAGE : "Widget %1 can only be used as a %2.",
+ BINDING_NEEDED : "the property 'selectedValue' from Widget %1 should be bound to a data model"
+ },
@jakub-g
jakub-g added a line comment Jun 18, 2013

I think it could make sense to introduce more inheritance here by creating abstract aria.html.InputElement and moving some of the shared things between TextInput, CheckBox and RadioButton. E.g. the statics could be moved there, writeMarkupBegin, writeMarkupEnd and those lines from the constructor which are the same everywhere:

        cfg.tagName = "input";
        cfg.attributes = cfg.attributes || {};
        cfg.on = cfg.on || {}; 

This could be done as a separate refactor commit on top of this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jakub-g jakub-g commented on an outdated diff Jun 18, 2013
src/aria/html/RadioButton.js
+ */
+ writeMarkupEnd : Aria.empty,
+
+ /**
+ * Initialization method called after the markup of the widget has been inserted in the DOM.
+ */
+ initWidget : function () {
+ this.$Element.initWidget.call(this);
+
+ var bindings = this._cfg.bind;
+ var binding = bindings.selectedValue;
+ if (binding) {
+ var newValue = this._transform(binding.transform, binding.inside[binding.to], "toWidget");
+ this._domElt.checked = (newValue === this._cfg.value);
+ } else {
+ this.$logWarn(this.BINDING_NEEDED, [this.$class]);
@jakub-g
jakub-g added a line comment Jun 18, 2013

It'll be good to add the same logic when no binding defined to the other two @html widgets, i.e. TextInput and CheckBox to be consistent. The property name in this.BINDING_NEEDED which now is hardcoded, should be changed to %2, and passed as the second parameter in this line.
It makes sense to raise this warning, as providing the bindings is the main reason why the html widget lib was created, so if they're not defined, it's likely a developer's mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@MatthieuDadou

refactored as suggested by Jakub

@MatthieuDadou MatthieuDadou feat #551 Allowing any type in the @html:TextInput widget
leaving it backward compatible , if the password property is set to true,
then  the attribute will still be type: "password",
but it won't be input:text if password is not defined or set to false

Close #551
361db41
@jakub-g

Looks good for me now (all the 3 commits).
Note that RadioButton is added to the HtmlLibrary in the second commit (it should be a part of the first one, but it's not a big deal).

@piuccio Would you like to review & integrate this?

@MatthieuDadou MatthieuDadou added a commit to MatthieuDadou/ariatemplates that referenced this pull request Jun 21, 2013
@MatthieuDadou MatthieuDadou feat #567 @html:RadioButton
The Radio button HTML widget with 3 properties
-'name': Radio buttons with the same name will be in the same radio group.
-'value': representing the data behing the widget
bindable property: 'selectedValue', representing the radioButton to select.

US 1984. Close #567.
d043299
@piuccio piuccio added a commit that referenced this pull request Jun 21, 2013
@MatthieuDadou MatthieuDadou feat #567 @html:RadioButton
The Radio button HTML widget with 3 properties
-'name': Radio buttons with the same name will be in the same radio group.
-'value': representing the data behing the widget
bindable property: 'selectedValue', representing the radioButton to select.

US 1984. Close #567.
54b2597
@piuccio piuccio added a commit that closed this pull request Jun 21, 2013
@MatthieuDadou MatthieuDadou feat #567 @html:RadioButton
The Radio button HTML widget with 3 properties
-'name': Radio buttons with the same name will be in the same radio group.
-'value': representing the data behing the widget
bindable property: 'selectedValue', representing the radioButton to select.

US 1984. Close #567.
54b2597
@piuccio piuccio closed this in 54b2597 Jun 21, 2013
@piuccio piuccio referenced this pull request Jun 21, 2013
Closed

Html select widget #574

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment