fix not working onchange on all inputs of date-duration select_unit="false"

This commit is contained in:
Ralf Becker 2021-02-09 15:51:10 +02:00
parent b234694d58
commit df2a426e08
2 changed files with 30 additions and 20 deletions

View File

@ -665,21 +665,25 @@ var et2_date_duration = /** @class */ (function (_super) {
et2_date_duration.prototype.isValid = function (_messages) { et2_date_duration.prototype.isValid = function (_messages) {
var ok = true; var ok = true;
// if we have a html5 validation error, show it, as this.input.val() will be empty! // if we have a html5 validation error, show it, as this.input.val() will be empty!
if (this.duration && this.duration[0] && for (var i = 0; this.duration && i < this.duration.length; ++i) {
this.duration[0].validationMessage && if (this.duration[i] &&
!this.duration[0].validity.stepMismatch) { this.duration[i].validationMessage &&
_messages.push(this.duration[0].validationMessage); !this.duration[i].validity.stepMismatch) {
_messages.push(this.duration[i].validationMessage);
ok = false; ok = false;
} }
}
return _super.prototype.isValid.call(this, _messages) && ok; return _super.prototype.isValid.call(this, _messages) && ok;
}; };
et2_date_duration.prototype.attachToDOM = function () { et2_date_duration.prototype.attachToDOM = function () {
var node = this.getInputNode(); if (this.duration) {
if (node) { for (var i = 0; i < this.duration.length; ++i) {
var node = this.duration[i];
jQuery(node).bind("change.et2_inputWidget", this, function (e) { jQuery(node).bind("change.et2_inputWidget", this, function (e) {
e.data.change(this); e.data.change(this);
}); });
} }
}
return et2_core_DOMWidget_1.et2_DOMWidget.prototype.attachToDOM.apply(this, arguments); return et2_core_DOMWidget_1.et2_DOMWidget.prototype.attachToDOM.apply(this, arguments);
}; };
et2_date_duration.prototype.getDOMNode = function () { et2_date_duration.prototype.getDOMNode = function () {

View File

@ -813,25 +813,31 @@ export class et2_date_duration extends et2_date
{ {
var ok = true; var ok = true;
// if we have a html5 validation error, show it, as this.input.val() will be empty! // if we have a html5 validation error, show it, as this.input.val() will be empty!
if (this.duration && this.duration[0] && for(let i=0; this.duration && i < this.duration.length; ++i)
(<HTMLInputElement>this.duration[0]).validationMessage &&
!(<HTMLInputElement>this.duration[0]).validity.stepMismatch)
{ {
_messages.push((<HTMLInputElement>this.duration[0]).validationMessage); if (this.duration[i] &&
(<HTMLInputElement>this.duration[i]).validationMessage &&
!(<HTMLInputElement>this.duration[i]).validity.stepMismatch)
{
_messages.push((<HTMLInputElement>this.duration[i]).validationMessage);
ok = false; ok = false;
} }
}
return super.isValid(_messages) && ok; return super.isValid(_messages) && ok;
} }
attachToDOM() attachToDOM()
{ {
var node = this.getInputNode(); if (this.duration)
if (node)
{ {
for(let i=0; i < this.duration.length; ++i)
{
let node = this.duration[i];
jQuery(node).bind("change.et2_inputWidget", this, function(e) { jQuery(node).bind("change.et2_inputWidget", this, function(e) {
e.data.change(this); e.data.change(this);
}); });
} }
}
return et2_DOMWidget.prototype.attachToDOM.apply(this, arguments); return et2_DOMWidget.prototype.attachToDOM.apply(this, arguments);
} }