Allow indeterminate checkboxes in list and filter modes

This change may require some tweaks to the unit tests to be able to test
it properly.
This commit is contained in:
Robin Munn 2022-03-25 12:30:14 +07:00
parent b4e512760e
commit 6afcb151be
1 changed files with 12 additions and 3 deletions

View File

@ -27,6 +27,7 @@ CheckboxWidget.prototype = new Widget();
Render this widget into the DOM
*/
CheckboxWidget.prototype.render = function(parent,nextSibling) {
var value;
// Save the parent dom node
this.parentDomNode = parent;
// Compute our attributes
@ -38,9 +39,13 @@ CheckboxWidget.prototype.render = function(parent,nextSibling) {
this.labelDomNode.setAttribute("class",this.checkboxClass);
this.inputDomNode = this.document.createElement("input");
this.inputDomNode.setAttribute("type","checkbox");
if(this.getValue()) {
value = this.getValue();
if(value) {
this.inputDomNode.setAttribute("checked","true");
}
if(value === undefined) {
this.inputDomNode.indeterminate = true;
}
if(this.isDisabled === "yes") {
this.inputDomNode.setAttribute("disabled",true);
}
@ -267,9 +272,13 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) {
this.refreshSelf();
return true;
} else {
var refreshed = false;
var refreshed = false, value;
if(changedTiddlers[this.checkboxTitle]) {
this.inputDomNode.checked = this.getValue();
value = this.getValue();
this.inputDomNode.checked = !!value;
if(value === undefined) {
this.inputDomNode.indeterminate = true;
}
refreshed = true;
}
return this.refreshChildren(changedTiddlers) || refreshed;