- Fix doubled format string in readonly duration

- Fix format displayed when duration is 0
This commit is contained in:
nathangray 2020-02-10 15:32:31 -07:00
parent b5af403238
commit 4ef2b0b401
2 changed files with 16 additions and 15 deletions

View File

@ -675,7 +675,7 @@ var et2_date_duration = /** @class */ (function (_super) {
};
et2_date_duration.prototype.set_value = function (_value) {
this.options.value = _value;
var display = this._convert_to_display(_value);
var display = this._convert_to_display(parseFloat(_value));
// Set display
if (this.duration[0].nodeName == "INPUT") {
this.duration.val(display.value);
@ -693,29 +693,26 @@ var et2_date_duration = /** @class */ (function (_super) {
}
}
};
et2_date_duration.prototype.set_display_format = function (format)
{
if (format.length <= 1)
{
et2_date_duration.prototype.set_display_format = function (format) {
if (format.length <= 1) {
this.node.remove('select.et2_date_duration');
}
this.options.display_format = format;
if (this.options.display_format.length > 1)
{
if (this.format) {
this.format.remove();
}
if (this.options.display_format.length > 1 && !this.options.readonly) {
this.format = jQuery(document.createElement("select"))
.addClass('et2_date_duration');
this.node.append(this.format);
for (var i = 0; i < this.options.display_format.length; i++)
{
for (var i = 0; i < this.options.display_format.length; i++) {
this.format.append("<option value='" + this.options.display_format[i] + "'>" + this.time_formats[this.options.display_format[i]] + "</option>");
}
}
else if (this.time_formats[this.options.display_format])
{
else if (this.time_formats[this.options.display_format]) {
this.format = jQuery("<span>" + this.time_formats[this.options.display_format] + "</span>").appendTo(this.node);
}
else
{
else {
this.format = jQuery("<span>" + this.time_formats["m"] + "</span>").appendTo(this.node);
}
};

View File

@ -832,7 +832,7 @@ export class et2_date_duration extends et2_date
{
this.options.value = _value;
var display = this._convert_to_display(_value);
var display = this._convert_to_display(parseFloat(_value));
// Set display
if(this.duration[0].nodeName == "INPUT")
@ -864,7 +864,11 @@ export class et2_date_duration extends et2_date
this.node.remove('select.et2_date_duration');
}
this.options.display_format = format;
if(this.options.display_format.length > 1)
if(this.format)
{
this.format.remove();
}
if(this.options.display_format.length > 1 && !this.options.readonly)
{
this.format = jQuery(document.createElement("select"))
.addClass('et2_date_duration');