From 5cf63cc45e1800b9e5afd059f2cf2a477dc8d0d8 Mon Sep 17 00:00:00 2001 From: ralf Date: Mon, 20 Feb 2023 12:42:21 +0100 Subject: [PATCH] * Timesheet: allow to set preference to never ask again to start working time on login --- api/js/jsapi/egw_timer.js | 8 ++++++-- api/lang/egw_de.lang | 1 + api/lang/egw_en.lang | 1 + timesheet/src/Events.php | 17 ++++++++++++++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/js/jsapi/egw_timer.js b/api/js/jsapi/egw_timer.js index 731d4c7060..b58ca823b4 100644 --- a/api/js/jsapi/egw_timer.js +++ b/api/js/jsapi/egw_timer.js @@ -670,9 +670,13 @@ egw.extend('timer', egw.MODULE_GLOBAL, function() } else { - egw.request('EGroupware\\Timesheet\\Events::ajax_dontAskAgainWorkingTime'); + egw.request('EGroupware\\Timesheet\\Events::ajax_dontAskAgainWorkingTime', button !== Et2Dialog.NO_BUTTON); } - }, 'Do you want to start your working time?', 'Working time', {}, Et2Dialog.BUTTONS_YES_NO); + }, 'Do you want to start your working time?', 'Working time', {}, [ + {button_id: Et2Dialog.YES_BUTTON, label: egw.lang('yes'), id: 'dialog[yes]', image: 'check', "default": true}, + {button_id: Et2Dialog.NO_BUTTON, label: egw.lang('no'), id: 'dialog[no]', image: 'cancel'}, + {button_id: "dont_ask_again", label: egw.lang("Don't ask again!"), id: 'dialog[dont_ask_again]', image:'save', align: "right"} + ]); } // overall timer running for more than 16 hours, ask to stop else if (overall?.start && (((new Date()).valueOf() - overall.start.valueOf()) / 3600000) >= 16) diff --git a/api/lang/egw_de.lang b/api/lang/egw_de.lang index e4f038c8c6..ff2b3e5e1e 100644 --- a/api/lang/egw_de.lang +++ b/api/lang/egw_de.lang @@ -453,6 +453,7 @@ domain name for mail-address, eg. "%1" common de Domainname für E-Mail Adresse, domestic common de Inland dominica common de DOMINICA dominican republic common de DOMINIKANISCHE REPUBLIK +don't ask again! common de Nicht wieder fragen! don't show this again common de Text nicht mehr anzeigen done common de erledigt dos international common de DOS International diff --git a/api/lang/egw_en.lang b/api/lang/egw_en.lang index 0849772021..a7fdf0556c 100644 --- a/api/lang/egw_en.lang +++ b/api/lang/egw_en.lang @@ -453,6 +453,7 @@ domain name for mail-address, eg. "%1" common en Domain name for mail address, e domestic common en Domestic dominica common en DOMINICA dominican republic common en DOMINICAN REPUBLIC +don't ask again! common en Don't ask again! don't show this again common en Don't show this again done common en Done dos international common en DOS International diff --git a/timesheet/src/Events.php b/timesheet/src/Events.php index 78fe889f91..a5ff8bee19 100644 --- a/timesheet/src/Events.php +++ b/timesheet/src/Events.php @@ -318,13 +318,24 @@ class Events extends Api\Storage\Base } /** - * Remember for 18h to not ask again to start working time + * Remember for 18h or forever to not ask again to start working time * + * @param ?bool $never true: never ask again, set preference, otherwise remember in session for 18h * @return void */ - static function ajax_dontAskAgainWorkingTime() + static function ajax_dontAskAgainWorkingTime(bool $never=null) { - Api\Cache::setSession(__CLASS__, self::DONT_ASK_AGAIN_WORKING_TIME, true, 18*3600); + if ($never) + { + $prefs = new Api\Preferences($GLOBALS['egw_info']['user']['account_id']); + $prefs->read_repository(); + $prefs->user['timesheet']['workingtime_session'] = 'no'; + $prefs->save_repository(); + } + else + { + Api\Cache::setSession(__CLASS__, self::DONT_ASK_AGAIN_WORKING_TIME, true, 18*3600); + } } /**