* Calendar: add toggles for integrated app display (infolog, call list) to the calendar toolbar

This commit is contained in:
nathangray 2021-03-03 08:55:51 -07:00
parent 4d9a30a041
commit 061a42ed67
8 changed files with 150 additions and 4 deletions

View File

@ -1218,6 +1218,11 @@ class calendar_so
{ {
foreach(isset($data[1]) ? $data : [$data] as $key => $data) foreach(isset($data[1]) ? $data : [$data] as $key => $data)
{ {
// Skip if user turned the app off
if(!in_array($data['selects'][0]['app'], $GLOBALS['egw_info']['user']['preferences']['calendar']['integration_toggle']))
{
continue;
}
// create a flat array, if app implementes multiple hooks using given app-name // create a flat array, if app implementes multiple hooks using given app-name
self::$integration_data[$data['selects'][0]['app']] = $data; self::$integration_data[$data['selects'][0]['app']] = $data;

View File

@ -383,6 +383,41 @@ class calendar_uiviews extends calendar_ui
'toolbarDefault' => true, 'toolbarDefault' => true,
), ),
); );
// Add integrated app options
$integration_data = Api\Hooks::process(array('location' => 'calendar_search_union'));
foreach($integration_data as $app => $app_hooks)
{
foreach ($app_hooks as $data)
{
// App might have multiple hooks, let it specify something else
$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']))
{
continue;
}
// Don't show infolog if there are no configured types
if($app == 'infolog' && empty($GLOBALS['egw_info']['user']['preferences']['infolog']['calendar_integration']))
{
continue;
}
$img = self::integration_get_icons($app, null, [])[0];
preg_match('/<img src=\"(.*?)\".*\/>/', $img, $results);
$actions['integration_'.$app] = array(
'caption' => $app,
'iconUrl' => $results[1] ?: "$app\navbar",
'checkbox' => true,
'hint' => lang("show %1 from %2",lang(Link::get_registry($app,'entries') ?: 'entries'),lang(Link::get_registry($app,'name'))),
'group' => 'integration',
'onExecute' => 'javaScript:app.calendar.toolbar_integration_action',
'checked' => in_array($app,$this->cal_prefs['integration_toggle']),
'data' => array('toggle_off' => '0', 'toggle_on' => '1')
);
}
}
if (Api\Header\UserAgent::mobile()) if (Api\Header\UserAgent::mobile())
{ {
foreach (array_keys($actions) as $key) foreach (array_keys($actions) as $key)

View File

@ -781,6 +781,36 @@ var CalendarApp = /** @class */ (function (_super) {
break; break;
} }
}; };
/**
* Handle integration actions from the toolbar
*
* @param action {egwAction} Integration action from the toolbar
*/
CalendarApp.prototype.toolbar_integration_action = function (action) {
var app = action.id.replace("integration_", "");
var integration_preference = egw.preference("integration_toggle", "calendar");
if (typeof integration_preference === "undefined") {
integration_preference = [];
}
if (typeof integration_preference == "string") {
integration_preference = integration_preference.split(",");
}
// Make sure it's an array, not an object
integration_preference = jQuery.extend([], integration_preference);
if (action.checked) {
integration_preference.push(app);
}
else {
var index = integration_preference.indexOf(app);
if (index > -1) {
integration_preference.splice(index, 1);
}
}
egw.set_preference("calendar", "integration_toggle", integration_preference);
// Force redraw to current state with new info, but wait a bit to let preference change get there first
this._clear_cache();
window.setTimeout(function () { this.setState({ state: this.state }); }.bind(this), 500);
};
/** /**
* Set the app header * Set the app header
* *

View File

@ -769,6 +769,44 @@ class CalendarApp extends EgwApp
} }
} }
/**
* Handle integration actions from the toolbar
*
* @param action {egwAction} Integration action from the toolbar
*/
toolbar_integration_action(action : egwAction)
{
let app = action.id.replace("integration_","");
let integration_preference = <string[]> egw.preference("integration_toggle","calendar");
if(typeof integration_preference === "undefined")
{
integration_preference = [];
}
if(typeof integration_preference == "string")
{
integration_preference = integration_preference.split(",");
}
// Make sure it's an array, not an object
integration_preference = jQuery.extend([],integration_preference);
if(action.checked)
{
integration_preference.push(app);
}
else
{
const index = integration_preference.indexOf(app);
if (index > -1) {
integration_preference.splice(index, 1);
}
}
egw.set_preference("calendar","integration_toggle",integration_preference);
// Force redraw to current state with new info, but wait a bit to let preference change get there first
this._clear_cache();
window.setTimeout(function() {this.setState({state: this.state})}.bind(this),500);
}
/** /**
* Set the app header * Set the app header
* *

View File

@ -531,6 +531,7 @@ show birthdays as all day non-blocking events as well as via mouseover of the da
show birthdays as events calendar en Show as events show birthdays as events calendar en Show as events
show birthdays from addressbook admin en Show birthdays from address book show birthdays from addressbook admin en Show birthdays from address book
show empty rows in planner calendar en Show empty rows in planner show empty rows in planner calendar en Show empty rows in planner
show %1 from %2 calendar en Show %1 from %2
show events that have been deleted calendar en Show events that have been deleted show events that have been deleted calendar en Show events that have been deleted
show list of upcoming events calendar en Show list of upcoming events show list of upcoming events calendar en Show list of upcoming events
show only accepted events calendar en Show only accepted events show only accepted events calendar en Show only accepted events

View File

@ -1497,6 +1497,21 @@ img.calendar_print_button, img.calendar_print_appicon {
position: absolute; position: absolute;
left:44%; left:44%;
} }
/* Integration slide switches in toolbar */
#calendar-toolbar_toolbar span[id^="toolbar-integration_"] {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
filter: grayscale(1) contrast(0.1);
}
#calendar-toolbar_toolbar span[id^="toolbar-integration_"].switchOn {
filter: none;
}
#calendar-toolbar_toolbar span[id^="toolbar-integration_"] span.slideSwitch_container {
background: none;
min-width: 24px;
}
#calendar-toolbar_toolbar .et2_toolbar_more { #calendar-toolbar_toolbar .et2_toolbar_more {
margin-top: 0; margin-top: 0;
} }

