Skip to main content
Light Dark System

Historylog

<et2-historylog> | Et2Historylog

The change history of one entry

Overview

Shows the changes recorded for one entry, newest first.

The widget is self-configuring: it needs only the record’s id and app, plus the app’s map of fields to the widgets their values should be displayed with.

<et2-historylog id="history"/>

with $content['history'] = ['id' => 123, 'app' => 'infolog', 'status-widgets' => [...]].

It renders through et2-datagrid, but is not a nextmatch: there is nothing to select, no actions, no favourites, no column preferences, and the sort order is fixed (newest first). What it does share with a nextmatch is the row-fetching plumbing - Et2NextmatchDataProvider, whose host contract it implements - and Et2Filterbox, which drives it through NextmatchInterface.

Initialization is deferred until the tab it sits on is first shown, so an unopened history tab costs nothing.

et2-historylog shows the changes recorded for one entry, newest first. Put it on a tab of an edit dialog and give it the record’s id and app; it configures itself from there.

<et2-historylog id="history"/>
$content['history'] = [
    'id'             => $entry_id,
    'app'            => 'infolog',
    'status-widgets' => [
        'St'    => $this->bo->status[$content['info_type']],
        'Ow'    => 'select-account',
        'En'    => 'date',
    ],
];

Overview
Content
status-widgets
Filtering
What it deliberately does not do
Attributes
Internals


Overview

The history log renders through et2-datagrid, so it gets virtualized rows, column resizing, a column chooser and keyboard navigation for free. It is not a nextmatch, and it is not a form control: it returns no value and never appears in a submit.

Rows come from Api\Storage\History::get_rows() through the same server endpoint a nextmatch uses (Nextmatch::ajax_get_rows()), scoped to one record of one app. An app can override the row source with a get_rows attribute, which is read server-side from the template and never from the client.

Initialization is deferred until the tab it sits on is first shown, so an unopened history tab costs nothing.

Content

$content[<widget id>] is the widget’s whole configuration:

Key Meaning
id The record whose history to show. Without it, the widget renders nothing and requests nothing.
app Which app’s history.
status-widgets Which widget displays which field’s values - see below.
num_rows Page size. Optional.
rows / total Rows the initial exec already carried, used instead of fetching the first page.

Labels for the “Changed” column come from $sel_options['status'] inside the widget’s own namespace, which Etemplate\Widget\HistoryLog::beforeSendToClient() arranges - the history log needs its own owner options (all accounts) without clobbering the surrounding dialog’s.

status-widgets

A map of field code to how that field’s values should be displayed. Every form is accepted:

'status-widgets' => [
    'Ow'           => 'select-account',            // a widget name
    'parent'       => 'link:infolog',              // a widget name with legacy options
    'public'       => ['' => 'No', 1 => 'Yes'],    // select options
    'participants' => [                            // a multi-part value, rendered stacked
        'select-account',
        ['U' => 'Unknown', 'A' => 'Accepted'],
        'integer',
    ],
],

Three statuses exist without being declared, because the server can produce them for any app:

Status Rendered as
~link~ et2-link
~file~ et2-vfs-path - an attachment, UNIONed in from the VFS
user_agent_action plain text

Custom fields need no declaration either: #<name> statuses resolve through the shared customfield-to-widget mapper, so a history value renders the way that field itself does.

A field with no usable widget - an app naming one from a bundle that is not loaded, or a typo - renders its value as plain text and logs one warning, rather than breaking the row.

Long or multi-line values are stored by the server as a unified diff plus a marker. Those rows render an et2-diff spanning both value columns, which caps its own height and offers a pop-out for the full text on hover - but only for a diff tall enough to be cut off.

A diff needs two things it cannot get inside the grid, and the history log supplies both.

Its markup goes into et2-diff’s own light DOM, because the CSS that colours it - the diff2html library’s, plus the overrides that hide the library’s file header and recolour the +/- lines - ships in the page’s theme stylesheet. A document stylesheet never crosses a shadow boundary, and here the diff is behind two, so the rules are lifted out of the theme and adopted into the shadow roots that host a diff. Without that the diff arrives as unstyled text.

