N°3649 - Activity panel: Fix wrong elapsed time displayed under entries after a new entry has been added

This commit is contained in:
Molkobain
2021-02-07 17:21:55 +01:00
parent 15c5a22d11
commit 73f6c697b9
2 changed files with 8 additions and 6 deletions

View File

@@ -382,14 +382,13 @@ $(function()
const me = this;
this.element.find(this.js_selectors.entry_datetime).each(function(){
const oEntryDateTime = moment($(this).text(), me.options.datetime_format);
const oEntryDateTime = moment($(this).attr('data-formatted-datetime'), me.options.datetime_format);
const oNowDateTime = moment();
// Reformat date time only if it is not too far in the past (eg. "2 years ago" is not easy to interpret)
const fDays = moment.duration(oNowDateTime.diff(oEntryDateTime)).asDays();
if(fDays < me.options.datetimes_reformat_limit)
{
$(this).text( moment($(this).text(), me.options.datetime_format).fromNow() );
if (fDays < me.options.datetimes_reformat_limit) {
$(this).text(moment($(this).attr('data-formatted-datetime'), me.options.datetime_format).fromNow());
}
});
},

View File

@@ -32,8 +32,11 @@
</div>
<div class="ibo-activity-entry--sub-information" data-role="ibo-activity-entry--sub-information">
{% block iboActivityEntrySubInformation %}
<span class="ibo-activity-entry--datetime" data-role="ibo-activity-entry--datetime" data-tooltip-content="{{ oUIBlock.GetFormattedDateTime() }}">{{ oUIBlock.GetFormattedDateTime() }}</span>
{% endblock %}
<span class="ibo-activity-entry--datetime" data-role="ibo-activity-entry--datetime"
data-tooltip-content="{{ oUIBlock.GetFormattedDateTime() }}"
data-raw-datetime="{{ oUIBlock.GetRawDateTime() }}"
data-formatted-datetime="{{ oUIBlock.GetFormattedDateTime() }}">{{ oUIBlock.GetFormattedDateTime() }}</span>
{% endblock %}
</div>
{% endblock %}
</div>