* 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
This commit is contained in:
nathan 2023-08-01 15:53:16 -06:00
parent 27f750d33b
commit 780f16702f
5 changed files with 79 additions and 25 deletions

View File

@ -54,9 +54,34 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
// calendar app is not yet loaded. // calendar app is not yet loaded.
$value = !empty($sel_options) ? array(): explode(',', $value); $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 // 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); $label = self::get_owner_label($owner);
$info = array(); $info = array();
@ -213,6 +238,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
if(array_key_exists('total', $options)) if(array_key_exists('total', $options))
{ {
$total += $options['total']; $total += $options['total'];
unset($options['total']);
} }
} }
// Use standard link registry // Use standard link registry
@ -222,6 +248,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
if(array_key_exists('total', $options)) if(array_key_exists('total', $options))
{ {
$total += $options['total']; $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'])) if(isset($value['email']) || isset($contact['email']) || isset($contact['email_home']))
{ {
$email = \EGroupware\Api\Mail::stripRFC822Addresses(array($value['email'] ?: $contact['email'] ?: $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) if($id < 0)
{ {

View File

@ -9,9 +9,9 @@
*/ */
import {Et2Select} from "../../api/js/etemplate/Et2Select/Et2Select"; 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 {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"; import {Et2StaticSelectMixin} from "../../api/js/etemplate/Et2Select/StaticOptions";
/** /**
@ -45,30 +45,45 @@ export class CalendarOwner extends Et2StaticSelectMixin(Et2Select)
this.searchOptions['checkgrants'] = true; 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`
<sl-menu-item value="${option.value}"
title="${!option.title || this.noLang ? option.title : this.egw().lang(option.title)}"
class="${option.class}" .option=${option}
?disabled=${option.disabled}
>
${this._iconTemplate(option)}
${this.noLang ? option.label : this.egw().lang(option.label)}
<span class="title" slot="suffix">${option.title}</span>
</sl-menu-item>`;
}
// Start fetch of users /**
const type = this.egw().preference('account_selection', 'common'); * Customise how tags are rendered. Overridden from parent to add email to title for hover
if(!type || type == "none") *
* @param item
* @protected
*/
protected _createTagNode(item)
{
const tag = super._createTagNode(item);
if(item.title)
{ {
return; tag.title = item.title;
} }
let fetch = []; return tag;
// 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());
} }
/** /**

View File

@ -98,6 +98,10 @@
background-color: var(--row_hover); background-color: var(--row_hover);
box-shadow: none; box-shadow: none;
} }
/* Hide email in sidebox */
#calendar-sidebox_owner .title {
display: none;
}
/* Conflict display */ /* Conflict display */
.calendar_conflicts { .calendar_conflicts {

View File

@ -114,6 +114,10 @@
background-color: var(--row_hover); background-color: var(--row_hover);
box-shadow: none; box-shadow: none;
} }
/* Hide email in sidebox */
#calendar-sidebox_owner .title {
display: none;
}
/* Conflict display */ /* Conflict display */
.calendar_conflicts { .calendar_conflicts {
max-height: 540px; max-height: 540px;
@ -1462,7 +1466,7 @@ et2-switch#calendar-toolbar_toolbar-weekend {
height: 100%; height: 100%;
} }
#calendar-toolbar_toolbar et2-switch#calendar-toolbar_toolbar-weekend .label span { #calendar-toolbar_toolbar et2-switch#calendar-toolbar_toolbar-weekend .label span {
background-size: contain; background-size: 20px;
height: 75%; height: 75%;
} }
#calendar-toolbar_toolbar et2-switch#calendar-toolbar_toolbar-weekend .label { #calendar-toolbar_toolbar et2-switch#calendar-toolbar_toolbar-weekend .label {

View File

@ -102,6 +102,10 @@
background-color: var(--row_hover); background-color: var(--row_hover);
box-shadow: none; box-shadow: none;
} }
/* Hide email in sidebox */
#calendar-sidebox_owner .title {
display: none;
}
/* Conflict display */ /* Conflict display */
.calendar_conflicts { .calendar_conflicts {
max-height: 540px; max-height: 540px;