Its pop-out is position: fixed, and a fixed element is placed against the nearest ancestor that establishes a containing block rather than against the viewport. The datagrid’s virtualizer gives every row a transform and its body contain: layout, both of which establish one, so a dialog opened from inside a row is sized to that row - the panel collapses and its contents spill across the grid. The cell therefore intercepts the click and hands the diff to Et2Historylog.showDiff(), which opens the dialog in its own shadow root, above the virtualizer. It intercepts only when the diff reports itself overflowing; otherwise the click is left alone and et2-diff ignores it too.

Filtering

Filters live in a drawer, opened by the funnel button above the grid. The button fills in while anything is filtered, so it is visible at a glance that the list is not showing everything.

Filter Wire Notes
Changed field col_filter[status] Multi-select of the “Changed” column’s own option list
User col_filter[owner]
Date col_filter[user_ts] Converted from user time to the server-time column
Search search Matches either value

The changed-field filter offering the display column’s own list is what makes attachments and links filterable: ~file~ and ~link~ are values the rows genuinely carry, so “show me only attachments” and “show me only status changes” both work without inventing a second name for them. Attachments cannot be matched against a user, a date or a search term - they are not in the history table - so those filters exclude them, and a changed-field filter includes them only when it lists ~file~.

The server accepts only those keys (Etemplate\Widget\HistoryLog::$allowed_filters). Anything else is dropped rather than passed to the database, and record_id/appname are re-derived server-side from the request’s own content, so a client cannot ask for another entry’s history.

The “User” column holds two widgets, and each renders its own field: a readonly et2-select-account for owner, and an et2-description for share_email. A change made through a share records who the share was made out to rather than an account, so there is no account to show for those rows - the account hides itself (hidden="$row_cont[share_email]") and the recorded address is shown instead. Both widgets sit in an et2-hbox: a <row>’s direct children are its cells, so two of them side by side would make a sixth cell in a five-column grid, which is silently dropped.

A row whose owner is an account that no longer exists - or 0, which attachment rows inherit from a directory created by a system process - shows an empty User cell. There is no name to resolve, and that is what the legacy widget did too.

What it deliberately does not do

Worth knowing, because each of these is a nextmatch feature someone may expect:

  • No sorting. Newest first, always. The server does not accept a client-supplied sort order.
  • No row selection. There are no actions on a history row. Arrow keys still move a visible cursor for keyboard users, but nothing is ever selected.
  • No column selection and no column preferences. Columns come from the columns attribute every time; the datagrid’s column chooser is switched off.
  • No favourites, no print dialog, no letter search, no auto-refresh, no expandable rows.

Attributes

Attribute Default Purpose
columns user_ts,owner,status,new_value,old_value Which columns to show. Unlisted ones are hidden, not removed - they stay available in the column chooser.
status_id status Id for the “Changed” column’s widget. Move it if the surrounding dialog already has a widget called status; calendar does. Must not equal the history log’s own id.
lazy true Wait for the tab to be shown before loading.
auto-height false Grow to fit rows instead of scrolling internally.
get_rows Api\Storage\History::get_rows Row source. Read server-side from the template only.

Internals

Three pieces, split by what varies:

  • Et2Historylog owns the grid, the filters and the lifecycle. It implements NextmatchInterface, which is what lets Et2Filterbox drive it, and NextmatchDataProviderHost, which is what lets it reuse Et2NextmatchDataProvider - including that provider’s row-cache keep-alive bookkeeping, without which egw’s 5-minute sweep would evict rows the grid can still scroll back to.
  • Et2HistorylogWidgetRegistry resolves status-widgets (plus custom fields and the built-in statuses) into {tagName, attrs} render specs. Specs rather than widget instances: the legacy widget built a live widget for every declared field and every custom field before the tab was looked at.
  • Et2HistorylogValue and Et2HistorylogStatus are the cells that cannot be plain widgets. They exist because the datagrid renders a fixed row template while the history log needs a different widget per row - so the tag in the row template is fixed and the variation lives inside it. Both are bound with id="$row", receiving the whole row rather than one field, because both need the row’s status to decide what to show. The other three columns are ordinary widgets (et2-date-time, et2-select-account).

