Link
<et2-link> | Et2Link
Overview
Display a specific, single entry from an application
The entry is specified with the application name, and the app’s ID for that entry. You can set it directly
in the properties (application, entryId) or use set_value() to pass an object {app: string, id: string,
[title: string]} or string in the form
Choosing a link widget
A link joins two entries across applications - a contact attached to an InfoLog task, a file
attached to a project. One end of a link is always an application name plus that application’s own ID for
the entry, written <app>:<id>. See
Linking system widgets for the group as a whole.
All ten widgets in the family are built on that one idea, and differ only in how many links they show at once and whether the user can change them:
| Widget | What it is for |
|---|---|
<et2-link>
|
Show one entry as a clickable title |
<et2-link-entry_ro>
|
The same display, used automatically when <et2-link-entry> is readonly |
<et2-link-string>
|
Show all links of an entry, comma separated on one line |
<et2-link-list>
|
Show all links of an entry as a list, with delete and a context menu |
<et2-link-to>
|
Create links: pick an entry, a VFS file, or upload a file |
<et2-link-entry>
|
Pick one entry - application selector plus search. This is the input inside
<et2-link-to>
|
<et2-link-apps>
|
Just the application selector out of <et2-link-entry> |
<et2-link-search>
|
Just the entry search out of <et2-link-entry> |
<et2-link-add>
|
Not a link at all - a button that opens another application’s “add entry” dialog |
<et2-link-paste-dialog>
|
Pick files out of the EGroupware file clipboard so they can be linked |
Two short rules cover most templates:
-
To show what is already linked, use
<et2-link-string>(one line, for a nextmatch row) or<et2-link-list>(a list, for a “Links” tab). -
To let the user add links, use
<et2-link-to>, and give it the sameidas the<et2-link-list>beside it so the two halves share one value. That pair is the whole “Links” tab in InfoLog, Timesheet, Calendar and friends.
Examples
A link’s title lives on the server: given addressbook:42 the widget calls
egw.link_title() to find out that entry 42 is “Fischer, Peter”. This documentation site has
no server, so the examples below pass the title in with the link. In a real template you give only the
application and the ID and let the widget fetch the title.
One entry
app and entryId say which entry to show. Passing a
{app, id, title} object as the value sets all three at once, and a title supplied this way is
used as-is instead of being looked up.
<et2-link id="link-example"></et2-link>
<script>
const link = document.getElementById("link-example");
customElements.whenDefined("et2-link").then(() =>
{
link.value = {app: "addressbook", id: "42", title: "Fischer, Peter"};
});
</script>
Clicking it calls egw.open() for that entry. linkHook chooses which view you land
in (view, the default, or edit or add), and
extraLinkTarget is passed on as the window target, so
extraLinkTarget="_blank" opens the entry in a new tab.
An extra remark
Any other key in the value object is kept in the element’s dataset, and remark -
the comment a user can put on a link - is rendered after the title. It is hidden by
<et2-link-string> and shown by <et2-link-list>.
<et2-link id="link-remark-example"></et2-link>
<script>
const link = document.getElementById("link-remark-example");
customElements.whenDefined("et2-link").then(() =>
{
link.value = {app: "addressbook", id: "42", title: "Fischer, Peter", remark: "Ordered twice"};
});
</script>
A link to an external URL
url is a pseudo-application: there is no such EGroupware application, the “entry ID” is the URL
itself, and clicking opens it in a new tab instead of going through egw.open(). Because no
application is registered for it there is no application icon to look up either, so it carries a small
inline one of its own.
<et2-link id="link-url-example"></et2-link>
<script>
const link = document.getElementById("link-url-example");
customElements.whenDefined("et2-link").then(() =>
{
link.value = {app: "url", id: "https://www.egroupware.org", title: "www.egroupware.org"};
});
</script>
Breaking a long title
Titles are one line and get an ellipsis when they do not fit. breakTitle names a string the
title is allowed to wrap after - the widget puts a zero-width space behind every occurrence and protects the
remaining spaces and hyphens, so the title only ever breaks where you said it may.
<et2-link id="link-break-example" breakTitle=":" style="width: 12em"></et2-link>
<script>
const link = document.getElementById("link-break-example");
customElements.whenDefined("et2-link").then(() =>
{
link.value = {app: "infolog", id: "7", title: "Phone call: ask about the renewal"};
});
</script>
Properties
| Name | Description | Reflects | Type | Default |
|---|---|---|---|---|
app
|
Specify the application for the entry |
|
string
|
- |
breakTitle
|
Breaks title into multiple lines based on this delimiter by replacing it with ‘\r\n’” |
string
|
- | |
entryId
|
Application entry ID |
|
string
|
- |
extraLinkTarget
|
Optional parameter to be passed to egw().open in order to open links in specified target eg. _blank |
string
|
- | |
linkHook
|
View link type Used for displaying the linked entry [view|edit|add] default “view” |
string
|
- | |
targetApp
|
Target application Passed to egw.open() to open entry in specified application |
string
|
- | |
value
|
Pass value as an object, will be parsed to set application & entryId |
LinkInfo | string
|
- |
Learn more about attributes and properties.
Inherited properties (20)
Et2Widget
| Name | Description |
|---|---|
accesskey |
Accesskey provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character. |
actions |
Set Actions on the widget Each action is defined as an object: move: { type: “drop”, acceptedTypes: “mail”, icon: “move”, caption: “Move to” onExecute: javascript:mail_move” } This will turn the widget into a drop target for “mail” drag types. When “mail” drag types are dropped, the global function mail_move(egwAction action, egwActionObject sender) will be called. The ID of the dragged “mail” will be in sender.id, some information about the sender will be in sender.context. The etemplate2 widget involved can typically be found in action.parent.data.widget, so your handler can operate in the widget context easily. The location varies depending on your action though. It might be action.parent.parent.data.widget To customise how the actions are handled for a particular widget, override _link_actions(). It handles the more widget-specific parts. |
align |
Used by Et2Box to determine alignment. Allowed values are left, right |
class |
CSS Class. This class is applied to the outside, on the web component itself. Due to how WebComponents work, this might not change anything inside the component. |
data |
Set the dataset from a CSV |
deferredProperties |
Any attribute that refers to row content cannot be resolved immediately, but some like booleans cannot stay a string because it’s a boolean attribute. We store them for later, and parse when they’re fully in their row. If you are creating a widget that can go in a nextmatch row, and it has boolean attributes that can change for each row, add those attributes into deferredProperties |
disabled |
Defines whether this widget is visibly disabled. The widget is still visible, but clearly cannot be interacted with. Widgets disabled in the template will not return a value to the application code, even if re-enabled via javascript before submitting. To allow a disabled widget to be re-enabled and return a value, disable via javascript in the app’s et2_ready() instead of an attribute in the template file. |
dom_id |
Get the actual DOM ID, which has been prefixed to make sure it’s unique. |
hidden |
The widget is not visible. As far as the user is concerned, the widget does not exist. Widgets hidden with an attribute in the template may not be created in the DOM, and will not return a value. Widgets can be hidden after creation, and they may return a value if hidden this way. |
id |
Get the ID of the widget |
label |
The label of the widget This is usually displayed in some way. It’s also important for accessability. This is defined in the parent somewhere, and re-defining it causes labels to disappear |
noLang |
Disable any translations for the widget |
parentId |
Parent is different than what is specified in the template / hierarchy. Widget ID of another node to insert this node into instead of the normal location |
statustext |
Tooltip which is shown for this element on hover |
styles |
WebComponent * |
options |
Get property-values as object |
supportedWidgetClasses |
et2_widget compatability |
ExposeMixin
| Name | Description |
|---|---|
exposeValue |
Get the info needed to determine if this widget’s value allows it to participate in expose It needs to have a path, and we use mime to determine if it can expose It’s also passed to getMedia() when we’re not reading from a nextmatch |
mediaContentFunction |
Function to extract an image list “Normally” we’ll try to pull a list of images from the nextmatch or show just the current widget, but if you know better you can provide a method to get the list. |
LitElement
| Name | Description |
|---|---|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Inherited methods (22)
Et2Widget
| Name | Description |
|---|---|
checkCreateNamespace() |
Checks whether a namespace exists for this element in the content array. If yes, an own perspective of the content array is created. If not, the parent content manager is used. Constructor attributes are passed in case a child needs to make decisions |
clone() |
Creates a copy of this widget. |
createElementFromNode() |
Create a et2_widget from an XML node. First the type and attributes are read from the node. Then the readonly & modifications arrays are checked for changes specific to the loaded data. Then the appropriate constructor is called. After the constructor returns, the widget has a chance to further initialize itself from the XML node when the widget’s loadFromXML() method is called with the node. |
getArrayMgr() |
Returns the array manager object for the given part |
getArrayMgrs() |
Returns an associative array containing the top-most array managers. |
getChildren() |
Get child widgets Use |
getInstanceManager() |
Returns the instance manager |
getPath() |
Returns the path into the data array. By default, array manager takes care of this, but some extensions need to override this |
getRoot() |
Returns the base widget Usually this is the same as getInstanceManager().widgetContainer |
loadFromXML() |
Loads the widget tree from an XML node |
loadingFinished() |
Needed for legacy compatability. |
parseXMLAttrs() |
The parseXMLAttrs function takes an XML DOM attributes object and adds the given attributes to the _target associative array. This function also parses the legacyOptions. N.B. This is only used for legacy widgets. WebComponents use transformAttributes() and do their own handling of attributes. |
set_label() |
NOT the setter, since we cannot add to the DOM before connectedCallback() TODO: This is not best practice. Should just set property, DOM modification should be done in render https://lit-element.polymer-project.org/guide/templates#design-a-performant-template |
setArrayMgr() |
Sets the array manager for the given part |
setArrayMgrs() |
Sets all array manager objects - this function can be used to set the root array managers of the container object. |
setInstanceManager() |
Set the instance manager Normally this is not needed as it’s set on the top-level container, and we just return that reference |
_handleClick() |
Just override the normal click handler |
destroy() |
et2_widget compatability |
set_class() |
Set the widget class |
set_disabled() |
Wrapper on this.disabled because legacy had it. |
set_statustext() |
supports legacy set_statustext |
ExposeMixin
| Name | Description |
|---|---|
getMedia() |
Get the info needed to show the given value as slide(s) _value is (usually?) pulled from egw.dataGetUIDdata() Override this |
Belongs to
Related
These widgets are related by naming but not by inheritance or sub-widget composition.