Timesheet: Update quantity placeholder when duration changes, including decimal separator

This commit is contained in:
nathan 2023-03-22 11:00:16 -06:00
parent e034557f60
commit 3dff71c8d1
2 changed files with 23 additions and 13 deletions

View File

@ -372,7 +372,7 @@ class timesheet_ui extends timesheet_bo
'to_app' => TIMESHEET_APP,
),
'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0, 3) : '',
'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
'ts_quantity' => $this->data['ts_duration'] / 60.0 == $this->data['ts_quantity'] ? null : (float)$this->data['ts_quantity'],
'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'],
'pm_integration' => $this->pm_integration,
'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS),

View File

@ -202,8 +202,18 @@ class TimesheetApp extends EgwApp
const quantity = this.et2.getWidgetById("ts_quantity");
if(quantity)
{
// use decimal separator from user prefs
const format = this.egw.preference('number_format');
const sep = format ? format[0] : '.';
// Duration is in minutes, round to hours with 1 decimal
quantity.placeholder = Math.round(parseInt(widget.value) / 6) / 10;
let val = "" + (Math.round(parseInt(widget.value) / 6) / 10);
if(format && sep && sep !== '.')
{
val = val.replace('.', sep);
}
quantity.placeholder = val;
}
}