From 026b088dd09ef5df91c5a0a171232bd8bb758dab Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 25 Mar 2021 14:39:01 -0600 Subject: [PATCH] Calendar: Add button to toggle videoconference events It works by configured category in status app --- calendar/inc/class.calendar_uilist.inc.php | 10 ++++++ calendar/inc/class.calendar_uiviews.inc.php | 21 ++++++++++++- calendar/js/app.js | 30 ++++++++++++++---- calendar/js/app.ts | 35 ++++++++++++++++----- calendar/templates/default/app.css | 6 ++-- calendar/templates/pixelegg/app.css | 6 ++-- calendar/templates/pixelegg/app.less | 1 + 7 files changed, 89 insertions(+), 20 deletions(-) diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 963460fcda..007f3848df 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -417,6 +417,16 @@ class calendar_uilist extends calendar_ui $col_filter['cal_id'] = $val; } } + // Videocalls + if(array_key_exists('include_videocalls',$params['col_filter'])) + { + $status_config = Api\Config::read("status"); + if (!$col_filter['include_videocalls']) + { + $col_filter[] = 'cal_category != ' . $this->bo->so->db->quote( $status_config['status_cat_videocall']); + } + unset($col_filter['include_videocalls']); + } } $rows = $js_integration_data = array(); diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index 9bdbd09734..c604c477ec 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -11,6 +11,7 @@ */ use EGroupware\Api; +use EGroupware\Api\Image; use EGroupware\Api\Link; use EGroupware\Api\Framework; use EGroupware\Api\Egw; @@ -376,6 +377,22 @@ class calendar_uiviews extends calendar_ui ), ); + // Add toggle for video calls + $status_config = Api\Config::read("status"); + if($status_config["status_cat_videocall"]) + { + $actions['video_toggle'] = array( + 'caption' => 'Video call', + 'iconUrl' => Image::find('status', 'videoconference_call'), + 'checkbox' => true, + 'hint' => lang("video call"), + 'group' => 'integration', + 'onExecute' => 'javaScript:app.calendar.toolbar_videocall_toggle_action', + 'checked' => in_array('video_toggle', $this->cal_prefs['integration_toggle']), + 'data' => array('toggle_off' => '0', 'toggle_on' => '1') + ); + } + // Add integrated app options $integration_data = Api\Hooks::process(array('location' => 'calendar_search_union')); foreach($integration_data as $app => $app_hooks) @@ -386,7 +403,9 @@ class calendar_uiviews extends calendar_ui $app = $data['selects']['app'] ?: $app; // Don't add if no access or app already added - if (!array_key_exists($app, $GLOBALS['egw_info']['user']['apps']) || array_key_exists($app, $actions['integration']['children'])) + if (!array_key_exists($app, $GLOBALS['egw_info']['user']['apps']) || + (is_array($actions['integration']['children']) && array_key_exists($app, $actions['integration']['children'])) + ) { continue; } diff --git a/calendar/js/app.js b/calendar/js/app.js index 9854dfb6bf..7e438bc4c5 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -124,7 +124,8 @@ var CalendarApp = /** @class */ (function (_super) { owner: egw.user('account_id'), keywords: '', last: undefined, - first: undefined + first: undefined, + include_videocalls: false }; // If you are in one of these views and select a date in the sidebox, the view // will change as needed to show the date. Other views will only change the @@ -797,12 +798,24 @@ var CalendarApp = /** @class */ (function (_super) { break; } }; + /** + * Handle the video call toggle from the toolbar + * + * @param action + */ + CalendarApp.prototype.toolbar_videocall_toggle_action = function (action) { + var videocall_category = egw.config("status_cat_videocall", "status"); + var callback = function () { + this.update_state({ include_videocalls: action.checked }); + }.bind(this); + this.toolbar_integration_action(action, [], null, callback); + }; /** * Handle integration actions from the toolbar * * @param action {egwAction} Integration action from the toolbar */ - CalendarApp.prototype.toolbar_integration_action = function (action) { + CalendarApp.prototype.toolbar_integration_action = function (action, selected, target, callback) { var app = action.id.replace("integration_", ""); var integration_preference = egw.preference("integration_toggle", "calendar"); if (typeof integration_preference === "undefined") { @@ -813,11 +826,10 @@ var CalendarApp = /** @class */ (function (_super) { } // Make sure it's an array, not an object integration_preference = jQuery.extend([], integration_preference); - var callback = function () { }; if (action.checked) { integration_preference.push(app); // After the preference change is done, get new info which should now include the app - callback = function () { + callback = callback ? callback : function () { this._fetch_data(this.state); }.bind(this); } @@ -829,6 +841,9 @@ var CalendarApp = /** @class */ (function (_super) { // Clear any events from that app this._clear_cache(app); } + if (typeof callback === "undefined") { + callback = function () { }; + } egw.set_preference("calendar", "integration_toggle", integration_preference, callback); }; /** @@ -3054,8 +3069,11 @@ var CalendarApp = /** @class */ (function (_super) { row_id: 'row_id', startdate: state.first || state.date, enddate: state.last, - // Participant must be an array or it won't work - col_filter: { participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner) }, + col_filter: { + // Participant must be an array or it won't work + participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner), + include_videocalls: state.include_videocalls + }, filter: 'custom', status_filter: state.status_filter, cat_id: cat_id, diff --git a/calendar/js/app.ts b/calendar/js/app.ts index ad154a9cb4..6859a9403b 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -88,7 +88,8 @@ class CalendarApp extends EgwApp owner: egw.user('account_id'), keywords: '', last: undefined, - first: undefined + first: undefined, + include_videocalls: false }; /** @@ -791,12 +792,26 @@ class CalendarApp extends EgwApp } } + /** + * Handle the video call toggle from the toolbar + * + * @param action + */ + toolbar_videocall_toggle_action(action : egwAction) + { + let videocall_category = egw.config("status_cat_videocall","status"); + let callback = function() { + this.update_state({include_videocalls: action.checked}); + }.bind(this); + this.toolbar_integration_action(action, [],null,callback); + } + /** * Handle integration actions from the toolbar * * @param action {egwAction} Integration action from the toolbar */ - toolbar_integration_action(action : egwAction) + toolbar_integration_action(action : egwAction, selected: egwActionObject[], target: egwActionObject, callback? : CallableFunction) { let app = action.id.replace("integration_",""); let integration_preference = egw.preference("integration_toggle","calendar"); @@ -811,14 +826,12 @@ class CalendarApp extends EgwApp // Make sure it's an array, not an object integration_preference = jQuery.extend([],integration_preference); - let callback = function() {}; - if(action.checked) { integration_preference.push(app); // After the preference change is done, get new info which should now include the app - callback = function() { + callback = callback ? callback : function() { this._fetch_data(this.state); }.bind(this); } @@ -832,6 +845,11 @@ class CalendarApp extends EgwApp // Clear any events from that app this._clear_cache(app); } + if(typeof callback === "undefined") + { + callback = function() {}; + } + egw.set_preference("calendar","integration_toggle",integration_preference, callback); } @@ -3592,8 +3610,11 @@ class CalendarApp extends EgwApp row_id:'row_id', startdate:state.first || state.date, enddate:state.last, - // Participant must be an array or it won't work - col_filter: {participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner)}, + col_filter: { + // Participant must be an array or it won't work + participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner), + include_videocalls: state.include_videocalls + }, filter:'custom', // Must be custom to get start & end dates status_filter: state.status_filter, cat_id: cat_id, diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index f08bef01af..e3a06c093e 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -1521,17 +1521,17 @@ img.calendar_print_button, img.calendar_print_appicon { left:44%; } /* Integration slide switches in toolbar */ -#calendar-toolbar_toolbar span[id^="toolbar-integration_"] { +#calendar-toolbar_toolbar span[data-group="integration"] > span { background-size: contain; background-repeat: no-repeat; background-position: center; filter: grayscale(1) contrast(0.9999) opacity(0.7); } -#calendar-toolbar_toolbar span[id^="toolbar-integration_"].switchOn { +#calendar-toolbar_toolbar span[data-group="integration"] > span.switchOn { filter: none; box-shadow: inset 1px 1px 1px 1px gray !important; } -#calendar-toolbar_toolbar span[id^="toolbar-integration_"] span.slideSwitch_container { +#calendar-toolbar_toolbar span[data-group="integration"] > span span.slideSwitch_container { background: none; min-width: 24px; } diff --git a/calendar/templates/pixelegg/app.css b/calendar/templates/pixelegg/app.css index fa731a25e6..e4a795ca7b 100755 --- a/calendar/templates/pixelegg/app.css +++ b/calendar/templates/pixelegg/app.css @@ -1483,17 +1483,17 @@ img.calendar_print_appicon { left: 44%; } /* Integration slide switches in toolbar */ -#calendar-toolbar_toolbar span[id^="toolbar-integration_"] { +#calendar-toolbar_toolbar span[data-group="integration"] > span { background-size: contain; background-repeat: no-repeat; background-position: center; filter: grayscale(1) contrast(0.9999) opacity(0.7); } -#calendar-toolbar_toolbar span[id^="toolbar-integration_"].switchOn { +#calendar-toolbar_toolbar span[data-group="integration"] > span.switchOn { filter: none; box-shadow: inset 1px 1px 1px 1px gray !important; } -#calendar-toolbar_toolbar span[id^="toolbar-integration_"] span.slideSwitch_container { +#calendar-toolbar_toolbar span[data-group="integration"] > span span.slideSwitch_container { background: none; min-width: 24px; } diff --git a/calendar/templates/pixelegg/app.less b/calendar/templates/pixelegg/app.less index be6ecb99b7..90b3966884 100755 --- a/calendar/templates/pixelegg/app.less +++ b/calendar/templates/pixelegg/app.less @@ -17,6 +17,7 @@ + /*generell*/ // makes svg visible