mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Link fixes
- Fix actual Expose didn't work on links themselves - Adjust delete button / context menu caption to match file/link
This commit is contained in:
parent
a3a63f3586
commit
b9d145a40b
@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import {ExposeMixin} from "../Expose/ExposeMixin";
|
||||
import {ExposeMixin, ExposeValue} from "../Expose/ExposeMixin";
|
||||
import {css, html, LitElement} from "@lion/core";
|
||||
import {Et2Widget} from "../Et2Widget/Et2Widget";
|
||||
import {et2_IDetachedDOM} from "../et2_core_interfaces";
|
||||
@ -158,6 +158,16 @@ export class Et2Link extends ExposeMixin<Et2Widget>(Et2Widget(LitElement)) imple
|
||||
return this._title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value representation of the link.
|
||||
*
|
||||
* @returns {LinkInfo | string}
|
||||
*/
|
||||
get value() : LinkInfo | string
|
||||
{
|
||||
return this.app && this.entry_id ? this.app + ":" + this.entry_id : "";
|
||||
}
|
||||
|
||||
set value(_value : LinkInfo | string)
|
||||
{
|
||||
if(!_value)
|
||||
@ -215,6 +225,35 @@ export class Et2Link extends ExposeMixin<Et2Widget>(Et2Widget(LitElement)) imple
|
||||
this.value = _value;
|
||||
}
|
||||
|
||||
get exposeValue() : ExposeValue
|
||||
{
|
||||
let info = <ExposeValue><unknown>{
|
||||
app: this.app,
|
||||
id: this.entry_id,
|
||||
path: this.dataset['icon']
|
||||
};
|
||||
info['label'] = this.title;
|
||||
info = Object.assign(info, this.dataset);
|
||||
|
||||
if(info['remark'])
|
||||
{
|
||||
info['label'] += " - " + info['remark'];
|
||||
}
|
||||
if(!info.path && this.app == "file")
|
||||
{
|
||||
// Fallback to check the "normal" place if path wasn't available
|
||||
info.path = "/webdav.php/apps/" + this.dataset.app2 + "/" + this.dataset.id2 + "/" + this.entry_id;
|
||||
}
|
||||
|
||||
if(typeof info["type"] !== "undefined")
|
||||
{
|
||||
// Links use "type" for mimetype.
|
||||
info.mime = info["type"];
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* If app or entry_id has changed, we'll update the title
|
||||
*
|
||||
@ -246,13 +285,17 @@ export class Et2Link extends ExposeMixin<Et2Widget>(Et2Widget(LitElement)) imple
|
||||
|
||||
_handleClick(_ev : MouseEvent) : boolean
|
||||
{
|
||||
this.egw().open(Object.assign({
|
||||
app: this.app,
|
||||
id: this.entry_id
|
||||
}, this.dataset), "", this.link_hook, this.dataset.extra_args, this.target_app || this.app, this.target_app);
|
||||
// If super didn't handle it (returns false), just use egw.open()
|
||||
if(super._handleClick(_ev))
|
||||
{
|
||||
this.egw().open(Object.assign({
|
||||
app: this.app,
|
||||
id: this.entry_id
|
||||
}, this.dataset), "", this.link_hook, this.dataset.extra_args, this.target_app || this.app, this.target_app);
|
||||
}
|
||||
|
||||
_ev.stopImmediatePropagation();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
getDetachedAttributes(_attrs : string[])
|
||||
@ -289,6 +332,7 @@ export interface LinkInfo
|
||||
link_id? : string;
|
||||
comment? : string
|
||||
icon? : string,
|
||||
help? : string,
|
||||
|
||||
// Extra information for things like files
|
||||
download_url? : string,
|
||||
|
@ -270,7 +270,7 @@ export class Et2LinkList extends Et2LinkString
|
||||
{
|
||||
this._delete_link(link);
|
||||
}}
|
||||
aria-label="${this.egw().lang("Delete")}"
|
||||
aria-label="${this.egw().lang(link.app === "file" ? "Delete" : "Unlink")}"
|
||||
>
|
||||
</et2-image>`;
|
||||
}
|
||||
@ -513,7 +513,7 @@ export class Et2LinkList extends Et2LinkString
|
||||
this.context.getItem("zip").set_enabled(this._link_list.length >= 2);
|
||||
// Show delete item only if the widget is not readonly
|
||||
this.context.getItem("delete").set_enabled(!this.readonly);
|
||||
|
||||
this.context.getItem("delete").caption = _link_data.app === "file" ? this.egw().lang("Delete file") : this.egw().lang("Delete link");
|
||||
this.context.data = _link_data;
|
||||
this.context.showAt(_ev.pageX, _ev.pageY, true);
|
||||
_ev.preventDefault();
|
||||
|
@ -173,7 +173,7 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
|
||||
protected _linkTemplate(link) : TemplateResult
|
||||
{
|
||||
return html`
|
||||
<et2-link app="${link.app}" entry_id="${link.id}" .value=${link}></et2-link>`;
|
||||
<et2-link app="${link.app}" entry_id="${link.id}" .value=${link} ._parent=${this}></et2-link>`;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,11 +242,12 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadingPromise = this.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_list', [_value]).then(_value =>
|
||||
{
|
||||
this._addLinks(_value);
|
||||
this._loadingPromise = null;
|
||||
})
|
||||
this._loadingPromise = <Promise<LinkInfo[]>>(this.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_list', [_value]))
|
||||
.then(_value =>
|
||||
{
|
||||
this._addLinks(_value);
|
||||
this._loadingPromise = null;
|
||||
})
|
||||
}
|
||||
|
||||
getDetachedAttributes(_attrs : string[])
|
||||
|
@ -499,9 +499,12 @@ export function ExposeMixin<B extends Constructor<LitElement>>(superclass : B)
|
||||
{
|
||||
if(exposable === this)
|
||||
{
|
||||
options.index = index;
|
||||
options.index = mediaContent.length;
|
||||
}
|
||||
if(exposable.isExposable())
|
||||
{
|
||||
mediaContent.push(...exposable.getMedia(Object.assign({}, IMAGE_DEFAULT, exposable.exposeValue)));
|
||||
}
|
||||
mediaContent.push(...exposable.getMedia(Object.assign({}, IMAGE_DEFAULT, exposable.exposeValue)));
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
|
@ -194,7 +194,6 @@ class Link extends Etemplate\Widget
|
||||
if ($link['app'] == Api\Link::VFS_APPNAME)
|
||||
{
|
||||
$link['target'] = '_blank';
|
||||
$link['label'] = 'Delete';
|
||||
$link['help'] = lang('Delete this file');
|
||||
$link['title'] = Api\Vfs::decodePath($link['title']);
|
||||
$link['icon'] = Api\Link::vfs_path($link['app2'],$link['id2'],$link['id'],true);
|
||||
@ -214,7 +213,6 @@ class Link extends Etemplate\Widget
|
||||
else
|
||||
{
|
||||
$link['icon'] = Api\Link::get_registry($link['app'], 'icon');
|
||||
$link['label'] = 'Unlink';
|
||||
$link['help'] = lang('Remove this link (not the entry itself)');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user