fix date-duration fails with only one date-format eg. "m"

This commit is contained in:
Ralf Becker 2020-09-11 20:22:34 +02:00
parent d257077017
commit 638da52fa9
3 changed files with 7 additions and 4 deletions

View File

@ -683,7 +683,7 @@ var et2_date_duration = /** @class */ (function (_super) {
this.duration.text(display.value + " ");
}
// Set unit as figured for display
if (display.unit != this.options.display_format) {
if (display.unit && display.unit != this.options.display_format) {
if (this.format && this.format.children().length > 1) {
jQuery("option[value='" + display.unit + "']", this.format).attr('selected', 'selected');
}
@ -693,7 +693,7 @@ var et2_date_duration = /** @class */ (function (_super) {
}
};
et2_date_duration.prototype.set_display_format = function (format) {
if (format.length <= 1) {
if (format.length < 1) {
this.node.remove('select.et2_date_duration');
this.format.remove();
this.format = null;

View File

@ -844,7 +844,7 @@ export class et2_date_duration extends et2_date
}
// Set unit as figured for display
if(display.unit != this.options.display_format)
if(display.unit && display.unit != this.options.display_format)
{
if(this.format && this.format.children().length > 1) {
jQuery("option[value='"+display.unit+"']",this.format).attr('selected','selected');
@ -858,7 +858,7 @@ export class et2_date_duration extends et2_date
set_display_format(format)
{
if (format.length <= 1)
if (format.length < 1)
{
this.node.remove('select.et2_date_duration');
this.format.remove();

View File

@ -524,6 +524,9 @@ span.et2_date span {
span.et2_date_duration input.et2_date_duration{
width: 25%;
}
span.et2_date_duration span {
vertical-align: -webkit-baseline-middle;
}
.et2_date.required, .et2_date[required] {
background-color: inherit;
}