Fix problems with links from mail

- unsaved links were not properly displayed
- unsaved links could not be removed
- calendar preserved original links, so even if you removed one it came back
This commit is contained in:
nathan 2022-11-01 15:38:58 -06:00
parent 8601f274ef
commit 953166b161
4 changed files with 33 additions and 14 deletions

View File

@ -152,9 +152,10 @@ export class Et2LinkList extends Et2LinkString
*/
protected _linkTemplate(link) : TemplateResult
{
const id = typeof link.id === "string" ? link.id : link.link_id;
return html`
${this._thumbnailTemplate(link)}
<et2-link slot="${this._get_row_id(link)}" app="${link.app}" entry_id="${link.id}"
<et2-link slot="${this._get_row_id(link)}" app="${link.app}" entry_id="${id}"
._parent=${this}
.value=${link}></et2-link>
<et2-description slot="${this._get_row_id(link)}" ._parent=${this} class="remark"
@ -248,7 +249,7 @@ export class Et2LinkList extends Et2LinkString
<et2-image-expose
slot="${this._get_row_id(link)}" ._parent=${this}
href="${link.href}"
src=${this.egw().image(link.icon)}></et2-image-expose>`;
src=${this.egw().image("" + link.icon)}></et2-image-expose>`;
}
/**

View File

@ -123,22 +123,36 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
{
_value.to_app = this.application;
}
if(typeof _value == 'object' && !Array.isArray(_value) && _value.to_app && _value.to_id)
// We have app & ID - fetch list
if(typeof _value == 'object' && !Array.isArray(_value) && _value.to_app && _value.to_id && typeof _value.to_id === "string")
{
this.application = _value.to_app;
this.entryId = _value.to_id;
this.get_links();
return;
}
// CSV list of IDs for one app
if(typeof _value === "string")
{
let ids = _value.split(",");
ids.forEach((id) => (<LinkInfo[]>this._link_list).push(<LinkInfo>{app: this.application, id: id}));
}
// List of LinkInfo
else if(Array.isArray(_value))
{
this._link_list = _value;
}
// List of LinkInfo stuffed into to_id - entry is not yet saved
else if(typeof _value.to_id !== "string")
{
this.entryId = _value.to_id;
Object.keys(_value.to_id).forEach((key) =>
{
this._link_list.push(<LinkInfo>_value.to_id[key]);
});
}
this._addLinks(this._link_list);
super.requestUpdate();
}
@ -170,10 +184,11 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
* @returns {TemplateResult}
* @protected
*/
protected _linkTemplate(link) : TemplateResult
protected _linkTemplate(link : LinkInfo) : TemplateResult
{
const id = typeof link.id === "string" ? link.id : link.link_id;
return html`
<et2-link app="${link.app}" entryId="${link.id}" .value=${link} ._parent=${this}></et2-link>`;
<et2-link app="${link.app}" entryId="${id}" .value=${link} ._parent=${this}></et2-link>`;
}
/**

View File

@ -428,6 +428,7 @@ class Link extends Link\Storage
$id1[$link_id] = array(
'app' => $app2,
'id' => $id2,
'title' => $id2['title'] ?? $id2['name'],
'remark' => $remark,
'owner' => $owner,
'link_id' => $link_id,

View File

@ -1788,7 +1788,7 @@ class calendar_uiforms extends calendar_ui
$content['participants']['status_date'] = $preserv['actual_date'];
// set notify_externals in participants from cfs
if (!empty($event['##notify_externals']))
if(!empty($event['##notify_externals']))
{
$content['participants']['notify_externals'] = $event['##notify_externals'];
}
@ -1796,15 +1796,17 @@ class calendar_uiforms extends calendar_ui
{
$content['participants']['notify_externals'] = $this->cal_prefs['notify_externals'];
}
$preserved = array_merge($preserv,$content);
$preserved = array_merge($preserv, $content);
// Don't preserve link_to, it causes problems if user removes a link
unset($preserved['link_to']);
$event['new_alarm']['options'] = $content['new_alarm']['options'];
if ($event['alarm'])
if($event['alarm'])
{
// makes keys of the alarm-array starting with 1
$content['alarm'] = array(false);
foreach(array_values($event['alarm']) as $id => $alarm)
{
if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
if(!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner']))
{
continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
}