From 780f16702f44628f70d62078e0dde03083efe8d9 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 1 Aug 2023 15:53:16 -0600 Subject: [PATCH] * Calendar: Change how participant emails are shown Sidebox: emails are shown on hover Edit dialog: emails are shown in search results Week headers: emails are no longer shown To support this, now sending account options from server instead of pulling from user list --- ...ss.calendar_owner_etemplate_widget.inc.php | 31 +++++++++- calendar/js/CalendarOwner.ts | 59 ++++++++++++------- calendar/templates/default/app.css | 4 ++ calendar/templates/mobile/app.css | 6 +- calendar/templates/pixelegg/app.css | 4 ++ 5 files changed, 79 insertions(+), 25 deletions(-) diff --git a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php index 8a5f89df54..0d01478613 100644 --- a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php +++ b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php @@ -54,9 +54,34 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist // calendar app is not yet loaded. $value = !empty($sel_options) ? array(): explode(',', $value); } + $option_list = (array)$value; + + // Add in accounts / own groups + $type = $bo->common_prefs['account_selection']; + if(!$type || $type == "none") + { + $accounts = []; + } + else + { + $accounts = Framework::ajax_user_list(); + if($type == "primary_groups") + { + unset($accounts['groups']); + } + else + { + unset($accounts['owngroups']); + } + } + foreach($accounts as $type_account_list) + { + $option_list = array_merge($option_list, array_column($type_account_list, 'value')); + } + // Add external owners that a select account widget will not find - foreach((array)$value as $owner) + foreach(array_unique($option_list) as $owner) { $label = self::get_owner_label($owner); $info = array(); @@ -213,6 +238,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist if(array_key_exists('total', $options)) { $total += $options['total']; + unset($options['total']); } } // Use standard link registry @@ -222,6 +248,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist if(array_key_exists('total', $options)) { $total += $options['total']; + unset($options['total']); } } @@ -353,7 +380,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist if(isset($value['email']) || isset($contact['email']) || isset($contact['email_home'])) { $email = \EGroupware\Api\Mail::stripRFC822Addresses(array($value['email'] ?: $contact['email'] ?: $contact['email_home'])); - $value['label'] .= $email ? (' <' . $email[0] . '>') : ""; + $value['title'] = $email ? (' <' . $email[0] . '>') : ""; } if($id < 0) { diff --git a/calendar/js/CalendarOwner.ts b/calendar/js/CalendarOwner.ts index 898387c317..c0b771c37a 100644 --- a/calendar/js/CalendarOwner.ts +++ b/calendar/js/CalendarOwner.ts @@ -9,9 +9,9 @@ */ import {Et2Select} from "../../api/js/etemplate/Et2Select/Et2Select"; -import {css, html, nothing} from "@lion/core"; +import {css, html, nothing, TemplateResult} from "@lion/core"; import {IsEmail} from "../../api/js/etemplate/Validators/IsEmail"; -import {cleanSelectOptions} from "../../api/js/etemplate/Et2Select/FindSelectOptions"; +import {SelectOption} from "../../api/js/etemplate/Et2Select/FindSelectOptions"; import {Et2StaticSelectMixin} from "../../api/js/etemplate/Et2Select/StaticOptions"; /** @@ -45,30 +45,45 @@ export class CalendarOwner extends Et2StaticSelectMixin(Et2Select) this.searchOptions['checkgrants'] = true; } - connectedCallback() + /** + * Override parent to show email address in options + * + * We use this in edit dialog, but the same widget is used in sidemenu where the email is hidden via CSS. + * Anything set in "title" will be shown + * + * @param {SelectOption} option + * @returns {TemplateResult} + */ + _optionTemplate(option : SelectOption) : TemplateResult { - super.connectedCallback(); + // Tag used must match this.optionTag, but you can't use the variable directly. + // Pass option along so SearchMixin can grab it if needed + return html` + + ${this._iconTemplate(option)} + ${this.noLang ? option.label : this.egw().lang(option.label)} + ${option.title} + `; + } - // Start fetch of users - const type = this.egw().preference('account_selection', 'common'); - if(!type || type == "none") + /** + * Customise how tags are rendered. Overridden from parent to add email to title for hover + * + * @param item + * @protected + */ + protected _createTagNode(item) + { + const tag = super._createTagNode(item); + if(item.title) { - return; + tag.title = item.title; } - let fetch = []; - // for primary_group we only display owngroups == own memberships, not other groups - if(type === 'primary_group') - { - fetch.push(this.egw().accounts('accounts').then(options => {this.static_options = this.static_options.concat(cleanSelectOptions(options))})); - fetch.push(this.egw().accounts('owngroups').then(options => {this.static_options = this.static_options.concat(cleanSelectOptions(options))})); - } - else - { - fetch.push(this.egw().accounts('accounts').then(options => {this.static_options = this.static_options.concat(cleanSelectOptions(options))})); - fetch.push(this.egw().accounts('groups').then(options => {this.static_options = this.static_options.concat(cleanSelectOptions(options))})); - } - this.fetchComplete = Promise.all(fetch) - .then(() => this._renderOptions()); + return tag; } /** diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index 6f9619a302..27832a2374 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -98,6 +98,10 @@ background-color: var(--row_hover); box-shadow: none; } +/* Hide email in sidebox */ +#calendar-sidebox_owner .title { + display: none; +} /* Conflict display */ .calendar_conflicts { diff --git a/calendar/templates/mobile/app.css b/calendar/templates/mobile/app.css index 4e82606a4b..93f76d17a1 100644 --- a/calendar/templates/mobile/app.css +++ b/calendar/templates/mobile/app.css @@ -114,6 +114,10 @@ background-color: var(--row_hover); box-shadow: none; } +/* Hide email in sidebox */ +#calendar-sidebox_owner .title { + display: none; +} /* Conflict display */ .calendar_conflicts { max-height: 540px; @@ -1462,7 +1466,7 @@ et2-switch#calendar-toolbar_toolbar-weekend { height: 100%; } #calendar-toolbar_toolbar et2-switch#calendar-toolbar_toolbar-weekend .label span { - background-size: contain; + background-size: 20px; height: 75%; } #calendar-toolbar_toolbar et2-switch#calendar-toolbar_toolbar-weekend .label { diff --git a/calendar/templates/pixelegg/app.css b/calendar/templates/pixelegg/app.css index ebdf6d9b15..7d4ab3d635 100755 --- a/calendar/templates/pixelegg/app.css +++ b/calendar/templates/pixelegg/app.css @@ -102,6 +102,10 @@ background-color: var(--row_hover); box-shadow: none; } +/* Hide email in sidebox */ +#calendar-sidebox_owner .title { + display: none; +} /* Conflict display */ .calendar_conflicts { max-height: 540px;