The row and filter structure is an ordinary eTemplate, api/templates/default/historylog.xet, read by Et2RowProvider like any other datagrid row template.

Row cells find their owner by walking up shadow boundaries: row widgets have no widget-tree parent (the datagrid clones a template rather than building child widgets) and rows live in the datagrid’s shadow DOM, so neither getParent() nor a plain closest() reaches it.

Properties

Name Description Reflects Type Default
autoHeight
auto-height
Grow to fit rows instead of scrolling internally. See _resolveHeight(). boolean false
columns Which columns to show, as a comma-separated list or an array. Kept for compatibility with the legacy widget. Columns not listed are hidden but remain available in the datagrid’s column chooser. string | string[] "user_ts,owner,status,new_value,old_value"
filtersDrawer
The filter drawer, by the name Et2Filterbox looks for when closing on Escape any -
lazy Wait for the tab this sits on to be shown before loading anything. On by default - a history tab is rarely the one the user opens first. boolean true
statusId Id given to the widget rendering the “Changed” column. The history log’s own id is traditionally history, and its changed-field column is named status; an app whose dialog already has a widget called status can move this one out of the way. (Calendar does, via <historylog options="history_status"/>.) No explicit attribute: on purpose. api/etemplate.php rewrites every et2-* attribute name containing _ or - to camelCase before the template reaches the client, so the legacy options="..." arrives as statusId="..." - which the HTML parser lowercases to statusid, exactly the attribute Lit derives from this property name by default. Declaring attribute: "status_id" instead would observe a name that never arrives. string "status"
statusWidgets
The app’s status-widgets map, read by et2-historylog-value when warning about a gap Record | null -
value {app, id, status-widgets, num_rows, rows, total, ...} - what the app put in $content[<widget id>]. Same shape the legacy widget took. Record {}
widgetRegistry
Which widget renders which field’s value, built once from the app’s status-widgets plus the custom fields and the built-in statuses. Read per row by et2-historylog-value. Et2HistorylogWidgetRegistry | null null

Learn more about attributes and properties.

Inherited properties (18)

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

LitElement

Name Description
updateComplete A read-only promise that resolves when the component has finished updating.

Events

Name Description Event Detail
et2-filter Missing description CustomEvent

Learn more about events.

Methods

Name Description Arguments
applyFilters() Merge the given filters into the active ones and reload. The reentrancy guard is the same one Et2Nextmatch needs: dispatching the filter event runs listeners synchronously, and a filter widget whose value setter re-fires “change” on a programmatic set would otherwise come straight back in here before this call returned. set: Record<string, any>, options: { reload? : boolean }
isDirty() A display widget: it never contributes to a submit. Deliberately not an et2_IInput. -
showDiff() Show one row’s diff full-size, in a dialog. Called by et2-historylog-value instead of letting et2-diff open its own dialog, because that one is rendered inside the datagrid’s virtualized row and comes out unusable there - Et2HistorylogValue._handleDiffClick() has the details. Here the dialog is a child of the history log’s shadow root, which is above the virtualizer, so it sizes to the window. value: string
sortBy() The sort order is fixed (newest first) and the server rejects a client-supplied one, so these exist only to satisfy the interface - and because Et2NextmatchDataProvider calls sortBy() when a response echoes an order. _id: string, _asc: boolean, _update: boolean

Learn more about methods.

Inherited methods (23)

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 .children to get web component children
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
transformAttributes() Pick our configuration up out of the content. _createNamespace() gives our children a content perspective scoped to our id, but nothing assigns our own value from it - and once that perspective is open, our content entry is no longer reachable under our id. So it has to be read here, which runs before namespace creation (same reason Et2Nextmatch reads its settings here, from attrs.id).
_createNamespace() The history log’s content is its own namespace (content['history']), like the legacy widget’s.
_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

Parts

Name Description
grid the datagrid
filters the filter drawer’s panel
header the bar above the grid, holding the filter button

Learn more about customizing CSS parts.

These widgets are related by naming but not by inheritance or sub-widget composition.