Et2DateDuration: Enforce the order of display to be greatest to least

For example hours:days is not allowed anymore, auto-corrected to days:hours
This commit is contained in:
nathan 2022-03-29 11:00:09 -06:00
parent 22c8d8808f
commit c12d4cebfb

View File

@ -338,6 +338,30 @@ export class Et2DateDuration extends Et2InputWidget(FormControlMixin(LitElement)
this.requestUpdate();
}
/**
* Set the format for displaying the duration
*
* @param {string} value
*/
set display_format(value : string)
{
this.__display_format = "";
// Display format must be in decreasing size order (dhms) or the calculations
// don't work out nicely
for(let f of Object.keys(Et2DateDuration.time_formats))
{
if(value.indexOf(f) !== -1)
{
this.__display_format += f;
}
}
}
get display_format()
{
return this.__display_format;
}
/**
* @return {TemplateResult}
* @protected