Calendar: Add button to toggle videoconference events

It works by configured category in status app
This commit is contained in:
nathangray 2021-03-25 14:39:01 -06:00
parent 2b9230c326
commit 026b088dd0
7 changed files with 89 additions and 20 deletions

View File

@ -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();

View File

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

View File

@ -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,
col_filter: {
// 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) },
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,

View File

@ -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 = <string[]> 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,
col_filter: {
// 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)},
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,

View File

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

View File

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

View File

@ -17,6 +17,7 @@
/*generell*/
// makes svg visible