fix et2-date-duration showing NaN:NaN in timesheet

boolean attributes should not have a default of true, because DOM does NOT reflect false and we need to reflect for use in NM
--> changed default for select_unit for r/o duration to false and set it in timesheet.index to true
--> changing it for r/w too would require a lot of xet files to be updated (we don't need reflection there)
This commit is contained in:
ralf 2022-03-02 11:02:24 +02:00
parent d7adf26ce6
commit 89613dd368
4 changed files with 9 additions and 7 deletions

View File

@ -76,8 +76,8 @@ function send_template()
str_replace($type[0], '', $matches[0]);
list($matches[1], $matches[2]) = explode('-', $type[1], 2);
}
static $legacy_options = array(
'select' => 'empty_label,dummy',
static $legacy_options = array( // use "ignore" to ignore further comma-sep. values, otherwise they are all in last attribute
'select' => 'empty_label,ignore',
'box' => ',cellpadding,cellspacing,keep',
'hbox' => 'cellpadding,cellspacing,keep',
'vbox' => 'cellpadding,cellspacing,keep',
@ -85,7 +85,7 @@ function send_template()
'checkbox' => 'selected_value,unselected_value,ro_true,ro_false',
'radio' => 'set_value,ro_true,ro_false',
'customfields' => 'sub-type,use-private,field-names',
'date' => 'data_format', // Legacy option "mode" was never implemented in et2
'date' => 'data_format,ignore', // Legacy option "mode" was never implemented in et2
'description' => 'bold-italic,link,activate_links,label_for,link_target,link_popup_size,link_title',
);
// prefer more specific type-subtype over just type
@ -99,6 +99,7 @@ function send_template()
$values = array_merge($values, array_fill(count($values), count($names)-count($values), ''));
}
$attrs = array_diff(array_combine($names, $values), ['', null]);
unset($attrs['ignore']);
// fix select options can be either multiple or empty_label
if ($matches[1] === 'select' && !empty($attrs['empty_label']) && (int)$attrs['empty_label'] > 0)
{

View File

@ -186,6 +186,7 @@ export class Et2DateDuration extends Et2InputWidget(FormControlMixin(LitElement)
* Default is true
*/
select_unit: {
reflect: true,
type: Boolean
},
@ -451,7 +452,7 @@ export class Et2DateDuration extends Et2InputWidget(FormControlMixin(LitElement)
_value = Math.floor(_value / 3600);
return _highest ? _value : _value % this.hours_per_day;
case 'd':
return Math.floor(_value / 3600 * this.hours_per_day);
return Math.floor(_value / 3600 / this.hours_per_day);
}
}

View File

@ -938,7 +938,7 @@ export class et2_date_duration extends et2_date
_value = Math.floor(_value / 3600);
return _highest ? _value : _value % this.options.hours_per_day;
case 'd':
return Math.floor(_value / 3600*this.options.hours_per_day);
return Math.floor(_value / 3600 / this.options.hours_per_day);
}
}

View File

@ -81,7 +81,7 @@
<menulist class="noWrap">
<menupopup type="select-cat" id="${row}[cat_id]" readonly="true"/>
</menulist>
<date-duration id="${row}[ts_duration]" readonly="true" options=",h,,,1" align="right"/>
<date-duration id="${row}[ts_duration]" readonly="true" display_format="h" select_unit="true" align="right"/>
<textbox type="float" id="${row}[ts_quantity]" no_lang="1" readonly="true" precision="3"/>
<description id="${row}[ts_unitprice]" no_lang="1"/>
<textbox type="float" id="${row}[ts_total]" no_lang="1" readonly="true" precision="2"/>
@ -101,4 +101,4 @@
<template id="timesheet.index" template="" lang="" group="0" version="1.9.001">
<nextmatch id="nm" options="timesheet.index.rows" header_left="timesheet.index.add" header_right="timesheet.index.dates"/>
</template>
</overlay>
</overlay>