From 9a4046ddb95462b7c27f214d966d56177dd751e5 Mon Sep 17 00:00:00 2001 From: Tim Berners-Lee Date: Thu, 15 Aug 2019 17:35:52 +0200 Subject: [PATCH] Do not prefill a value for a checkbox If the BooleanField in the given resource is not set, the tristate logic would set it to false by default. This commit changes that to differentiate between the value that is shown (false), and the value that's actually present on the web. --- src/widgets/forms.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/widgets/forms.js b/src/widgets/forms.js index 81cdb80c8..f42841235 100644 --- a/src/widgets/forms.js +++ b/src/widgets/forms.js @@ -1202,20 +1202,22 @@ function buildCheckboxForm (dom, kb, lab, del, ins, form, store, tristate) { // } function refresh () { var state = holdsAll(ins) + var displayState = state if (del.length) { var negation = holdsAll(del) if (state && negation) { - box.appendChild(error.errorMessageBlock(dom, + box.appendChild(UI.widgets.errorMessageBlock(dom, 'Inconsistent data in store!\n' + ins + ' and\n' + del)) return box } if (!state && !negation) { + state = null let defa = kb.any(form, UI.ns.ui('default')) - state = defa ? defa.value === '1' : tristate ? null : false + displayState = defa ? defa.value === '1' : tristate ? null : false } } input.state = state - input.textContent = {true: checkMarkCharacter, false: cancelCharacter, null: dashCharacter}[input.state] + input.textContent = {true: checkMarkCharacter, false: cancelCharacter, null: dashCharacter}[displayState] } refresh()