Fix duration in infolog list

This commit is contained in:
nathan 2022-03-03 14:14:26 -07:00
parent aff71549a2
commit 1893a2c7fe
3 changed files with 29 additions and 16 deletions

View File

@ -263,11 +263,17 @@ export class Et2DateDuration extends Et2InputWidget(FormControlMixin(LitElement)
transformAttributes(attrs) transformAttributes(attrs)
{ {
// Clean formats // Clean formats, but avoid things that need to be expanded like $cont[display_format]
if(typeof attrs.display_format === 'string') const check = new RegExp('[\$\@' + Object.keys(Et2DateDuration.time_formats).join('') + ']');
for(let attr in ["display_format", "data_format"])
{ {
attrs.display_format = attrs.display_format.replace(/[^dhms]/g, ''); if(typeof attrs[attrs] === 'string' && !check.test(attrs[attr]))
{
console.warn("Invalid format for " + attr + "'" + attrs[attr] + "'", this);
attrs[attr] = attrs[attr].replace(/[^dhms]/g, '');
}
} }
super.transformAttributes(attrs); super.transformAttributes(attrs);
} }

View File

@ -55,7 +55,7 @@ class infolog_ui
* *
* @var string * @var string
*/ */
var $duration_format = ','; // comma is necessary! var $duration_format = '';
var $icons = array( var $icons = array(
'type' => array( 'type' => array(
@ -1009,7 +1009,7 @@ class infolog_ui
$values['action'] = $persist['action'] = $values['nm']['action'] = $action; $values['action'] = $persist['action'] = $values['nm']['action'] = $action;
$values['action_id'] = $persist['action_id'] = $values['nm']['action_id'] = $action_id; $values['action_id'] = $persist['action_id'] = $values['nm']['action_id'] = $action_id;
$values['action_title'] = $persist['action_title'] = $values['nm']['action_title'] = $action_title; $values['action_title'] = $persist['action_title'] = $values['nm']['action_title'] = $action_title;
$values['duration_format'] = ','.$this->duration_format; $values['duration_format'] = $this->duration_format;
$persist['called_as'] = $called_as; $persist['called_as'] = $called_as;
$persist['own_referer'] = $own_referer; $persist['own_referer'] = $own_referer;

View File

@ -103,26 +103,33 @@
<vbox> <vbox>
<hbox readonly="true"> <hbox readonly="true">
<hbox readonly="true"> <hbox readonly="true">
<date-duration id="${row}[info_used_time]" readonly="true" options="@@duration_format"/> <date-duration id="${row}[info_used_time]" readonly="true"
<date-duration id="${row}[info_sum_timesheets]" readonly="true" options="@@duration_format" class="timesheet"/> display_format="@@duration_format"/>
</hbox> <date-duration id="${row}[info_sum_timesheets]" readonly="true"
display_format="@@duration_format" class="timesheet"/>
</hbox>
<description/> <description/>
</hbox> </hbox>
<date-duration id="${row}[info_planned_time]" readonly="true" options="@@duration_format" span="all" class="infolog_planned"/> <date-duration id="${row}[info_planned_time]" readonly="true" display_format="@@duration_format"
span="all" class="infolog_planned"/>
</vbox> </vbox>
<vbox> <vbox>
<hbox id="r_used_time"> <hbox id="r_used_time">
<image label="Times" src="timesheet"/> <image label="Times" src="timesheet"/>
<date-duration id="${row}[info_used_time]" readonly="true" options="@@duration_format"/> <date-duration id="${row}[info_used_time]" readonly="true"
<date-duration id="${row}[info_sum_timesheets]" readonly="true" options="@@duration_format" class="timesheet"/> display_format="@@duration_format"/>
</hbox> <date-duration id="${row}[info_sum_timesheets]" readonly="true"
display_format="@@duration_format" class="timesheet"/>
</hbox>
<hbox id="planified"> <hbox id="planified">
<image label="planned time" src="k_alarm.png"/> <image label="planned time" src="k_alarm.png"/>
<date-duration id="${row}[info_planned_time]" readonly="true" options="@@duration_format" span="all" class="infolog_planned"/> <date-duration id="${row}[info_planned_time]" readonly="true"
display_format="@@duration_format" span="all" class="infolog_planned"/>
</hbox> </hbox>
<hbox id="replanified"> <hbox id="replanified">
<image label="Re-planned time" src="agt_reload.png"/> <image label="Re-planned time" src="agt_reload.png"/>
<date-duration id="${row}[info_replanned_time]" readonly="true" options="@@duration_format" span="all" class="replanned"/> <date-duration id="${row}[info_replanned_time]" readonly="true"
display_format="@@duration_format" span="all" class="replanned"/>
</hbox> </hbox>
</vbox> </vbox>
<vbox> <vbox>