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 protected _linkTemplate(link) : TemplateResult
{ {
const id = typeof link.id === "string" ? link.id : link.link_id;
return html` return html`
${this._thumbnailTemplate(link)} ${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} ._parent=${this}
.value=${link}></et2-link> .value=${link}></et2-link>
<et2-description slot="${this._get_row_id(link)}" ._parent=${this} class="remark" <et2-description slot="${this._get_row_id(link)}" ._parent=${this} class="remark"
@ -248,7 +249,7 @@ export class Et2LinkList extends Et2LinkString
<et2-image-expose <et2-image-expose
slot="${this._get_row_id(link)}" ._parent=${this} slot="${this._get_row_id(link)}" ._parent=${this}
href="${link.href}" 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; _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.application = _value.to_app;
this.entryId = _value.to_id; this.entryId = _value.to_id;
this.get_links(); this.get_links();
return; return;
} }
// CSV list of IDs for one app
if(typeof _value === "string") if(typeof _value === "string")
{ {
let ids = _value.split(","); let ids = _value.split(",");
ids.forEach((id) => (<LinkInfo[]>this._link_list).push(<LinkInfo>{app: this.application, id: id})); ids.forEach((id) => (<LinkInfo[]>this._link_list).push(<LinkInfo>{app: this.application, id: id}));
} }
// List of LinkInfo
else if(Array.isArray(_value)) else if(Array.isArray(_value))
{ {
this._link_list = _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); this._addLinks(this._link_list);
super.requestUpdate(); super.requestUpdate();
} }
@ -170,10 +184,11 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
* @returns {TemplateResult} * @returns {TemplateResult}
* @protected * @protected
*/ */
protected _linkTemplate(link) : TemplateResult protected _linkTemplate(link : LinkInfo) : TemplateResult
{ {
const id = typeof link.id === "string" ? link.id : link.link_id;
return html` 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

@ -426,10 +426,11 @@ class Link extends Link\Storage
$link_id = self::temp_link_id($app2,$id2); $link_id = self::temp_link_id($app2,$id2);
$id1[$link_id] = array( $id1[$link_id] = array(
'app' => $app2, 'app' => $app2,
'id' => $id2, 'id' => $id2,
'remark' => $remark, 'title' => $id2['title'] ?? $id2['name'],
'owner' => $owner, 'remark' => $remark,
'owner' => $owner,
'link_id' => $link_id, 'link_id' => $link_id,
'lastmod' => time() 'lastmod' => time()
); );

View File

@ -1788,7 +1788,7 @@ class calendar_uiforms extends calendar_ui
$content['participants']['status_date'] = $preserv['actual_date']; $content['participants']['status_date'] = $preserv['actual_date'];
// set notify_externals in participants from cfs // set notify_externals in participants from cfs
if (!empty($event['##notify_externals'])) if(!empty($event['##notify_externals']))
{ {
$content['participants']['notify_externals'] = $event['##notify_externals']; $content['participants']['notify_externals'] = $event['##notify_externals'];
} }
@ -1796,17 +1796,19 @@ class calendar_uiforms extends calendar_ui
{ {
$content['participants']['notify_externals'] = $this->cal_prefs['notify_externals']; $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']; $event['new_alarm']['options'] = $content['new_alarm']['options'];
if ($event['alarm']) if($event['alarm'])
{ {
// makes keys of the alarm-array starting with 1 // makes keys of the alarm-array starting with 1
$content['alarm'] = array(false); $content['alarm'] = array(false);
foreach(array_values($event['alarm']) as $id => $alarm) 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 continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
} }
$alarm['all'] = (int) $alarm['all']; $alarm['all'] = (int) $alarm['all'];
// fix alarm time in case of alread run alarms, where the time will be their keep_time / when they will be cleaned up otherwise // fix alarm time in case of alread run alarms, where the time will be their keep_time / when they will be cleaned up otherwise