Tab
<et2-tab> | Et2Tab
et2-tab is one clickable label in a et2-tabbox’s tab row. It is not a standalone widget: it only does anything inside a tabbox, in the
nav slot, paired with an et2-tab-panel.
Two attributes do the work:
-
panelnames theet2-tab-panelthis tab shows. It has to match that panel’snameexactly, or clicking the tab shows nothing. -
activemarks the tab that is open. The tabbox keeps it in sync from then on; you only set it to choose which tab starts open.
hidden removes the tab from the row - that is what the server’s readonlys array
does to a tab it does not want shown. disabled does the same: Shoelace would grey the tab out,
but the eTemplate base widget applies display: none to any disabled non-input widget, and that
wins. Either way the tab is gone, not greyed.
In a template you never write this tag. The tabbox builds one et2-tab per
<tab> entry, so <tab id="general" label="General"/> becomes
<et2-tab panel="general">General</et2-tab>. Write it by hand only outside a
template.
Examples
Tabs in their tabbox
The label is the tab’s content, not an attribute - anything can go in there, including an icon.
<et2-tabbox>
<et2-tab slot="nav" panel="general" active>General</et2-tab>
<et2-tab slot="nav" panel="links">
<et2-image src="image"></et2-image>
Links
</et2-tab>
<et2-tab slot="nav" panel="history" disabled>History</et2-tab>
<et2-tab-panel name="general" active>
<et2-description value="There is a third, disabled tab - it is not in the row at all."></et2-description>
</et2-tab-panel>
<et2-tab-panel name="links">
<et2-description value="Links panel"></et2-description>
</et2-tab-panel>
<et2-tab-panel name="history">
<et2-description value="Never reached"></et2-description>
</et2-tab-panel>
</et2-tabbox>
Clicks and double clicks
A tab takes onclick like any other widget, and adds ondblclick - EGroupware uses
the double click to toggle a maximised tab. Both run in addition to switching to the panel, they do not
replace it.
clicks: none
<et2-tabbox>
<et2-tab id="tab-click-example" slot="nav" panel="one" active>Double-click me</et2-tab>
<et2-tab slot="nav" panel="two">Other</et2-tab>
<et2-tab-panel name="one" active><et2-description value="Panel one"></et2-description></et2-tab-panel>
<et2-tab-panel name="two"><et2-description value="Panel two"></et2-description></et2-tab-panel>
</et2-tabbox>
<p>clicks: <span id="tab-click-output">none</span></p>
<script>
const tab = document.getElementById("tab-click-example");
const out = document.getElementById("tab-click-output");
tab.addEventListener("click", () => {out.textContent = "click";});
tab.addEventListener("dblclick", () => {out.textContent = "dblclick";});
</script>
Inherited properties (21)
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 |
SlTab (Shoelace)
| Name | Description |
|---|---|
active |
Draws the tab in an active state. |
closable |
Makes the tab closable and shows a close button. |
panel |
The name of the tab panel this tab is associated with. The panel must be located in the same tab group. |
LitElement
| Name | Description |
|---|---|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Inherited methods (21)
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() |
Click handler calling custom handler set via onclick attribute to this.onclick |
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 |