forked from extern/egroupware
Fix some Et2DateDuration bugs
- Duration did not validate correctly - Validation errors were not actually shown - Empty duration ('') did not work consistently
This commit is contained in:
parent
a847f25408
commit
cfbb74b83e
@ -290,7 +290,7 @@ export class Et2DateDuration extends Et2InputWidget(FormControlMixin(LitElement)
|
||||
}
|
||||
|
||||
let val = this._durationNode.length ? this._durationNode[0].value : '';
|
||||
if(val === '')
|
||||
if(val === '' || isNaN(val))
|
||||
{
|
||||
return this.emptyNot0 ? '' : "0";
|
||||
}
|
||||
@ -496,7 +496,7 @@ export class Et2DateDuration extends Et2InputWidget(FormControlMixin(LitElement)
|
||||
let input = {
|
||||
name: "",
|
||||
title: "",
|
||||
value: value,
|
||||
value: typeof value == "number" ? value : ((this.selectUnit ? value.pop() : value[i]) || ""),
|
||||
min: undefined,
|
||||
max: undefined
|
||||
};
|
||||
|
@ -71,6 +71,9 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
||||
.input-group__container > .input-group__input ::slotted(.form-control) {
|
||||
width: 100%;
|
||||
}
|
||||
.form-field__feedback {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
`
|
||||
];
|
||||
@ -411,13 +414,13 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
||||
let feedback = <LionValidationFeedback>document.createElement("lion-validation-feedback");
|
||||
feedback.feedbackData = feedbackData;
|
||||
feedback.slot = "help-text";
|
||||
this.append(feedback);
|
||||
if(this.shadowRoot.querySelector("slot[name='feedback']"))
|
||||
{
|
||||
feedback.slot = "feedback";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.append(feedback);
|
||||
// Not always visible?
|
||||
(<HTMLElement>this.shadowRoot.querySelector("#help-text")).style.display = "initial";
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ class Date extends Transformer
|
||||
$value = self::get_array($content, $form_name);
|
||||
$valid =& self::get_array($validated, $form_name, true);
|
||||
|
||||
if($value && $this->type !== 'date-duration')
|
||||
if($value && !in_array($this->type, ['et2-date-duration', 'date-duration']))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -193,7 +193,7 @@ class Date extends Transformer
|
||||
{
|
||||
$valid = null;
|
||||
}
|
||||
elseif($this->type == 'date-duration')
|
||||
elseif(in_array($this->type, ['et2-date-duration', 'date-duration']))
|
||||
{
|
||||
$valid = (string)$value === '' ? '' : (int)$value;
|
||||
}
|
||||
@ -256,7 +256,7 @@ class Date extends Transformer
|
||||
$value = $max;
|
||||
}
|
||||
}
|
||||
if($this->type == 'date-duration')
|
||||
if(in_array($this->type, ['et2-date-duration', 'date-duration']))
|
||||
{
|
||||
$valid = (string)$value === '' ? '' : (int)$value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user