View File

@ -1459,6 +1459,20 @@ img.calendar_print_appicon {
position: absolute; position: absolute;
left: 44%; left: 44%;
} }
/* Integration slide switches in toolbar */
#calendar-toolbar_toolbar span[id^="toolbar-integration_"] {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
filter: grayscale(1) contrast(0.1);
}
#calendar-toolbar_toolbar span[id^="toolbar-integration_"].switchOn {
filter: none;
}
#calendar-toolbar_toolbar span[id^="toolbar-integration_"] span.slideSwitch_container {
background: none;
min-width: 24px;
}
#calendar-toolbar_toolbar .et2_toolbar_more { #calendar-toolbar_toolbar .et2_toolbar_more {
margin-top: 0; margin-top: 0;
} }
@ -2737,7 +2751,6 @@ div#calendar-container div.calendar table tbody tr.rowhilite td {
padding: 0px; padding: 0px;
} }
#calendar-toolbar_toolbar span.et2_checkbox_slideSwitch span.slideSwitch_container span.on { #calendar-toolbar_toolbar span.et2_checkbox_slideSwitch span.slideSwitch_container span.on {
background-image: url(../../../pixelegg/images/7_day_view.svg);
background-size: 18px 18px; background-size: 18px 18px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
@ -2746,7 +2759,6 @@ div#calendar-container div.calendar table tbody tr.rowhilite td {
filter: invert(1); filter: invert(1);
} }
#calendar-toolbar_toolbar span.et2_checkbox_slideSwitch span.slideSwitch_container span.off { #calendar-toolbar_toolbar span.et2_checkbox_slideSwitch span.slideSwitch_container span.off {
background-image: url(../../../pixelegg/images/5_day_view.svg);
background-size: 18px 18px; background-size: 18px 18px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
@ -2759,5 +2771,11 @@ div#calendar-container div.calendar table tbody tr.rowhilite td {
#calendar-toolbar_toolbar span.et2_checkbox_slideSwitch span.slideSwitch_container a { #calendar-toolbar_toolbar span.et2_checkbox_slideSwitch span.slideSwitch_container a {
background: none; background: none;
} }
#calendar-toolbar_toolbar #toolbar-weekend span.slideSwitch_container span.on {
background-image: url(../../../pixelegg/images/7_day_view.svg);
}
#calendar-toolbar_toolbar #toolbar-weekend span.slideSwitch_container span.off {
background-image: url(../../../pixelegg/images/5_day_view.svg);
}
/* ######################################################################################## /* ########################################################################################
/* * Calendar END */ /* * Calendar END */

View File

@ -1236,7 +1236,6 @@ div#calendar-container {
height: 22px; height: 22px;
span.slideSwitch_container { span.slideSwitch_container {
span.on { span.on {
background-image: url(../../../pixelegg/images/7_day_view.svg);
background-size: 18px 18px; background-size: 18px 18px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
@ -1245,7 +1244,6 @@ div#calendar-container {
filter: invert(1); filter: invert(1);
} }
span.off { span.off {
background-image: url(../../../pixelegg/images/5_day_view.svg);
background-size: 18px 18px; background-size: 18px 18px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
@ -1258,6 +1256,12 @@ div#calendar-container {
a {background: none;} a {background: none;}
} }
} }
#toolbar-weekend span.slideSwitch_container span.on {
background-image: url(../../../pixelegg/images/7_day_view.svg);
}
#toolbar-weekend span.slideSwitch_container span.off {
background-image: url(../../../pixelegg/images/5_day_view.svg);
}
} }
/* ######################################################################################## /* ########################################################################################