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

@ -362,21 +362,21 @@ class timesheet_ui extends timesheet_bo
'referer' => $referer,
'ts_title_blur' => $content['ts_title_blur'],
);
$content = array_merge($this->data,array(
'msg' => $msg,
'view' => $view,
'tabs' => $content['tabs'],
'link_to' => array(
'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] :
$content = array_merge($this->data, array(
'msg' => $msg,
'view' => $view,
'tabs' => $content['tabs'],
'link_to' => array(
'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] :
($this->data['link_to']['to_id'] ? $this->data['link_to']['to_id'] : $content['link_to']['to_id']),
'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'],
'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),
'tabs' => $_GET['tabs'] ?? 'general',
'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 : (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),
'tabs' => $_GET['tabs'] ?? 'general',
));
$links = array();
// create links specified in the REQUEST (URL)

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;
}
}