Fix some readonly / readOnly bugs that snuck in when textbox was converted from Lion to Shoelace

This commit is contained in:
nathan 2022-07-26 13:56:17 -06:00
parent 5b76c8b16d
commit 17012f6f25
5 changed files with 16 additions and 9 deletions

View File

@ -457,7 +457,7 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
getValue() getValue()
{ {
if(this.readOnly || this.disabled) if(this.readonly || this.disabled)
{ {
return null; return null;
} }

View File

@ -57,7 +57,7 @@ describe("Date widget", () =>
element.set_value("0"); element.set_value("0");
// wait for asychronous changes to the DOM // wait for asychronous changes to the DOM
await elementUpdated(element); await elementUpdated(element);
assert.equal(element.querySelector("input").value, ""); assert.equal(element.querySelector("et2-textbox").value, "");
assert.equal(element.get_value(), ''); assert.equal(element.get_value(), '');
}); });
@ -108,4 +108,4 @@ describe("Date widget", () =>
}); });
} }
}); });
inputBasicTests(before, "2008-09-22T00:00:00Z", "input"); inputBasicTests(before, "2008-09-22T00:00:00Z", "et2-textbox");

View File

@ -63,7 +63,7 @@ describe("DateTime widget", () =>
it('No value shows no value', () => it('No value shows no value', () =>
{ {
assert.equal(element.querySelector("input").textContent, ""); assert.equal(element.querySelector("et2-textbox").textContent, "");
assert.equal(element.get_value(), ""); assert.equal(element.get_value(), "");
}); });
@ -72,7 +72,7 @@ describe("DateTime widget", () =>
element.set_value("0"); element.set_value("0");
// wait for asychronous changes to the DOM // wait for asychronous changes to the DOM
await elementUpdated(element); await elementUpdated(element);
assert.equal(element.querySelector("input").value, ""); assert.equal(element.querySelector("et2-textbox").value, "");
assert.equal(element.get_value(), ""); assert.equal(element.get_value(), "");
}); });

View File

@ -137,6 +137,8 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
this.validators = []; this.validators = [];
this.defaultValidators = []; this.defaultValidators = [];
this.__readonly = false;
} }
connectedCallback() connectedCallback()
@ -235,18 +237,23 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
set readOnly(new_value) {this.readonly = new_value;} set readOnly(new_value) {this.readonly = new_value;}
get readOnly() { return this.readonly}; /**
* Lion mapping
* @deprecated
*/
get readOnly()
{ return this.readonly};
getValue() getValue()
{ {
return this.readOnly || this.disabled ? null : this.value; return this.readonly || this.disabled ? null : this.value;
} }
isDirty() isDirty()
{ {
// Readonly can't be dirty, it can't change // Readonly can't be dirty, it can't change
if(this.readOnly) if(this.readonly)
{ {
return false; return false;
} }

View File

@ -41,7 +41,7 @@ export function inputBasicTests(before : Function, test_value : string, value_se
it("does not return a value (via attribute)", async() => it("does not return a value (via attribute)", async() =>
{ {
element.readOnly = true; element.readonly = true;
element.set_value(test_value); element.set_value(test_value);