diff --git a/api/js/jsapi/egw_timer.js b/api/js/jsapi/egw_timer.js index 43dd1d69fd..4dafc0ede0 100644 --- a/api/js/jsapi/egw_timer.js +++ b/api/js/jsapi/egw_timer.js @@ -92,6 +92,7 @@ egw.extend('timer', egw.MODULE_GLOBAL, function() * * @param {string} _action * @param {string} _time + * @throws string error-message */ function timerAction(_action, _time) { @@ -267,17 +268,22 @@ egw.extend('timer', egw.MODULE_GLOBAL, function() * @param object _timer * @param bool|undefined _pause true: pause, else: stop * @param string|Date|undefined _time stop-time, default current time + * @throws string error-message when timer.start < _time */ function stopTimer(_timer, _pause, _time) { const time = _time ? new Date(_time) : new Date(); // update _timer state object - _timer.paused = _pause || false; if (_timer.start) { + if (time.valueOf() < _timer.start.valueOf()) + { + throw egw.lang('Stop- or pause-time can not be before the start-time!'); + } _timer.offset = time.valueOf() - _timer.start.valueOf(); _timer.start = undefined; } + _timer.paused = _pause || false; // update timer display updateTimer(timer, _timer); @@ -334,10 +340,15 @@ egw.extend('timer', egw.MODULE_GLOBAL, function() callback: (button_id, value) => // return false to prevent dialog closing { if (button_id !== 'close') { - timerAction(button_id.replace(/_([a-z]+)\[([a-z]+)\]/, '$1-$2'), - // eT2 operates in user-time, while timers here always operate in UTC - value.time ? new Date((new Date(value.time)).valueOf() + egw.getTimezoneOffset() * 60000) : undefined); - dialog._overlayContentNode.querySelector('et2-date-time').value = ''; + try { + timerAction(button_id.replace(/_([a-z]+)\[([a-z]+)\]/, '$1-$2'), + // eT2 operates in user-time, while timers here always operate in UTC + value.time ? new Date((new Date(value.time)).valueOf() + egw.getTimezoneOffset() * 60000) : undefined); + dialog._overlayContentNode.querySelector('et2-date-time').value = ''; + } + catch (e) { + Et2Dialog.alert(e, egw.lang('Invalid Input'), Et2Dialog.ERROR_MESSAGE); + } setButtonState(); return false; } diff --git a/timesheet/lang/egw_de.lang b/timesheet/lang/egw_de.lang index c78d0a2f0d..74a2453ccd 100644 --- a/timesheet/lang/egw_de.lang +++ b/timesheet/lang/egw_de.lang @@ -68,6 +68,7 @@ import options timesheet de Import Optionen imports entries into the timesheet from a csv file. timesheet de Importiert Einträge für den Stundenzettel aus einer CSV Datei. insert timesheet de einfügen invalid field: %1 = %2, it needs to be a number. timesheet de Ungültiges Feld: %1 =%2, es muss eine Zahl sein +invalid input common de Ungültige Eingabe invalid owner id: %1. might be a bad field translation. used %2 instead. timesheet de Ungültiger Benutze ID: %1 könnte eine falsche Feldzuordnung haben. %2 wird stattdessen verwendet. last modified timesheet de Zuletzt geändert last month timesheet de Letzten Monat @@ -135,6 +136,7 @@ status deleted. timesheet de Status gelöscht status of created timesheets timesheet de Status für neue Stundenzettel status updated. timesheet de Status geändert stop common de Stop +stop- or pause-time can not be before the start-time! common de Stop- oder Pause-Zeit kann nicht vor der Start-Zeit liegen! sum timesheet de Summe sum %1: timesheet de Summe %1: tag to mark positions for address labels timesheet de Platzhalter, um die Position der Adresslabels festzulegen diff --git a/timesheet/lang/egw_en.lang b/timesheet/lang/egw_en.lang index bf7175369f..d9c1e06dfc 100644 --- a/timesheet/lang/egw_en.lang +++ b/timesheet/lang/egw_en.lang @@ -68,6 +68,7 @@ import options timesheet en Import options imports entries into the timesheet from a csv file. timesheet en Imports entries into the Time Sheet from a CSV file insert timesheet en Insert invalid field: %1 = %2, it needs to be a number. timesheet en Invalid field: %1 = %2, it needs to be a number. +invalid input common en Invalid input invalid owner id: %1. might be a bad field translation. used %2 instead. timesheet en Invalid owner ID: %1. Might be a bad field translation. Used %2 instead. last modified timesheet en Last modified last month timesheet en Last month @@ -135,6 +136,7 @@ status deleted. timesheet en Status deleted. status of created timesheets timesheet en Status of created timesheets status updated. timesheet en Status updated. stop common en Stop +stop- or pause-time can not be before the start-time! common en Stop- or pause-time can not be before the start-time! sum timesheet en Sum sum %1: timesheet en Sum %1: tag to mark positions for address labels timesheet en Tag to mark positions for address labels